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

Side by Side Diff: chrome/browser/extensions/updater/extension_cache.h

Issue 612423003: Move ExtensionCache to //extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test setup Created 6 years, 2 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_UPDATER_EXTENSION_CACHE_H_
6 #define CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_CACHE_H_
7
8 #include <string>
9
10 #include "base/callback_forward.h"
11 #include "base/files/file_path.h"
12
13 namespace extensions {
14
15 // ExtensionCache interface that caches extensions .crx files to share them
16 // between multiple users and profiles on the machine.
17 class ExtensionCache {
18 public:
19 // Return global singleton instance of ExtensionCache.
20 static ExtensionCache* GetInstance();
21
22 // Callback that is invoked when the file placed when PutExtension done.
23 typedef base::Callback<void(const base::FilePath& file_path,
24 bool file_ownership_passed)> PutExtensionCallback;
25
26 // Initialize cache in background. The |callback| is called when cache ready.
27 // Can be called multiple times. The |callback| can be called immediately if
28 // cache is ready.
29 virtual void Start(const base::Closure& callback) = 0;
30
31 // Shut down the cache. Must be called at most once on browser shutdown.
32 virtual void Shutdown(const base::Closure& callback) = 0;
33
34 // Allow caching for the extension with given |id|. User specific extensions
35 // should not be cached for privacy reasons. But default apps including policy
36 // configured can be cached. Can be called before Init.
37 virtual void AllowCaching(const std::string& id) = 0;
38
39 // If extension with |id| exists in the cache, returns |true|, |file_path| and
40 // |version| for the extension. Extension will be marked as used with current
41 // timestamp.
42 virtual bool GetExtension(const std::string& id,
43 base::FilePath* file_path,
44 std::string* version) = 0;
45
46 // Put extension with |id| and |version| into local cache. Older version in
47 // the cache will removed be on next run so it can be safely used. Extension
48 // will be marked as used with current timestamp. The file will be available
49 // via GetExtension when |callback| is called. Original |file_path| won't be
50 // deleted from the disk. There is no guarantee that |callback| will be
51 // called.
52 virtual void PutExtension(const std::string& id,
53 const base::FilePath& file_path,
54 const std::string& version,
55 const PutExtensionCallback& callback) = 0;
56
57 protected:
58 virtual ~ExtensionCache() {}
59
60 // Sets the singleton to the given |cache|. Returns the previous value of
61 // the singleton. Ownership is not transferred.
62 static ExtensionCache* SetForTesting(ExtensionCache* cache);
63 };
64
65 } // namespace extensions
66
67 #endif // CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_CACHE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_provider_impl_unittest.cc ('k') | chrome/browser/extensions/updater/extension_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698