Garbage collect extensions only if there are no pending extension installs that could still be using the Temp directory.
BUG=161920
Review URL: https://chromiumcodereview.appspot.com/11411227
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170149 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 13e3d5c5..f49aaa8 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -178,6 +178,9 @@
// Wait this many seconds after an extensions becomes idle before updating it.
static const int kUpdateIdleDelay = 5;
+// Wait this many seconds before trying to garbage collect extensions again.
+static const int kGarbageCollectRetryDelay = 30;
+
const char* kNaClPluginMimeType = "application/x-nacl";
static bool IsSyncableExtension(const Extension& extension) {
@@ -1989,6 +1992,17 @@
if (extension_prefs_->pref_service()->ReadOnly())
return;
+ if (pending_extension_manager()->HasPendingExtensions()) {
+ // Don't garbage collect while there are pending installations, which may
+ // be using the temporary installation directory. Try to garbage collect
+ // again later.
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&ExtensionService::GarbageCollectExtensions, AsWeakPtr()),
+ base::TimeDelta::FromSeconds(kGarbageCollectRetryDelay));
+ return;
+ }
+
scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> info(
extension_prefs_->GetInstalledExtensionsInfo());