| 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_;
|
|
|