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 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 std::vector<uint8> pk_hash; | 71 std::vector<uint8> pk_hash; |
72 ComponentInstaller* installer; | 72 ComponentInstaller* installer; |
73 Version version; | 73 Version version; |
74 std::string fingerprint; | 74 std::string fingerprint; |
75 std::string name; | 75 std::string name; |
76 bool allow_background_download; | 76 bool allow_background_download; |
77 CrxComponent(); | 77 CrxComponent(); |
78 ~CrxComponent(); | 78 ~CrxComponent(); |
79 }; | 79 }; |
80 | 80 |
81 // Convenience structure to use with component listing / enumeration. | 81 struct CrxUpdateItem; |
82 struct CrxComponentInfo { | |
83 // |id| is currently derived from |CrxComponent.pk_hash|, see rest of the | |
84 // class implementation for details. | |
85 std::string id; | |
86 std::string version; | |
87 std::string name; | |
88 CrxComponentInfo(); | |
89 ~CrxComponentInfo(); | |
90 }; | |
91 | 82 |
92 // The component update service is in charge of installing or upgrading | 83 // The component update service is in charge of installing or upgrading |
93 // select parts of chrome. Each part is called a component and managed by | 84 // select parts of chrome. Each part is called a component and managed by |
94 // instances of CrxComponent registered using RegisterComponent(). On the | 85 // instances of CrxComponent registered using RegisterComponent(). On the |
95 // server, each component is packaged as a CRX which is the same format used | 86 // server, each component is packaged as a CRX which is the same format used |
96 // to package extensions. To the update service each component is identified | 87 // to package extensions. To the update service each component is identified |
97 // by its public key hash (CrxComponent::pk_hash). If there is an update | 88 // by its public key hash (CrxComponent::pk_hash). If there is an update |
98 // available and its version is bigger than (CrxComponent::version), it will | 89 // available and its version is bigger than (CrxComponent::version), it will |
99 // be downloaded, verified and unpacked. Then component-specific installer | 90 // be downloaded, verified and unpacked. Then component-specific installer |
100 // ComponentInstaller::Install (of CrxComponent::installer) will be called. | 91 // ComponentInstaller::Install (of CrxComponent::installer) will be called. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
198 virtual Status Start() = 0; | 189 virtual Status Start() = 0; |
199 | 190 |
200 // Stop doing update checks. In-flight requests and pending installations | 191 // Stop doing update checks. In-flight requests and pending installations |
201 // will not be canceled. | 192 // will not be canceled. |
202 virtual Status Stop() = 0; | 193 virtual Status Stop() = 0; |
203 | 194 |
204 // Add component to be checked for updates. You can call this method | 195 // Add component to be checked for updates. You can call this method |
205 // before calling Start(). | 196 // before calling Start(). |
206 virtual Status RegisterComponent(const CrxComponent& component) = 0; | 197 virtual Status RegisterComponent(const CrxComponent& component) = 0; |
207 | 198 |
208 // Returns a list of registered components. | |
209 virtual void GetComponents(std::vector<CrxComponentInfo>* components) = 0; | |
210 | |
211 // Returns a network resource throttle. It means that a component will be | 199 // Returns a network resource throttle. It means that a component will be |
212 // downloaded and installed before the resource is unthrottled. This is the | 200 // downloaded and installed before the resource is unthrottled. This is the |
213 // only function callable from the IO thread. | 201 // only function callable from the IO thread. |
214 virtual content::ResourceThrottle* GetOnDemandResourceThrottle( | 202 virtual content::ResourceThrottle* GetOnDemandResourceThrottle( |
215 net::URLRequest* request, | 203 net::URLRequest* request, |
216 const std::string& crx_id) = 0; | 204 const std::string& crx_id) = 0; |
217 | 205 |
218 virtual ~ComponentUpdateService() {} | 206 virtual ~ComponentUpdateService() {} |
219 | 207 |
220 friend class ::ComponentsUI; | 208 friend class ::ComponentsUI; |
221 friend class OnDemandTester; | 209 friend class OnDemandTester; |
222 | 210 |
223 private: | 211 private: |
212 // Returns a list of registered components. | |
213 virtual std::vector<std::string> GetComponentIDs() const = 0; | |
214 | |
215 // Returns details about registered component. | |
Sorin Jianu
2014/05/16 16:36:09
We need to add a comment here saying that the obje
Shrikant Kelkar
2014/05/16 18:58:56
Done.
| |
216 virtual CrxUpdateItem* GetComponentDetails( | |
217 const std::string& component_id) const = 0; | |
218 | |
224 // Ask the component updater to do an update check for a previously | 219 // Ask the component updater to do an update check for a previously |
225 // registered component, immediately. If an update or check is already | 220 // registered component, immediately. If an update or check is already |
226 // in progress, returns |kInProgress|. | 221 // in progress, returns |kInProgress|. |
227 // There is no guarantee that the item will actually be updated, | 222 // There is no guarantee that the item will actually be updated, |
228 // since an update may not be available. Listeners for the component will | 223 // since an update may not be available. Listeners for the component will |
229 // know the outcome of the check. | 224 // know the outcome of the check. |
230 virtual Status OnDemandUpdate(const std::string& component_id) = 0; | 225 virtual Status OnDemandUpdate(const std::string& component_id) = 0; |
231 }; | 226 }; |
232 | 227 |
233 typedef ComponentUpdateService::Observer ServiceObserver; | 228 typedef ComponentUpdateService::Observer ServiceObserver; |
234 | 229 |
235 // Creates the component updater. You must pass a valid |config| allocated on | 230 // Creates the component updater. You must pass a valid |config| allocated on |
236 // the heap which the component updater will own. | 231 // the heap which the component updater will own. |
237 ComponentUpdateService* ComponentUpdateServiceFactory( | 232 ComponentUpdateService* ComponentUpdateServiceFactory( |
238 ComponentUpdateService::Configurator* config); | 233 ComponentUpdateService::Configurator* config); |
239 | |
240 } // namespace component_updater | 234 } // namespace component_updater |
241 | 235 |
242 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 236 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
OLD | NEW |