OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
| 11 #include "base/callback.h" |
11 #include "base/version.h" | 12 #include "base/version.h" |
12 #include "url/gurl.h" | 13 #include "url/gurl.h" |
13 | 14 |
14 class ComponentsUI; | 15 class ComponentsUI; |
15 | 16 |
16 namespace base { | 17 namespace base { |
17 class DictionaryValue; | 18 class DictionaryValue; |
18 class FilePath; | 19 class FilePath; |
19 } | 20 } |
20 | 21 |
21 namespace net { | 22 namespace net { |
22 class URLRequestContextGetter; | 23 class URLRequestContextGetter; |
23 class URLRequest; | 24 class URLRequest; |
24 } | 25 } |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 class ResourceThrottle; | 28 class ResourceThrottle; |
28 } | 29 } |
29 | 30 |
30 namespace component_updater { | 31 namespace component_updater { |
31 | 32 |
32 class OnDemandUpdater; | 33 class OnDemandUpdater; |
33 | 34 |
| 35 typedef base::Callback<bool(const base::FilePath&)> InstallerSourceSerializer; |
| 36 |
34 // Component specific installers must derive from this class and implement | 37 // Component specific installers must derive from this class and implement |
35 // OnUpdateError() and Install(). A valid instance of this class must be | 38 // OnUpdateError() and Install(). A valid instance of this class must be |
36 // given to ComponentUpdateService::RegisterComponent(). | 39 // given to ComponentUpdateService::RegisterComponent(). |
37 class ComponentInstaller { | 40 class ComponentInstaller { |
38 public: | 41 public: |
39 // Called by the component updater on the UI thread when there was a | 42 // Called by the component updater on the UI thread when there was a |
40 // problem unpacking or verifying the component. |error| is a non-zero | 43 // problem unpacking or verifying the component. |error| is a non-zero |
41 // value which is only meaningful to the component updater. | 44 // value which is only meaningful to the component updater. |
42 virtual void OnUpdateError(int error) = 0; | 45 virtual void OnUpdateError(int error) = 0; |
43 | 46 |
44 // Called by the component updater when a component has been unpacked | 47 // Called by the component updater when a component has been unpacked |
45 // and is ready to be installed. |manifest| contains the CRX manifest | 48 // and is ready to be installed. |manifest| contains the CRX manifest |
46 // json dictionary and |unpack_path| contains the temporary directory | 49 // json dictionary and |unpack_path| contains the temporary directory |
47 // with all the unpacked CRX files. | 50 // with all the unpacked CRX files. |
48 virtual bool Install(const base::DictionaryValue& manifest, | 51 virtual bool Install(const base::DictionaryValue& manifest, |
49 const base::FilePath& unpack_path) = 0; | 52 const base::FilePath& unpack_path) = 0; |
50 | 53 |
| 54 // Called by the component updater if Install() retuns false. This gives |
| 55 // installer a chance to handle install failure. |serializer| knows how to |
| 56 // save installer source information to the given path for retry later. |
| 57 virtual void OnInstallError(const InstallerSourceSerializer& serializer) = 0; |
| 58 |
51 // Set |installed_file| to the full path to the installed |file|. |file| is | 59 // Set |installed_file| to the full path to the installed |file|. |file| is |
52 // the filename of the file in this component's CRX. Returns false if this is | 60 // the filename of the file in this component's CRX. Returns false if this is |
53 // not possible (the file has been removed or modified, or its current | 61 // not possible (the file has been removed or modified, or its current |
54 // location is unknown). Otherwise, returns true. | 62 // location is unknown). Otherwise, returns true. |
55 virtual bool GetInstalledFile(const std::string& file, | 63 virtual bool GetInstalledFile(const std::string& file, |
56 base::FilePath* installed_file) = 0; | 64 base::FilePath* installed_file) = 0; |
57 | 65 |
58 virtual ~ComponentInstaller() {} | 66 virtual ~ComponentInstaller() {} |
59 }; | 67 }; |
60 | 68 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 const std::string& component_id) = 0; | 250 const std::string& component_id) = 0; |
243 }; | 251 }; |
244 | 252 |
245 // Creates the component updater. You must pass a valid |config| allocated on | 253 // Creates the component updater. You must pass a valid |config| allocated on |
246 // the heap which the component updater will own. | 254 // the heap which the component updater will own. |
247 ComponentUpdateService* ComponentUpdateServiceFactory( | 255 ComponentUpdateService* ComponentUpdateServiceFactory( |
248 ComponentUpdateService::Configurator* config); | 256 ComponentUpdateService::Configurator* config); |
249 } // namespace component_updater | 257 } // namespace component_updater |
250 | 258 |
251 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 259 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
OLD | NEW |