Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: chrome/browser/component_updater/component_updater_service.h

Issue 292203002: Define and implement an interface for on-demand component updates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 11 matching lines...) Expand all
22 class URLRequestContextGetter; 22 class URLRequestContextGetter;
23 class URLRequest; 23 class URLRequest;
24 } 24 }
25 25
26 namespace content { 26 namespace content {
27 class ResourceThrottle; 27 class ResourceThrottle;
28 } 28 }
29 29
30 namespace component_updater { 30 namespace component_updater {
31 31
32 class OnDemandTester; 32 class OnDemandUpdater;
33 33
34 // Component specific installers must derive from this class and implement 34 // Component specific installers must derive from this class and implement
35 // OnUpdateError() and Install(). A valid instance of this class must be 35 // OnUpdateError() and Install(). A valid instance of this class must be
36 // given to ComponentUpdateService::RegisterComponent(). 36 // given to ComponentUpdateService::RegisterComponent().
37 class ComponentInstaller { 37 class ComponentInstaller {
38 public: 38 public:
39 // Called by the component updater on the UI thread when there was a 39 // Called by the component updater on the UI thread when there was a
40 // problem unpacking or verifying the component. |error| is a non-zero 40 // problem unpacking or verifying the component. |error| is a non-zero
41 // value which is only meaningful to the component updater. 41 // value which is only meaningful to the component updater.
42 virtual void OnUpdateError(int error) = 0; 42 virtual void OnUpdateError(int error) = 0;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // will not be canceled. 201 // will not be canceled.
202 virtual Status Stop() = 0; 202 virtual Status Stop() = 0;
203 203
204 // Add component to be checked for updates. You can call this method 204 // Add component to be checked for updates. You can call this method
205 // before calling Start(). 205 // before calling Start().
206 virtual Status RegisterComponent(const CrxComponent& component) = 0; 206 virtual Status RegisterComponent(const CrxComponent& component) = 0;
207 207
208 // Returns a list of registered components. 208 // Returns a list of registered components.
209 virtual void GetComponents(std::vector<CrxComponentInfo>* components) = 0; 209 virtual void GetComponents(std::vector<CrxComponentInfo>* components) = 0;
210 210
211 // Returns an interface for on-demand updates. On-demand updates are
212 // proactively triggered outside the normal component update service schedule.
213 virtual OnDemandUpdater& GetOnDemandUpdater() = 0;
214
215 virtual ~ComponentUpdateService() {}
216
217 private:
218 friend class ::ComponentsUI;
219 };
220
221 typedef ComponentUpdateService::Observer ServiceObserver;
222
223 class OnDemandUpdater {
224 public:
225 virtual ~OnDemandUpdater() {}
226
211 // Returns a network resource throttle. It means that a component will be 227 // Returns a network resource throttle. It means that a component will be
212 // downloaded and installed before the resource is unthrottled. This is the 228 // downloaded and installed before the resource is unthrottled. This function
213 // only function callable from the IO thread. 229 // can be called from the IO thread.
214 virtual content::ResourceThrottle* GetOnDemandResourceThrottle( 230 virtual content::ResourceThrottle* GetOnDemandResourceThrottle(
215 net::URLRequest* request, 231 net::URLRequest* request,
216 const std::string& crx_id) = 0; 232 const std::string& crx_id) = 0;
217 233
218 virtual ~ComponentUpdateService() {} 234 private:
235 friend class OnDemandTester;
236 friend class ::ComponentsUI;
219 237
220 friend class ::ComponentsUI; 238 // Triggers an update check for a component. |component_id| is a value
221 friend class OnDemandTester; 239 // returned by GetCrxComponentID(). If an update for this component is already
222 240 // in progress, the function returns |kInProgress|. If an update is available,
223 private: 241 // the update will be applied. The caller can subscribe to component update
224 // Ask the component updater to do an update check for a previously 242 // service notifications to get an indication about the outcome of the
225 // registered component, immediately. If an update or check is already 243 // on-demand update.
226 // in progress, returns |kInProgress|. 244 virtual ComponentUpdateService::Status OnDemandUpdate(
227 // There is no guarantee that the item will actually be updated, 245 const std::string& component_id) = 0;
228 // since an update may not be available. Listeners for the component will
229 // know the outcome of the check.
230 virtual Status OnDemandUpdate(const std::string& component_id) = 0;
231 }; 246 };
232 247
233 typedef ComponentUpdateService::Observer ServiceObserver;
234
235 // Creates the component updater. You must pass a valid |config| allocated on 248 // Creates the component updater. You must pass a valid |config| allocated on
236 // the heap which the component updater will own. 249 // the heap which the component updater will own.
237 ComponentUpdateService* ComponentUpdateServiceFactory( 250 ComponentUpdateService* ComponentUpdateServiceFactory(
238 ComponentUpdateService::Configurator* config); 251 ComponentUpdateService::Configurator* config);
239 252
240 } // namespace component_updater 253 } // namespace component_updater
241 254
242 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ 255 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698