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 | |
cpu_(ooo_6.6-7.5)
2013/06/18 17:02:06
I was expecting as input the version, but I guess
Sorin Jianu
2013/06/18 20:46:39
Done.
| |
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 // Only |name| is optional. |pk_hash| is the SHA256 hash of the component's |
cpu_(ooo_6.6-7.5)
2013/06/18 17:02:06
"only name is optional"
Sorin Jianu
2013/06/18 20:46:39
I am sorry I don't understand the comment.
cpu_(ooo_6.6-7.5)
2013/06/18 22:07:34
If fingerprint optional? if so then comment needs
Sorin Jianu
2013/06/19 00:29:10
Done.
| |
47 // public key. If the component is to be installed then version should be | 56 // public key. If the component is to be installed then version should be |
48 // "0" or "0.0", else it should be the current version. | 57 // "0" or "0.0", else it should be the current version. |
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 virtual int NextCheckDelay() = 0; | 119 virtual int NextCheckDelay() = 0; |
110 // Delay in seconds from each task step. Used to smooth out CPU/IO usage. | 120 // Delay in seconds from each task step. Used to smooth out CPU/IO usage. |
111 virtual int StepDelay() = 0; | 121 virtual int StepDelay() = 0; |
112 // Minimum delta time in seconds before checking again the same component. | 122 // Minimum delta time in seconds before checking again the same component. |
113 virtual int MinimumReCheckWait() = 0; | 123 virtual int MinimumReCheckWait() = 0; |
114 // Minimum delta time in seconds before an on-demand check is allowed | 124 // Minimum delta time in seconds before an on-demand check is allowed |
115 // for the same component. | 125 // for the same component. |
116 virtual int OnDemandDelay() = 0; | 126 virtual int OnDemandDelay() = 0; |
117 // The url that is going to be used update checks over Omaha protocol. | 127 // The url that is going to be used update checks over Omaha protocol. |
118 virtual GURL UpdateUrl(CrxComponent::UrlSource source) = 0; | 128 virtual GURL UpdateUrl(CrxComponent::UrlSource source) = 0; |
129 // The url where the completion pings are sent. Invalid if and only if | |
130 // pings are disabled. | |
131 virtual GURL PingUrl() = 0; | |
119 // Parameters added to each url request. It can be null if none are needed. | 132 // Parameters added to each url request. It can be null if none are needed. |
120 virtual const char* ExtraRequestParams() = 0; | 133 virtual const char* ExtraRequestParams() = 0; |
121 // How big each update request can be. Don't go above 2000. | 134 // How big each update request can be. Don't go above 2000. |
122 virtual size_t UrlSizeLimit() = 0; | 135 virtual size_t UrlSizeLimit() = 0; |
123 // The source of contexts for all the url requests. | 136 // The source of contexts for all the url requests. |
124 virtual net::URLRequestContextGetter* RequestContext() = 0; | 137 virtual net::URLRequestContextGetter* RequestContext() = 0; |
125 // True means that all ops are performed in this process. | 138 // True means that all ops are performed in this process. |
126 virtual bool InProcess() = 0; | 139 virtual bool InProcess() = 0; |
127 // The component updater will call this function when an interesting event | 140 // 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 | 141 // happens. It should be used mostly as a place to add application specific |
129 // logging or telemetry. |extra| is |event| dependent. | 142 // logging or telemetry. |extra| is |event| dependent. |
130 virtual void OnEvent(Events event, int extra) = 0; | 143 virtual void OnEvent(Events event, int extra) = 0; |
144 // Creates a new ComponentPatcher in a platform-specific way. This is useful | |
145 // for dependency injection. | |
146 virtual ComponentPatcher* CreateComponentPatcher() = 0; | |
147 // True means that this client can handle delta updates. | |
148 virtual bool DeltasEnabled() const = 0; | |
131 }; | 149 }; |
132 | 150 |
133 // Start doing update checks and installing new versions of registered | 151 // Start doing update checks and installing new versions of registered |
134 // components after Configurator::InitialDelay() seconds. | 152 // components after Configurator::InitialDelay() seconds. |
135 virtual Status Start() = 0; | 153 virtual Status Start() = 0; |
136 | 154 |
137 // Stop doing update checks. In-flight requests and pending installations | 155 // Stop doing update checks. In-flight requests and pending installations |
138 // will not be canceled. | 156 // will not be canceled. |
139 virtual Status Stop() = 0; | 157 virtual Status Stop() = 0; |
140 | 158 |
(...skipping 14 matching lines...) Expand all Loading... | |
155 | 173 |
156 virtual ~ComponentUpdateService() {} | 174 virtual ~ComponentUpdateService() {} |
157 }; | 175 }; |
158 | 176 |
159 // Creates the component updater. You must pass a valid |config| allocated on | 177 // Creates the component updater. You must pass a valid |config| allocated on |
160 // the heap which the component updater will own. | 178 // the heap which the component updater will own. |
161 ComponentUpdateService* ComponentUpdateServiceFactory( | 179 ComponentUpdateService* ComponentUpdateServiceFactory( |
162 ComponentUpdateService::Configurator* config); | 180 ComponentUpdateService::Configurator* config); |
163 | 181 |
164 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 182 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
OLD | NEW |