Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / data_deleter.cc
index 9d8ffb7..acd5d09 100644 (file)
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/site_instance.h"
 #include "content/public/browser/storage_partition.h"
+#include "extensions/browser/api/storage/storage_frontend.h"
 #include "extensions/browser/extension_prefs.h"
 #include "extensions/browser/extension_system.h"
 #include "extensions/common/constants.h"
 #include "extensions/common/extension.h"
 #include "net/url_request/url_request_context_getter.h"
 
-#if defined(ENABLE_EXTENSIONS)
-#include "extensions/browser/api/storage/storage_frontend.h"
-#endif
-
 using base::WeakPtr;
 using content::BrowserContext;
 using content::BrowserThread;
@@ -37,7 +34,8 @@ namespace {
 // |partition|.
 void DeleteOrigin(Profile* profile,
                   StoragePartition* partition,
-                  const GURL& origin) {
+                  const GURL& origin,
+                  const base::Closure& callback) {
   DCHECK_CURRENTLY_ON(BrowserThread::UI);
   DCHECK(profile);
   DCHECK(partition);
@@ -53,33 +51,36 @@ void DeleteOrigin(Profile* profile,
     // simpler than special casing.  This code should go away once we merge
     // the various URLRequestContexts (http://crbug.com/159193).
     partition->ClearDataForOrigin(
-        StoragePartition::REMOVE_DATA_MASK_ALL &
-            (~StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE),
+        ~StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE,
         StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
         origin,
-        profile->GetRequestContextForExtensions());
+        profile->GetRequestContextForExtensions(),
+        callback);
   } else {
     // We don't need to worry about the media request context because that
     // shares the same cookie store as the main request context.
     partition->ClearDataForOrigin(
-        StoragePartition::REMOVE_DATA_MASK_ALL &
-            (~StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE),
+        ~StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE,
         StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
         origin,
-        partition->GetURLRequestContext());
+        partition->GetURLRequestContext(),
+        callback);
   }
 }
 
-void OnNeedsToGarbageCollectIsolatedStorage(WeakPtr<ExtensionService> es) {
-  if (!es)
-    return;
-  ExtensionPrefs::Get(es->profile())->SetNeedsStorageGarbageCollection(true);
+void OnNeedsToGarbageCollectIsolatedStorage(WeakPtr<ExtensionService> es,
+                                            const base::Closure& callback) {
+  if (es)
+    ExtensionPrefs::Get(es->profile())->SetNeedsStorageGarbageCollection(true);
+  callback.Run();
 }
 
 } // namespace
 
 // static
-void DataDeleter::StartDeleting(Profile* profile, const Extension* extension) {
+void DataDeleter::StartDeleting(Profile* profile,
+                                const Extension* extension,
+                                const base::Closure& callback) {
   DCHECK(profile);
   DCHECK(extension);
 
@@ -89,7 +90,8 @@ void DataDeleter::StartDeleting(Profile* profile, const Extension* extension) {
         util::GetSiteForExtensionId(extension->id(), profile),
         base::Bind(
             &OnNeedsToGarbageCollectIsolatedStorage,
-            ExtensionSystem::Get(profile)->extension_service()->AsWeakPtr()));
+            ExtensionSystem::Get(profile)->extension_service()->AsWeakPtr(),
+            callback));
   } else {
     GURL launch_web_url_origin(
         AppLaunchInfo::GetLaunchWebURL(extension).GetOrigin());
@@ -101,9 +103,12 @@ void DataDeleter::StartDeleting(Profile* profile, const Extension* extension) {
     if (extension->is_hosted_app() &&
         !profile->GetExtensionSpecialStoragePolicy()->
             IsStorageProtected(launch_web_url_origin)) {
-      DeleteOrigin(profile, partition, launch_web_url_origin);
+      DeleteOrigin(profile,
+                   partition,
+                   launch_web_url_origin,
+                   base::Bind(&base::DoNothing));
     }
-    DeleteOrigin(profile, partition, extension->url());
+    DeleteOrigin(profile, partition, extension->url(), callback);
   }
 
 #if defined(ENABLE_EXTENSIONS)