OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_GARBAGE_COLLECTOR_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_GARBAGE_COLLECTOR_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <set> |
| 10 |
| 11 #include "base/file_path.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 |
| 14 class ExtensionService; |
| 15 |
| 16 // Garbage collection for extensions. This will delete any directories in the |
| 17 // installation directory of |extension_service_| that aren't valid, as well |
| 18 // as removing any references in the preferences to extensions that are |
| 19 // missing local content. |
| 20 class ExtensionGarbageCollector |
| 21 : public base::RefCountedThreadSafe<ExtensionGarbageCollector> { |
| 22 public: |
| 23 explicit ExtensionGarbageCollector(ExtensionService* extension_service); |
| 24 virtual ~ExtensionGarbageCollector(); |
| 25 |
| 26 // Begin garbage collection; fetch the installed extensions' ids. |
| 27 void GarbageCollectExtensions(); |
| 28 |
| 29 private: |
| 30 // Check the installation directory for directories with invalid extension |
| 31 // ids, deleting them if found. Call CheckExtensionPreferences with a list of |
| 32 // present directories. |
| 33 void CheckExtensionDirectoriesOnBackgroundThread( |
| 34 const FilePath& installation_directory); |
| 35 |
| 36 // Check for any extension directories which: |
| 37 // - Are an old version of a current extension; |
| 38 // - Are present in the preferences but not on the file system; |
| 39 // - Are present on the file system, but not in the preferences |
| 40 // and delete them if found. |
| 41 void CheckExtensionPreferences(const std::set<FilePath>& extension_paths); |
| 42 |
| 43 // Helper function to cleanup any old versions of an extension in the |
| 44 // extension's base directory. |
| 45 void CleanupOldVersionsOnBackgroundThread( |
| 46 const FilePath& path, const FilePath& current_version); |
| 47 |
| 48 ExtensionService* extension_service_; |
| 49 }; |
| 50 |
| 51 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_GARBAGE_COLLECTOR_H_ |
OLD | NEW |