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

Side by Side Diff: chrome/browser/extensions/extension_garbage_collector.h

Issue 216553012: Resubmit: Remove ExtensionService Garbage-Collecting methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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 unified diff | Download patch
OLDNEW
(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 // Manually trigger GarbageCollectExtensions() for testing.
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 // Garbage collects apps/extensions isolated storage, if it is not currently
52 // active (i.e. is not in ExtensionRegistry::ENABLED). There is an exception
53 // for ephemeral apps, because they can outlive their cache lifetimes.
54 void GarbageCollectIsolatedStorageIfNeeded();
55
56 // The ExtensionService which owns this GarbageCollector.
57 ExtensionService* extension_service_;
58
59 // The BrowserContext associated with the GarbageCollector, for convenience.
60 // (This is equivalent to extension_service_->GetBrowserContext().)
61 content::BrowserContext* context_;
62
63 // The root extensions installation directory.
64 base::FilePath install_directory_;
65
66 #if defined(OS_CHROMEOS)
67 // TODO(rkc): HACK alert - this is only in place to allow the
68 // kiosk_mode_screensaver to prevent its extension from getting garbage
69 // collected. Remove this once KioskModeScreensaver is removed.
70 // See crbug.com/280363
71 bool disable_garbage_collection_;
72 #endif
73
74 // Generate weak pointers for safely posting to the file thread for garbage
75 // collection.
76 base::WeakPtrFactory<ExtensionGarbageCollector> weak_factory_;
77
78 DISALLOW_COPY_AND_ASSIGN(ExtensionGarbageCollector);
79 };
80
81 } // namespace extensions
82
83 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_GARBAGE_COLLECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698