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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // Returns an interface for on-demand updates. On-demand updates are |
171 // proactively triggered outside the normal component update service schedule. | 172 // proactively triggered outside the normal component update service schedule. |
172 virtual OnDemandUpdater& GetOnDemandUpdater() = 0; | 173 virtual OnDemandUpdater& GetOnDemandUpdater() = 0; |
173 | 174 |
175 // |callback| is called on the main thread once the component with |crx_id| | |
176 // is downloaded and installed. |callback| may be called synchronously | |
Sorin Jianu
2014/08/01 00:03:06
We need to better document the intention and the f
tommycli
2014/08/05 21:30:25
I rewrote parts of the comment. It's a bit long no
| |
177 // if component is already installed. The function implements a cooldown | |
178 // interval of 30 minutes. That means it will ineffective to call the | |
179 // function before the cooldown interval has passed. This behavior is intended | |
180 // to be defensive against programming bugs, usually triggered by web fetches, | |
181 // where the on-demand functionality is invoked too often. | |
182 virtual void MaybeThrottle(const std::string& crx_id, | |
183 const base::Closure& callback) = 0; | |
184 | |
174 // Returns a task runner suitable for use by component installers. | 185 // Returns a task runner suitable for use by component installers. |
175 virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() = 0; | 186 virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() = 0; |
176 | 187 |
177 virtual ~ComponentUpdateService() {} | 188 virtual ~ComponentUpdateService() {} |
178 | 189 |
179 private: | 190 private: |
180 // Returns details about registered component in the |item| parameter. The | 191 // Returns details about registered component in the |item| parameter. The |
181 // function returns true in case of success and false in case of errors. | 192 // function returns true in case of success and false in case of errors. |
182 virtual bool GetComponentDetails(const std::string& component_id, | 193 virtual bool GetComponentDetails(const std::string& component_id, |
183 CrxUpdateItem* item) const = 0; | 194 CrxUpdateItem* item) const = 0; |
184 | 195 |
185 friend class ::ComponentsUI; | 196 friend class ::ComponentsUI; |
186 FRIEND_TEST_ALL_PREFIXES(ComponentUpdaterTest, ResourceThrottleLiveNoUpdate); | |
187 }; | 197 }; |
188 | 198 |
189 typedef ComponentUpdateService::Observer ServiceObserver; | 199 typedef ComponentUpdateService::Observer ServiceObserver; |
190 | 200 |
191 class OnDemandUpdater { | 201 class OnDemandUpdater { |
192 public: | 202 public: |
193 virtual ~OnDemandUpdater() {} | 203 virtual ~OnDemandUpdater() {} |
194 | 204 |
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: | 205 private: |
207 friend class OnDemandTester; | 206 friend class OnDemandTester; |
208 friend class ::ComponentsUI; | 207 friend class ::ComponentsUI; |
209 | 208 |
210 // Triggers an update check for a component. |component_id| is a value | 209 // Triggers an update check for a component. |component_id| is a value |
211 // returned by GetCrxComponentID(). If an update for this component is already | 210 // returned by GetCrxComponentID(). If an update for this component is already |
212 // in progress, the function returns |kInProgress|. If an update is available, | 211 // in progress, the function returns |kInProgress|. If an update is available, |
213 // the update will be applied. The caller can subscribe to component update | 212 // the update will be applied. The caller can subscribe to component update |
214 // service notifications to get an indication about the outcome of the | 213 // service notifications to get an indication about the outcome of the |
215 // on-demand update. The function does not implement any cooldown interval. | 214 // on-demand update. The function does not implement any cooldown interval. |
216 virtual ComponentUpdateService::Status OnDemandUpdate( | 215 virtual ComponentUpdateService::Status OnDemandUpdate( |
217 const std::string& component_id) = 0; | 216 const std::string& component_id) = 0; |
218 }; | 217 }; |
219 | 218 |
220 // Creates the component updater. You must pass a valid |config| allocated on | 219 // Creates the component updater. You must pass a valid |config| allocated on |
221 // the heap which the component updater will own. | 220 // the heap which the component updater will own. |
222 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config); | 221 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config); |
223 | 222 |
224 } // namespace component_updater | 223 } // namespace component_updater |
225 | 224 |
226 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ | 225 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ |
OLD | NEW |