Chromium Code Reviews| 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 |
| 11 #include "base/callback_forward.h" | |
| 11 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/version.h" | 14 #include "base/version.h" |
| 14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 15 | 16 |
| 16 class ComponentsUI; | 17 class ComponentsUI; |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 class DictionaryValue; | 20 class DictionaryValue; |
| 20 class FilePath; | 21 class FilePath; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 // will not be canceled. | 161 // will not be canceled. |
| 161 virtual Status Stop() = 0; | 162 virtual Status Stop() = 0; |
| 162 | 163 |
| 163 // Add component to be checked for updates. You can call this method | 164 // Add component to be checked for updates. You can call this method |
| 164 // before calling Start(). | 165 // before calling Start(). |
| 165 virtual Status RegisterComponent(const CrxComponent& component) = 0; | 166 virtual Status RegisterComponent(const CrxComponent& component) = 0; |
| 166 | 167 |
| 167 // Returns a list of registered components. | 168 // Returns a list of registered components. |
| 168 virtual std::vector<std::string> GetComponentIDs() const = 0; | 169 virtual std::vector<std::string> GetComponentIDs() const = 0; |
| 169 | 170 |
| 170 // Returns an interface for on-demand updates. On-demand updates are | 171 // |callback| is called on the main thread once the component with |crx_id| |
| 171 // proactively triggered outside the normal component update service schedule. | 172 // is downloaded and installed. |callback| may be called synchronously |
| 172 virtual OnDemandUpdater& GetOnDemandUpdater() = 0; | 173 // if component is already installed. The function implements a cooldown |
| 174 // interval of 30 minutes. That means it will ineffective to call the | |
| 175 // function before the cooldown interval has passed. This behavior is intended | |
| 176 // to be defensive against programming bugs, usually triggered by web fetches, | |
| 177 // where the on-demand functionality is invoked too often. | |
| 178 virtual void MaybeThrottle(const std::string& crx_id, | |
| 179 const base::Closure& callback) = 0; | |
| 173 | 180 |
| 174 // Returns a task runner suitable for use by component installers. | 181 // Returns a task runner suitable for use by component installers. |
| 175 virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() = 0; | 182 virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() = 0; |
| 176 | 183 |
| 177 virtual ~ComponentUpdateService() {} | 184 virtual ~ComponentUpdateService() {} |
| 178 | 185 |
| 179 private: | 186 private: |
| 187 friend class OnDemandTester; | |
| 188 friend class ::ComponentsUI; | |
| 189 | |
| 180 // Returns details about registered component in the |item| parameter. The | 190 // Returns details about registered component in the |item| parameter. The |
| 181 // function returns true in case of success and false in case of errors. | 191 // function returns true in case of success and false in case of errors. |
| 182 virtual bool GetComponentDetails(const std::string& component_id, | 192 virtual bool GetComponentDetails(const std::string& component_id, |
| 183 CrxUpdateItem* item) const = 0; | 193 CrxUpdateItem* item) const = 0; |
| 184 | 194 |
| 185 friend class ::ComponentsUI; | |
| 186 FRIEND_TEST_ALL_PREFIXES(ComponentUpdaterTest, ResourceThrottleLiveNoUpdate); | |
| 187 }; | |
| 188 | |
| 189 typedef ComponentUpdateService::Observer ServiceObserver; | |
| 190 | |
| 191 class OnDemandUpdater { | |
|
Sorin Jianu
2014/07/31 00:16:01
The idea here is that we want to have a class, whe
tommycli
2014/07/31 18:00:04
Done. Makes sense. I restored this class.
I left
| |
| 192 public: | |
| 193 virtual ~OnDemandUpdater() {} | |
| 194 | |
| 195 // Returns a network resource throttle. It means that a component will be | |
| 196 // downloaded and installed before the resource is unthrottled. This function | |
| 197 // can be called from the IO thread. The function implements a cooldown | |
| 198 // interval of 30 minutes. That means it will ineffective to call the | |
| 199 // function before the cooldown interval has passed. This behavior is intended | |
| 200 // to be defensive against programming bugs, usually triggered by web fetches, | |
| 201 // where the on-demand functionality is invoked too often. | |
| 202 virtual content::ResourceThrottle* GetOnDemandResourceThrottle( | |
| 203 net::URLRequest* request, | |
| 204 const std::string& crx_id) = 0; | |
| 205 | |
| 206 private: | |
| 207 friend class OnDemandTester; | |
| 208 friend class ::ComponentsUI; | |
| 209 | |
| 210 // Triggers an update check for a component. |component_id| is a value | 195 // Triggers an update check for a component. |component_id| is a value |
| 211 // returned by GetCrxComponentID(). If an update for this component is already | 196 // returned by GetCrxComponentID(). If an update for this component is already |
| 212 // in progress, the function returns |kInProgress|. If an update is available, | 197 // in progress, the function returns |kInProgress|. If an update is available, |
| 213 // the update will be applied. The caller can subscribe to component update | 198 // the update will be applied. The caller can subscribe to component update |
| 214 // service notifications to get an indication about the outcome of the | 199 // service notifications to get an indication about the outcome of the |
| 215 // on-demand update. The function does not implement any cooldown interval. | 200 // on-demand update. The function does not implement any cooldown interval. |
| 216 virtual ComponentUpdateService::Status OnDemandUpdate( | 201 virtual ComponentUpdateService::Status OnDemandUpdate( |
| 217 const std::string& component_id) = 0; | 202 const std::string& component_id) = 0; |
| 218 }; | 203 }; |
| 219 | 204 |
| 205 typedef ComponentUpdateService::Observer ServiceObserver; | |
| 206 | |
| 220 // Creates the component updater. You must pass a valid |config| allocated on | 207 // Creates the component updater. You must pass a valid |config| allocated on |
| 221 // the heap which the component updater will own. | 208 // the heap which the component updater will own. |
| 222 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config); | 209 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config); |
| 223 | 210 |
| 224 } // namespace component_updater | 211 } // namespace component_updater |
| 225 | 212 |
| 226 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 213 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
| OLD | NEW |