OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 | |
8 #include <map> | |
9 #include <string> | |
10 | |
11 #include "base/files/file_path.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 | |
14 namespace content { | |
15 class BrowserContext; | |
16 } | |
17 | |
18 class ExtensionService; | |
19 | |
20 namespace extensions { | |
21 | |
22 // The class responsible for cleaning up the cruft left behind on the file | |
23 // system by uninstalled (or failed install) extensions. | |
24 // The class is owned by ExtensionService, but is mostly independent. Tasks to | |
25 // garbage collect extensions and isolated storage are posted once the | |
26 // ExtensionSystem signals ready. | |
27 class ExtensionGarbageCollector { | |
28 public: | |
29 explicit ExtensionGarbageCollector(ExtensionService* extension_service); | |
30 ~ExtensionGarbageCollector(); | |
31 | |
32 #if defined(OS_CHROMEOS) | |
33 // Enable or disable garbage collection. See |disable_garbage_collection_|. | |
34 void disable_garbage_collection() { disable_garbage_collection_ = true; } | |
35 void enable_garbage_collection() { disable_garbage_collection_ = false; } | |
36 #endif | |
37 | |
38 // Call GarbageCollectExtensions(). Used only in tests. | |
Yoyo Zhou
2014/03/26 01:54:12
nit: this comment is redundant. Maybe say "manuall
Devlin
2014/03/26 23:56:32
Done.
| |
39 void GarbageCollectExtensionsForTest(); | |
40 | |
41 private: | |
42 // Cleans up the extension install directory. It can end up with garbage in it | |
43 // if extensions can't initially be removed when they are uninstalled (eg if a | |
44 // file is in use). | |
45 // Obsolete version directories are removed, as are directories that aren't | |
46 // found in the ExtensionPrefs. | |
47 // The "Temp" directory that is used during extension installation will get | |
48 // removed iff there are no pending installations. | |
49 void GarbageCollectExtensions(); | |
50 | |
51 // The FILE-thread implementation of GarbageCollectEtxensions(). | |
Yoyo Zhou
2014/03/26 01:54:12
typo
Devlin
2014/03/26 23:56:32
Done.
| |
52 void GarbageCollectExtensionsOnFileThread( | |
53 const std::multimap<std::string, base::FilePath>& extension_paths, | |
54 bool clean_temp_dir); | |
55 | |
56 // Garbage collects apps/extensions isolated storage, if it is not currently | |
57 // active (i.e. is not in ExtensionRegistry::ENABLED or does not have | |
Yoyo Zhou
2014/03/26 01:54:12
I'm confused by the "does not have isolated storag
Devlin
2014/03/26 23:56:32
Ah, yes, my parentheses were off. Presumably, tha
| |
58 // isolated storage). There is an exception for ephemeral apps, because they | |
59 // can outlive their cache lifetimes. | |
60 void GarbageCollectIsolatedStorageIfNeeded(); | |
61 | |
62 // The ExtensionService which owns this GarbageCollector. | |
63 ExtensionService* extension_service_; | |
64 | |
65 // The BrowserContext associated with the GarbageCollector, for convenience. | |
66 // (This is equivalent to extension_service_->GetBrowserContext().) | |
67 content::BrowserContext* context_; | |
68 | |
69 // The root extensions installation directory. | |
70 base::FilePath install_directory_; | |
71 | |
72 #if defined(OS_CHROMEOS) | |
73 // TODO(rkc): HACK alert - this is only in place to allow the | |
74 // kiosk_mode_screensaver to prevent its extension from getting garbage | |
75 // collected. Remove this once KioskModeScreensaver is removed. | |
76 // See crbug.com/280363 | |
77 bool disable_garbage_collection_; | |
78 #endif | |
79 | |
80 // Generate weak pointers for safely posting to the file thread for garbage | |
81 // collection. | |
82 base::WeakPtrFactory<ExtensionGarbageCollector> weak_factory_; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(ExtensionGarbageCollector); | |
85 }; | |
86 | |
87 } // namespace extensions | |
88 | |
89 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_GARBAGE_COLLECTOR_H_ | |
OLD | NEW |