OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/version.h" | 11 #include "base/version.h" |
12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 class URLRequestContextGetter; | 15 class URLRequestContextGetter; |
16 } | 16 } |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class DictionaryValue; | 19 class DictionaryValue; |
20 class FilePath; | 20 class FilePath; |
21 } | 21 } |
22 | 22 |
| 23 class ComponentPatcher; |
| 24 |
23 // Component specific installers must derive from this class and implement | 25 // Component specific installers must derive from this class and implement |
24 // OnUpdateError() and Install(). A valid instance of this class must be | 26 // OnUpdateError() and Install(). A valid instance of this class must be |
25 // given to ComponentUpdateService::RegisterComponent(). | 27 // given to ComponentUpdateService::RegisterComponent(). |
26 class ComponentInstaller { | 28 class ComponentInstaller { |
27 public : | 29 public : |
28 // Called by the component updater on the UI thread when there was a | 30 // Called by the component updater on the UI thread when there was a |
29 // problem unpacking or verifying the component. |error| is a non-zero | 31 // problem unpacking or verifying the component. |error| is a non-zero |
30 // value which is only meaningful to the component updater. | 32 // value which is only meaningful to the component updater. |
31 virtual void OnUpdateError(int error) = 0; | 33 virtual void OnUpdateError(int error) = 0; |
32 | 34 |
33 // Called by the component updater when a component has been unpacked | 35 // Called by the component updater when a component has been unpacked |
34 // and is ready to be installed. |manifest| contains the CRX manifest | 36 // and is ready to be installed. |manifest| contains the CRX manifest |
35 // json dictionary and |unpack_path| contains the temporary directory | 37 // json dictionary and |unpack_path| contains the temporary directory |
36 // with all the unpacked CRX files. | 38 // with all the unpacked CRX files. |
37 virtual bool Install(const base::DictionaryValue& manifest, | 39 virtual bool Install(const base::DictionaryValue& manifest, |
38 const base::FilePath& unpack_path) = 0; | 40 const base::FilePath& unpack_path) = 0; |
39 | 41 |
| 42 // Set |installed_file| to the full path to the installed |file|. |file| is |
| 43 // the filename of the file in this component's CRX. Returns false if this is |
| 44 // not possible (the file has been removed or modified, or its current |
| 45 // location is unknown). Otherwise, returns true. |
| 46 virtual bool GetInstalledFile(const std::string& file, |
| 47 base::FilePath* installed_file) = 0; |
| 48 |
40 protected: | 49 protected: |
41 virtual ~ComponentInstaller() {} | 50 virtual ~ComponentInstaller() {} |
42 }; | 51 }; |
43 | 52 |
44 // Describes a particular component that can be installed or updated. This | 53 // Describes a particular component that can be installed or updated. This |
45 // structure is required to register a component with the component updater. | 54 // structure is required to register a component with the component updater. |
46 // Only |name| is optional. |pk_hash| is the SHA256 hash of the component's | 55 // |pk_hash| is the SHA256 hash of the component's public key. If the component |
47 // public key. If the component is to be installed then version should be | 56 // is to be installed then version should be "0" or "0.0", else it should be |
48 // "0" or "0.0", else it should be the current version. | 57 // the current version. |fingerprint| and |name| are optional. |
49 // |source| is by default pointing to BANDAID but if needed it can be made | 58 // |source| is by default pointing to BANDAID but if needed it can be made |
50 // to point to the webstore (CWS_PUBLIC) or to the webstore sandbox. It is | 59 // to point to the webstore (CWS_PUBLIC) or to the webstore sandbox. It is |
51 // important to note that the BANDAID source if active throught the day | 60 // important to note that the BANDAID source if active throught the day |
52 // can pre-empt updates from the other sources down the list. | 61 // can pre-empt updates from the other sources down the list. |
53 struct CrxComponent { | 62 struct CrxComponent { |
54 // Specifies the source url for manifest check. | 63 // Specifies the source url for manifest check. |
55 enum UrlSource { | 64 enum UrlSource { |
56 BANDAID, | 65 BANDAID, |
57 CWS_PUBLIC, | 66 CWS_PUBLIC, |
58 CWS_SANDBOX | 67 CWS_SANDBOX, |
59 }; | 68 }; |
60 | 69 |
61 std::vector<uint8> pk_hash; | 70 std::vector<uint8> pk_hash; |
62 ComponentInstaller* installer; | 71 ComponentInstaller* installer; |
63 Version version; | 72 Version version; |
| 73 std::string fingerprint; |
64 std::string name; | 74 std::string name; |
65 UrlSource source; | 75 UrlSource source; |
66 CrxComponent(); | 76 CrxComponent(); |
67 ~CrxComponent(); | 77 ~CrxComponent(); |
68 }; | 78 }; |
69 | 79 |
70 // The component update service is in charge of installing or upgrading | 80 // The component update service is in charge of installing or upgrading |
71 // select parts of chrome. Each part is called a component and managed by | 81 // select parts of chrome. Each part is called a component and managed by |
72 // instances of CrxComponent registered using RegisterComponent(). On the | 82 // instances of CrxComponent registered using RegisterComponent(). On the |
73 // server, each component is packaged as a CRX which is the same format used | 83 // server, each component is packaged as a CRX which is the same format used |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // How big each update request can be. Don't go above 2000. | 131 // How big each update request can be. Don't go above 2000. |
122 virtual size_t UrlSizeLimit() = 0; | 132 virtual size_t UrlSizeLimit() = 0; |
123 // The source of contexts for all the url requests. | 133 // The source of contexts for all the url requests. |
124 virtual net::URLRequestContextGetter* RequestContext() = 0; | 134 virtual net::URLRequestContextGetter* RequestContext() = 0; |
125 // True means that all ops are performed in this process. | 135 // True means that all ops are performed in this process. |
126 virtual bool InProcess() = 0; | 136 virtual bool InProcess() = 0; |
127 // The component updater will call this function when an interesting event | 137 // The component updater will call this function when an interesting event |
128 // happens. It should be used mostly as a place to add application specific | 138 // happens. It should be used mostly as a place to add application specific |
129 // logging or telemetry. |extra| is |event| dependent. | 139 // logging or telemetry. |extra| is |event| dependent. |
130 virtual void OnEvent(Events event, int extra) = 0; | 140 virtual void OnEvent(Events event, int extra) = 0; |
| 141 // Creates a new ComponentPatcher in a platform-specific way. This is useful |
| 142 // for dependency injection. |
| 143 virtual ComponentPatcher* CreateComponentPatcher() = 0; |
| 144 // True means that this client can handle delta updates. |
| 145 virtual bool DeltasEnabled() const = 0; |
131 }; | 146 }; |
132 | 147 |
133 // Start doing update checks and installing new versions of registered | 148 // Start doing update checks and installing new versions of registered |
134 // components after Configurator::InitialDelay() seconds. | 149 // components after Configurator::InitialDelay() seconds. |
135 virtual Status Start() = 0; | 150 virtual Status Start() = 0; |
136 | 151 |
137 // Stop doing update checks. In-flight requests and pending installations | 152 // Stop doing update checks. In-flight requests and pending installations |
138 // will not be canceled. | 153 // will not be canceled. |
139 virtual Status Stop() = 0; | 154 virtual Status Stop() = 0; |
140 | 155 |
(...skipping 14 matching lines...) Expand all Loading... |
155 | 170 |
156 virtual ~ComponentUpdateService() {} | 171 virtual ~ComponentUpdateService() {} |
157 }; | 172 }; |
158 | 173 |
159 // Creates the component updater. You must pass a valid |config| allocated on | 174 // Creates the component updater. You must pass a valid |config| allocated on |
160 // the heap which the component updater will own. | 175 // the heap which the component updater will own. |
161 ComponentUpdateService* ComponentUpdateServiceFactory( | 176 ComponentUpdateService* ComponentUpdateServiceFactory( |
162 ComponentUpdateService::Configurator* config); | 177 ComponentUpdateService::Configurator* config); |
163 | 178 |
164 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 179 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
OLD | NEW |