Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7164)

Unified Diff: chrome/browser/extensions/extension_garbage_collector.h

Issue 1890163004: extensions: Abstract out install delay strategy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for comments in #4 Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_garbage_collector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_garbage_collector.h
diff --git a/chrome/browser/extensions/extension_garbage_collector.h b/chrome/browser/extensions/extension_garbage_collector.h
index 9a768062b51eabe5053ab90725eb43c8b058c96e..014337451d9377f63302991c251ee02b7af75467 100644
--- a/chrome/browser/extensions/extension_garbage_collector.h
+++ b/chrome/browser/extensions/extension_garbage_collector.h
@@ -11,6 +11,7 @@
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "chrome/browser/extensions/install_gate.h"
#include "chrome/browser/extensions/install_observer.h"
#include "components/keyed_service/core/keyed_service.h"
@@ -25,7 +26,9 @@ namespace extensions {
// The class is owned by ExtensionService, but is mostly independent. Tasks to
// garbage collect extensions and isolated storage are posted once the
// ExtensionSystem signals ready.
-class ExtensionGarbageCollector : public KeyedService, public InstallObserver {
+class ExtensionGarbageCollector : public KeyedService,
+ public InstallObserver,
+ public InstallGate {
public:
explicit ExtensionGarbageCollector(content::BrowserContext* context);
~ExtensionGarbageCollector() override;
@@ -35,14 +38,18 @@ class ExtensionGarbageCollector : public KeyedService, public InstallObserver {
// Manually trigger GarbageCollectExtensions() for testing.
void GarbageCollectExtensionsForTest();
- // Overriddes for KeyedService:
+ // KeyedService:
void Shutdown() override;
- // Overriddes for InstallObserver
+ // InstallObserver:
void OnBeginCrxInstall(const std::string& extension_id) override;
void OnFinishCrxInstall(const std::string& extension_id,
bool success) override;
+ // InstallGate:
+ Action ShouldDelay(const Extension* extension,
+ bool install_immediately) override;
+
protected:
// Cleans up the extension install directory. It can end up with garbage in it
// if extensions can't initially be removed when they are uninstalled (eg if a
@@ -58,6 +65,10 @@ class ExtensionGarbageCollector : public KeyedService, public InstallObserver {
// cache lifetimes.
void GarbageCollectIsolatedStorageIfNeeded();
+ // Restart any extension installs which were delayed for isolated storage
+ // garbage collection.
+ void OnGarbageCollectIsolatedStorageFinished();
+
static void GarbageCollectExtensionsOnFileThread(
const base::FilePath& install_directory,
const std::multimap<std::string, base::FilePath>& extension_paths);
@@ -69,6 +80,12 @@ class ExtensionGarbageCollector : public KeyedService, public InstallObserver {
// garbage collection from running while a CRX is being installed.
int crx_installs_in_progress_;
+ // Set to true to delay all new extension installations. Acts as a lock to
+ // allow background processing of garbage collection of on-disk state without
+ // needing to worry about race conditions caused by extension installation and
+ // reinstallation.
+ bool installs_delayed_for_gc_ = false;
+
// Generate weak pointers for safely posting to the file thread for garbage
// collection.
base::WeakPtrFactory<ExtensionGarbageCollector> weak_factory_;
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_garbage_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698