Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / browsing_data / browsing_data_file_system_helper.cc
index dbb0b1f..14ccbbc 100644 (file)
@@ -4,10 +4,11 @@
 
 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
 
+#include <set>
+
 #include "base/bind.h"
 #include "base/compiler_specific.h"
 #include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
 #include "base/sequenced_task_runner.h"
 #include "base/strings/string_util.h"
 #include "base/strings/utf_string_conversions.h"
@@ -96,9 +97,9 @@ BrowsingDataFileSystemHelperImpl::~BrowsingDataFileSystemHelperImpl() {
 
 void BrowsingDataFileSystemHelperImpl::StartFetching(
     const base::Callback<void(const std::list<FileSystemInfo>&)>& callback) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   DCHECK(!is_fetching_);
-  DCHECK_EQ(false, callback.is_null());
+  DCHECK(!callback.is_null());
   is_fetching_ = true;
   completion_callback_ = callback;
   file_task_runner()->PostTask(
@@ -110,7 +111,7 @@ void BrowsingDataFileSystemHelperImpl::StartFetching(
 
 void BrowsingDataFileSystemHelperImpl::DeleteFileSystemOrigin(
     const GURL& origin) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   file_task_runner()->PostTask(
       FROM_HERE,
       base::Bind(
@@ -125,7 +126,9 @@ void BrowsingDataFileSystemHelperImpl::FetchFileSystemInfoInFileThread() {
   const fileapi::FileSystemType types[] = {
     fileapi::kFileSystemTypeTemporary,
     fileapi::kFileSystemTypePersistent,
+#if defined(ENABLE_EXTENSIONS)
     fileapi::kFileSystemTypeSyncable,
+#endif
   };
 
   typedef std::map<GURL, FileSystemInfo> OriginInfoMap;
@@ -136,13 +139,13 @@ void BrowsingDataFileSystemHelperImpl::FetchFileSystemInfoInFileThread() {
       filesystem_context_->GetQuotaUtil(type);
     DCHECK(quota_util);
     std::set<GURL> origins;
-    quota_util->GetOriginsForTypeOnFileThread(type, &origins);
+    quota_util->GetOriginsForTypeOnFileTaskRunner(type, &origins);
     for (std::set<GURL>::iterator iter = origins.begin();
         iter != origins.end(); ++iter) {
       const GURL& current = *iter;
       if (!BrowsingDataHelper::HasWebScheme(current))
         continue;  // Non-websafe state is not considered browsing data.
-      int64 usage = quota_util->GetOriginUsageOnFileThread(
+      int64 usage = quota_util->GetOriginUsageOnFileTaskRunner(
           filesystem_context_.get(), current, type);
       OriginInfoMap::iterator inserted =
           file_system_info_map.insert(
@@ -162,7 +165,7 @@ void BrowsingDataFileSystemHelperImpl::FetchFileSystemInfoInFileThread() {
 }
 
 void BrowsingDataFileSystemHelperImpl::NotifyOnUIThread() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   DCHECK(is_fetching_);
   completion_callback_.Run(file_system_info_);
   completion_callback_.Reset();
@@ -172,7 +175,7 @@ void BrowsingDataFileSystemHelperImpl::NotifyOnUIThread() {
 void BrowsingDataFileSystemHelperImpl::DeleteFileSystemOriginInFileThread(
     const GURL& origin) {
   DCHECK(file_task_runner()->RunsTasksOnCurrentThread());
-  filesystem_context_->DeleteDataForOriginOnFileThread(origin);
+  filesystem_context_->DeleteDataForOriginOnFileTaskRunner(origin);
 }
 
 }  // namespace
@@ -189,19 +192,17 @@ BrowsingDataFileSystemHelper* BrowsingDataFileSystemHelper::Create(
 }
 
 CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper(
-    Profile* profile)
-    : is_fetching_(false) {
+    Profile* profile) {
 }
 
-CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper()
-    : is_fetching_(false) {
+CannedBrowsingDataFileSystemHelper::CannedBrowsingDataFileSystemHelper() {
 }
 
 CannedBrowsingDataFileSystemHelper::~CannedBrowsingDataFileSystemHelper() {}
 
 CannedBrowsingDataFileSystemHelper*
     CannedBrowsingDataFileSystemHelper::Clone() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   CannedBrowsingDataFileSystemHelper* clone =
       new CannedBrowsingDataFileSystemHelper();
   // This list only mutates on the UI thread, so it's safe to work with it here
@@ -212,7 +213,7 @@ CannedBrowsingDataFileSystemHelper*
 
 void CannedBrowsingDataFileSystemHelper::AddFileSystem(
     const GURL& origin, const fileapi::FileSystemType type, const int64 size) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   // This canned implementation of AddFileSystem uses an O(n^2) algorithm; which
   // is fine, as it isn't meant for use in a high-volume context. If it turns
   // out that we want to start using this in a context with many, many origins,
@@ -248,27 +249,15 @@ bool CannedBrowsingDataFileSystemHelper::empty() const {
 }
 
 size_t CannedBrowsingDataFileSystemHelper::GetFileSystemCount() const {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
   return file_system_info_.size();
 }
 
 void CannedBrowsingDataFileSystemHelper::StartFetching(
     const base::Callback<void(const std::list<FileSystemInfo>&)>& callback) {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-  DCHECK(!is_fetching_);
-  DCHECK_EQ(false, callback.is_null());
-  is_fetching_ = true;
-  completion_callback_ = callback;
+  DCHECK_CURRENTLY_ON(BrowserThread::UI);
+  DCHECK(!callback.is_null());
 
   BrowserThread::PostTask(
-      BrowserThread::UI, FROM_HERE,
-      base::Bind(&CannedBrowsingDataFileSystemHelper::NotifyOnUIThread, this));
-}
-
-void CannedBrowsingDataFileSystemHelper::NotifyOnUIThread() {
-  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-  DCHECK(is_fetching_);
-  completion_callback_.Run(file_system_info_);
-  completion_callback_.Reset();
-  is_fetching_ = false;
+      BrowserThread::UI, FROM_HERE, base::Bind(callback, file_system_info_));
 }