| 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 | |
| 13 class ExtensionService; | |
| 14 | |
| 15 // Garbage collection for extensions. This will delete any directories in the | |
| 16 // installation directory of |extension_service_| that aren't valid, as well | |
| 17 // as removing any references in the preferences to extensions that are | |
| 18 // missing local content. | |
| 19 namespace extensions { | |
| 20 | |
| 21 class 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 } // namespace extensions | |
| 52 | |
| 53 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_GARBAGE_COLLECTOR_H_ | |
| OLD | NEW |