| 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 // Only |name| is optional. |pk_hash| is the SHA256 hash of the component's |
| 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. |
| 130 virtual GURL PingUrl() = 0; |
| 119 // Parameters added to each url request. It can be null if none are needed. | 131 // Parameters added to each url request. It can be null if none are needed. |
| 120 virtual const char* ExtraRequestParams() = 0; | 132 virtual const char* ExtraRequestParams() = 0; |
| 121 // How big each update request can be. Don't go above 2000. | 133 // How big each update request can be. Don't go above 2000. |
| 122 virtual size_t UrlSizeLimit() = 0; | 134 virtual size_t UrlSizeLimit() = 0; |
| 123 // The source of contexts for all the url requests. | 135 // The source of contexts for all the url requests. |
| 124 virtual net::URLRequestContextGetter* RequestContext() = 0; | 136 virtual net::URLRequestContextGetter* RequestContext() = 0; |
| 125 // True means that all ops are performed in this process. | 137 // True means that all ops are performed in this process. |
| 126 virtual bool InProcess() = 0; | 138 virtual bool InProcess() = 0; |
| 127 // The component updater will call this function when an interesting event | 139 // 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 | 140 // happens. It should be used mostly as a place to add application specific |
| 129 // logging or telemetry. |extra| is |event| dependent. | 141 // logging or telemetry. |extra| is |event| dependent. |
| 130 virtual void OnEvent(Events event, int extra) = 0; | 142 virtual void OnEvent(Events event, int extra) = 0; |
| 143 // Creates a new ComponentPatcher in a platform-specific way. This is useful |
| 144 // for dependency injection. |
| 145 virtual ComponentPatcher* CreateComponentPatcher() = 0; |
| 146 // True means that this client can handle delta updates. |
| 147 virtual bool DeltasEnabled() const = 0; |
| 148 // True means this client is allowed to send component update status pings. |
| 149 virtual bool PingsEnabled() const = 0; |
| 131 }; | 150 }; |
| 132 | 151 |
| 133 // Start doing update checks and installing new versions of registered | 152 // Start doing update checks and installing new versions of registered |
| 134 // components after Configurator::InitialDelay() seconds. | 153 // components after Configurator::InitialDelay() seconds. |
| 135 virtual Status Start() = 0; | 154 virtual Status Start() = 0; |
| 136 | 155 |
| 137 // Stop doing update checks. In-flight requests and pending installations | 156 // Stop doing update checks. In-flight requests and pending installations |
| 138 // will not be canceled. | 157 // will not be canceled. |
| 139 virtual Status Stop() = 0; | 158 virtual Status Stop() = 0; |
| 140 | 159 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 155 | 174 |
| 156 virtual ~ComponentUpdateService() {} | 175 virtual ~ComponentUpdateService() {} |
| 157 }; | 176 }; |
| 158 | 177 |
| 159 // Creates the component updater. You must pass a valid |config| allocated on | 178 // Creates the component updater. You must pass a valid |config| allocated on |
| 160 // the heap which the component updater will own. | 179 // the heap which the component updater will own. |
| 161 ComponentUpdateService* ComponentUpdateServiceFactory( | 180 ComponentUpdateService* ComponentUpdateServiceFactory( |
| 162 ComponentUpdateService::Configurator* config); | 181 ComponentUpdateService::Configurator* config); |
| 163 | 182 |
| 164 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 183 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
| OLD | NEW |