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

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

Issue 204983020: Remove ExtensionService Garbage-Collecting methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove lazy global empty delta 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 // The FILE-thread implementation of GarbageCollectExtensions().
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). There is an exception
58 // for ephemeral apps, because they can outlive their cache lifetimes.
59 void GarbageCollectIsolatedStorageIfNeeded();
60
61 // The ExtensionService which owns this GarbageCollector.
62 ExtensionService* extension_service_;
63
64 // The BrowserContext associated with the GarbageCollector, for convenience.
65 // (This is equivalent to extension_service_->GetBrowserContext().)
66 content::BrowserContext* context_;
67
68 // The root extensions installation directory.
69 base::FilePath install_directory_;
70
71 #if defined(OS_CHROMEOS)
72 // TODO(rkc): HACK alert - this is only in place to allow the
73 // kiosk_mode_screensaver to prevent its extension from getting garbage
74 // collected. Remove this once KioskModeScreensaver is removed.
75 // See crbug.com/280363
76 bool disable_garbage_collection_;
77 #endif
78
79 // Generate weak pointers for safely posting to the file thread for garbage
80 // collection.
81 base::WeakPtrFactory<ExtensionGarbageCollector> weak_factory_;
82
83 DISALLOW_COPY_AND_ASSIGN(ExtensionGarbageCollector);
84 };
85
86 } // namespace extensions
87
88 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_GARBAGE_COLLECTOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.cc ('k') | chrome/browser/extensions/extension_garbage_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698