Chromium Code Reviews| 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 "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 | 13 |
| 14 namespace net { | |
| 15 class URLRequestContextGetter; | |
| 16 } | |
| 17 | |
| 18 namespace base { | 14 namespace base { |
| 19 class DictionaryValue; | 15 class DictionaryValue; |
| 20 class FilePath; | 16 class FilePath; |
| 21 } | 17 } |
| 22 | 18 |
| 19 namespace component_updater { | |
| 20 class ComponentUpdaterServiceObserver; | |
| 21 } | |
| 22 | |
| 23 namespace net { | |
| 24 class URLRequestContextGetter; | |
| 25 } | |
| 26 | |
| 23 class ComponentPatcher; | 27 class ComponentPatcher; |
| 24 | 28 |
| 25 // Component specific installers must derive from this class and implement | 29 // Component specific installers must derive from this class and implement |
| 26 // OnUpdateError() and Install(). A valid instance of this class must be | 30 // OnUpdateError() and Install(). A valid instance of this class must be |
| 27 // given to ComponentUpdateService::RegisterComponent(). | 31 // given to ComponentUpdateService::RegisterComponent(). |
| 28 class ComponentInstaller { | 32 class ComponentInstaller { |
| 29 public : | 33 public : |
| 30 // Called by the component updater on the UI thread when there was a | 34 // Called by the component updater on the UI thread when there was a |
| 31 // problem unpacking or verifying the component. |error| is a non-zero | 35 // problem unpacking or verifying the component. |error| is a non-zero |
| 32 // value which is only meaningful to the component updater. | 36 // value which is only meaningful to the component updater. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 public: | 88 public: |
| 85 enum Status { | 89 enum Status { |
| 86 kOk, | 90 kOk, |
| 87 kReplaced, | 91 kReplaced, |
| 88 kInProgress, | 92 kInProgress, |
| 89 kError | 93 kError |
| 90 }; | 94 }; |
| 91 // Controls the component updater behavior. | 95 // Controls the component updater behavior. |
| 92 class Configurator { | 96 class Configurator { |
| 93 public: | 97 public: |
| 94 enum Events { | |
| 95 kManifestCheck, | |
| 96 kComponentUpdated, | |
| 97 kManifestError, | |
| 98 kNetworkError, | |
| 99 kUnpackError, | |
| 100 kInstallerError | |
| 101 }; | |
| 102 | |
| 103 virtual ~Configurator() {} | 98 virtual ~Configurator() {} |
| 99 virtual void Init(ComponentUpdateService* cus) = 0; | |
| 104 // Delay in seconds from calling Start() to the first update check. | 100 // Delay in seconds from calling Start() to the first update check. |
| 105 virtual int InitialDelay() = 0; | 101 virtual int InitialDelay() = 0; |
| 106 // Delay in seconds to every subsequent update check. 0 means don't check. | 102 // Delay in seconds to every subsequent update check. 0 means don't check. |
| 107 virtual int NextCheckDelay() = 0; | 103 virtual int NextCheckDelay() = 0; |
| 108 // Delay in seconds from each task step. Used to smooth out CPU/IO usage. | 104 // Delay in seconds from each task step. Used to smooth out CPU/IO usage. |
| 109 virtual int StepDelay() = 0; | 105 virtual int StepDelay() = 0; |
| 110 // Minimum delta time in seconds before checking again the same component. | 106 // Minimum delta time in seconds before checking again the same component. |
| 111 virtual int MinimumReCheckWait() = 0; | 107 virtual int MinimumReCheckWait() = 0; |
| 112 // Minimum delta time in seconds before an on-demand check is allowed | 108 // Minimum delta time in seconds before an on-demand check is allowed |
| 113 // for the same component. | 109 // for the same component. |
| 114 virtual int OnDemandDelay() = 0; | 110 virtual int OnDemandDelay() = 0; |
| 115 // The url that is going to be used update checks over Omaha protocol. | 111 // The url that is going to be used update checks over Omaha protocol. |
| 116 virtual GURL UpdateUrl() = 0; | 112 virtual GURL UpdateUrl() = 0; |
| 113 // The url where the completion pings are sent. Invalid if and only if | |
| 114 // pings are disabled. | |
| 115 virtual GURL PingUrl() = 0; | |
| 117 // Parameters added to each url request. It can be null if none are needed. | 116 // Parameters added to each url request. It can be null if none are needed. |
| 118 virtual const char* ExtraRequestParams() = 0; | 117 virtual const char* ExtraRequestParams() = 0; |
| 119 // How big each update request can be. Don't go above 2000. | 118 // How big each update request can be. Don't go above 2000. |
| 120 virtual size_t UrlSizeLimit() = 0; | 119 virtual size_t UrlSizeLimit() = 0; |
| 121 // The source of contexts for all the url requests. | 120 // The source of contexts for all the url requests. |
| 122 virtual net::URLRequestContextGetter* RequestContext() = 0; | 121 virtual net::URLRequestContextGetter* RequestContext() = 0; |
| 123 // True means that all ops are performed in this process. | 122 // True means that all ops are performed in this process. |
| 124 virtual bool InProcess() = 0; | 123 virtual bool InProcess() = 0; |
| 125 // The component updater will call this function when an interesting event | |
| 126 // happens. It should be used mostly as a place to add application specific | |
| 127 // logging or telemetry. |extra| is |event| dependent. | |
| 128 virtual void OnEvent(Events event, int extra) = 0; | |
| 129 // Creates a new ComponentPatcher in a platform-specific way. This is useful | 124 // Creates a new ComponentPatcher in a platform-specific way. This is useful |
| 130 // for dependency injection. | 125 // for dependency injection. |
| 131 virtual ComponentPatcher* CreateComponentPatcher() = 0; | 126 virtual ComponentPatcher* CreateComponentPatcher() = 0; |
| 132 // True means that this client can handle delta updates. | 127 // True means that this client can handle delta updates. |
| 133 virtual bool DeltasEnabled() const = 0; | 128 virtual bool DeltasEnabled() const = 0; |
| 134 }; | 129 }; |
| 135 | 130 |
| 136 // Start doing update checks and installing new versions of registered | 131 // Start doing update checks and installing new versions of registered |
| 137 // components after Configurator::InitialDelay() seconds. | 132 // components after Configurator::InitialDelay() seconds. |
| 138 virtual Status Start() = 0; | 133 virtual Status Start() = 0; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 149 // registered component, soon. If an update or check is already in progress, | 144 // registered component, soon. If an update or check is already in progress, |
| 150 // returns |kInProgress|. The same component cannot be checked repeatedly | 145 // returns |kInProgress|. The same component cannot be checked repeatedly |
| 151 // in a short interval either (returns |kError| if so). | 146 // in a short interval either (returns |kError| if so). |
| 152 // There is no guarantee that the item will actually be updated, | 147 // There is no guarantee that the item will actually be updated, |
| 153 // since another item may be chosen to be updated. Since there is | 148 // since another item may be chosen to be updated. Since there is |
| 154 // no time guarantee, there is no notification if the item is not updated. | 149 // no time guarantee, there is no notification if the item is not updated. |
| 155 // However, the ComponentInstaller should know if an update succeeded | 150 // However, the ComponentInstaller should know if an update succeeded |
| 156 // via the Install() hook. | 151 // via the Install() hook. |
| 157 virtual Status CheckForUpdateSoon(const CrxComponent& component) = 0; | 152 virtual Status CheckForUpdateSoon(const CrxComponent& component) = 0; |
| 158 | 153 |
| 154 // Adds or removes observers for this class. The caller of this class | |
| 155 // still maintains ownership of the observer, and it is responsible for | |
| 156 // removing and destroying the observer when the observer is not needed. | |
|
waffles
2013/07/16 22:47:13
What is the purpose of the returned status? We don
Sorin Jianu
2013/07/16 22:52:47
To be consistent with the other methods in the int
| |
| 157 virtual Status AddObserver( | |
| 158 component_updater::ComponentUpdaterServiceObserver* observer) = 0; | |
| 159 virtual Status RemoveObserver( | |
| 160 component_updater::ComponentUpdaterServiceObserver* observer) = 0; | |
| 161 | |
| 159 virtual ~ComponentUpdateService() {} | 162 virtual ~ComponentUpdateService() {} |
| 160 }; | 163 }; |
| 161 | 164 |
| 162 // Creates the component updater. You must pass a valid |config| allocated on | 165 // Creates the component updater. You must pass a valid |config| allocated on |
| 163 // the heap which the component updater will own. | 166 // the heap which the component updater will own. |
| 164 ComponentUpdateService* ComponentUpdateServiceFactory( | 167 ComponentUpdateService* ComponentUpdateServiceFactory( |
| 165 ComponentUpdateService::Configurator* config); | 168 ComponentUpdateService::Configurator* config); |
| 166 | 169 |
| 167 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 170 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
| OLD | NEW |