Fix ExtensionServiceTest.ClearExtensionData flakiness
The test runs work on the IO thread, but doesn't wait for the IO thread.
Fails ~17% of the time on ChromeOS
BUG=396504
[email protected]
[email protected]
Review URL: https://codereview.chromium.org/421193002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@286674 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/data_deleter.cc b/chrome/browser/extensions/data_deleter.cc
index b28e7b2..6131da8 100644
--- a/chrome/browser/extensions/data_deleter.cc
+++ b/chrome/browser/extensions/data_deleter.cc
@@ -37,7 +37,8 @@
// |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);
@@ -56,7 +57,8 @@
~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.
@@ -64,20 +66,24 @@
~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);
@@ -87,7 +93,8 @@
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());
@@ -99,9 +106,12 @@
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)