Rename frame classes
[chromium-blink-merge.git] / extensions / browser / updater / extension_cache.h
blobc576ae60c061ceaab809ef992e0e1dd63100abe2
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.
5 #ifndef EXTENSIONS_BROWSER_UPDATER_EXTENSION_CACHE_H_
6 #define EXTENSIONS_BROWSER_UPDATER_EXTENSION_CACHE_H_
8 #include <string>
10 #include "base/callback_forward.h"
11 #include "base/files/file_path.h"
13 namespace extensions {
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 // Callback that is invoked when the file placed when PutExtension done.
20 typedef base::Callback<void(const base::FilePath& file_path,
21 bool file_ownership_passed)> PutExtensionCallback;
23 ExtensionCache() {}
24 virtual ~ExtensionCache() {}
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;
31 // Shut down the cache. Must be called at most once on browser shutdown.
32 virtual void Shutdown(const base::Closure& callback) = 0;
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;
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 const std::string& expected_hash,
44 base::FilePath* file_path,
45 std::string* version) = 0;
47 // Put extension with |id| and |version| into local cache. Older version in
48 // the cache will removed be on next run so it can be safely used. Extension
49 // will be marked as used with current timestamp. The file will be available
50 // via GetExtension when |callback| is called. Original |file_path| won't be
51 // deleted from the disk. There is no guarantee that |callback| will be
52 // called.
53 virtual void PutExtension(const std::string& id,
54 const std::string& expected_hash,
55 const base::FilePath& file_path,
56 const std::string& version,
57 const PutExtensionCallback& callback) = 0;
59 private:
60 DISALLOW_COPY_AND_ASSIGN(ExtensionCache);
63 } // namespace extensions
65 #endif // EXTENSIONS_BROWSER_UPDATER_EXTENSION_CACHE_H_