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

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

Issue 9817018: Cleaning Up Extensions When Local Content Removed (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Pulled garbage collection into its own class. Created 8 years, 9 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
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
new file mode 100644
index 0000000000000000000000000000000000000000..d9717e342a7d1acde714df61ab1271ba9353e04a
--- /dev/null
+++ b/chrome/browser/extensions/extension_garbage_collector.h
@@ -0,0 +1,49 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_GARBAGE_COLLECTOR_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_GARBAGE_COLLECTOR_H_
+#pragma once
+
+#include <map>
+#include <vector>
+
+#include "base/file_path.h"
+#include "base/memory/ref_counted.h"
+
+class ExtensionService;
+
+// Garbage collection for extensions. This will delete any directories in the
+// installation directory of |extension_service_| that aren't valid, as well
+// as removing any references in the preferences to extensions that are
+// missing local content.
+class ExtensionGarbageCollector
+ : public base::RefCountedThreadSafe<ExtensionGarbageCollector> {
+ public:
+ explicit ExtensionGarbageCollector(ExtensionService* extension_service);
+ virtual ~ExtensionGarbageCollector();
+
+ // Begin garbage collection; fetch the installed extensions' ids.
+ void GarbageCollectExtensions();
+
+ private:
+ // Check for invalid extension directories and for any extensions that are
+ // missing local content.
+ void CheckExtensionDirectories(
+ const std::map<std::string, FilePath>& extension_paths);
+
+ // Check the installation directory for any invalid/unused extension
+ // directories, deleting them if found.
+ void CheckInstalledDirectories(
+ const std::map<std::string, FilePath>& extension_paths);
+
+ // Remove all references to extensions which are missing local content (e.g.
+ // the extension's directory was deleted from the install directory).
+ void RemoveExtensionsMissingLocalContent(
+ const std::vector<std::string>& bad_extensions);
+
+ ExtensionService* extension_service_;
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_GARBAGE_COLLECTOR_H_

Powered by Google App Engine
This is Rietveld 408576698