OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_CACHE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_CACHE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_CACHE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_CACHE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 const GURL& download_url, | 96 const GURL& download_url, |
97 const std::string& version, | 97 const std::string& version, |
98 const PingResult& ping_result, | 98 const PingResult& ping_result, |
99 const std::set<int>& request_ids) OVERRIDE; | 99 const std::set<int>& request_ids) OVERRIDE; |
100 | 100 |
101 virtual bool IsExtensionPending(const std::string& id) OVERRIDE; | 101 virtual bool IsExtensionPending(const std::string& id) OVERRIDE; |
102 | 102 |
103 virtual bool GetExtensionExistingVersion(const std::string& id, | 103 virtual bool GetExtensionExistingVersion(const std::string& id, |
104 std::string* version) OVERRIDE; | 104 std::string* version) OVERRIDE; |
105 | 105 |
106 // Returns true if the extension with |id| is pending for update check. | |
107 bool IsExtensionPendingForUpdateCheck(const std::string& id); | |
xiyuan
2014/05/29 19:49:01
Move this under IsExtensionPending so that it has
jennyz
2014/07/07 21:11:12
Since this one is not virtual, so I won't put it u
| |
108 | |
106 // Shut down the cache. The |callback| will be invoked when the cache has shut | 109 // Shut down the cache. The |callback| will be invoked when the cache has shut |
107 // down completely and there are no more pending file I/O operations. | 110 // down completely and there are no more pending file I/O operations. |
108 void Shutdown(const base::Closure& callback); | 111 void Shutdown(const base::Closure& callback); |
109 | 112 |
110 // Replace the list of extensions to cache with |prefs| and perform update | 113 // Replace the list of extensions to cache with |prefs| and perform update |
111 // checks for these. | 114 // checks for these. |
112 void UpdateExtensionsList(scoped_ptr<base::DictionaryValue> prefs); | 115 void UpdateExtensionsList(scoped_ptr<base::DictionaryValue> prefs); |
113 | 116 |
114 // If a user of one of the ExternalCache's extensions detects that | 117 // If a user of one of the ExternalCache's extensions detects that |
115 // the extension is damaged then this method can be used to remove it from | 118 // the extension is damaged then this method can be used to remove it from |
116 // the cache and retry to download it after a restart. | 119 // the cache and retry to download it after a restart. |
117 void OnDamagedFileDetected(const base::FilePath& path); | 120 void OnDamagedFileDetected(const base::FilePath& path); |
118 | 121 |
119 // Removes extensions listed in |ids| from external cache, corresponding crx | 122 // Removes extensions listed in |ids| from external cache, corresponding crx |
120 // files will be removed from disk too. | 123 // files will be removed from disk too. |
121 void RemoveExtensions(const std::vector<std::string>& ids); | 124 void RemoveExtensions(const std::vector<std::string>& ids); |
122 | 125 |
123 // If extension with |id| exists in the cache, returns |true|, |file_path| and | 126 // If extension with |id| exists in the cache, returns |true|, |file_path| and |
124 // |version| for the extension. Extension will be marked as used with current | 127 // |version| for the extension. Extension will be marked as used with current |
125 // timestamp. | 128 // timestamp. |
126 bool GetExtension(const std::string& id, | 129 bool GetExtension(const std::string& id, |
127 base::FilePath* file_path, | 130 base::FilePath* file_path, |
128 std::string* version); | 131 std::string* version); |
129 | 132 |
130 private: | 133 private: |
134 enum ExtensionStatus { | |
135 DOWNLOAD_PENDING, | |
136 DOWNLOAD_SUCCEEDED, | |
137 DOWNLOAD_FAILED, | |
138 }; | |
139 | |
131 // Notifies the that the cache has been updated, providing | 140 // Notifies the that the cache has been updated, providing |
132 // extensions loader with an updated list of extensions. | 141 // extensions loader with an updated list of extensions. |
133 void UpdateExtensionLoader(); | 142 void UpdateExtensionLoader(); |
134 | 143 |
135 // Checks the cache contents and initiate download if needed. | 144 // Checks the cache contents and initiate download if needed. |
136 void CheckCache(); | 145 void CheckCache(); |
137 | 146 |
138 // Invoked on the UI thread when a new entry has been installed in the cache. | 147 // Invoked on the UI thread when a new entry has been installed in the cache. |
139 void OnPutExtension(const std::string& id, | 148 void OnPutExtension(const std::string& id, |
140 const base::FilePath& file_path, | 149 const base::FilePath& file_path, |
(...skipping 16 matching lines...) Expand all Loading... | |
157 // Set to true if cache should wait for initialization flag file. | 166 // Set to true if cache should wait for initialization flag file. |
158 bool wait_for_cache_initialization_; | 167 bool wait_for_cache_initialization_; |
159 | 168 |
160 // This is the list of extensions currently configured. | 169 // This is the list of extensions currently configured. |
161 scoped_ptr<base::DictionaryValue> extensions_; | 170 scoped_ptr<base::DictionaryValue> extensions_; |
162 | 171 |
163 // This contains extensions that are both currently configured | 172 // This contains extensions that are both currently configured |
164 // and that have a valid crx in the cache. | 173 // and that have a valid crx in the cache. |
165 scoped_ptr<base::DictionaryValue> cached_extensions_; | 174 scoped_ptr<base::DictionaryValue> cached_extensions_; |
166 | 175 |
176 // <extension_id : status>: used for tracking extension download status. | |
177 std::map<std::string, ExtensionStatus> extensions_status_; | |
178 | |
167 // Used to download the extensions and to check for updates. | 179 // Used to download the extensions and to check for updates. |
168 scoped_ptr<extensions::ExtensionDownloader> downloader_; | 180 scoped_ptr<extensions::ExtensionDownloader> downloader_; |
169 | 181 |
170 // Observes failures to install CRX files. | 182 // Observes failures to install CRX files. |
171 content::NotificationRegistrar notification_registrar_; | 183 content::NotificationRegistrar notification_registrar_; |
172 | 184 |
173 // Weak factory for callbacks. | 185 // Weak factory for callbacks. |
174 base::WeakPtrFactory<ExternalCache> weak_ptr_factory_; | 186 base::WeakPtrFactory<ExternalCache> weak_ptr_factory_; |
175 | 187 |
176 DISALLOW_COPY_AND_ASSIGN(ExternalCache); | 188 DISALLOW_COPY_AND_ASSIGN(ExternalCache); |
177 }; | 189 }; |
178 | 190 |
179 } // namespace chromeos | 191 } // namespace chromeos |
180 | 192 |
181 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_CACHE_H_ | 193 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_CACHE_H_ |
OLD | NEW |