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

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

Issue 385013002: Componentize component_updater: Replace content::BrowserThread usage with task runners (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove extraneous includes Created 6 years, 5 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
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/ref_counted.h"
12 #include "base/version.h" 13 #include "base/version.h"
13 #include "url/gurl.h" 14 #include "url/gurl.h"
14 15
15 class ComponentsUI; 16 class ComponentsUI;
16 17
17 namespace base { 18 namespace base {
18 class DictionaryValue; 19 class DictionaryValue;
19 class FilePath; 20 class FilePath;
21 class SequencedTaskRunner;
20 } 22 }
21 23
22 namespace net { 24 namespace net {
23 class URLRequestContextGetter; 25 class URLRequestContextGetter;
24 class URLRequest; 26 class URLRequest;
25 } 27 }
26 28
27 namespace content { 29 namespace content {
28 class ResourceThrottle; 30 class ResourceThrottle;
29 } 31 }
30 32
31 namespace component_updater { 33 namespace component_updater {
32 34
33 class Configurator; 35 class Configurator;
34 class OnDemandUpdater; 36 class OnDemandUpdater;
35 37
36 // Component specific installers must derive from this class and implement 38 // Component specific installers must derive from this class and implement
37 // OnUpdateError() and Install(). A valid instance of this class must be 39 // OnUpdateError() and Install(). A valid instance of this class must be
38 // given to ComponentUpdateService::RegisterComponent(). 40 // given to ComponentUpdateService::RegisterComponent().
39 class ComponentInstaller { 41 class ComponentInstaller {
40 public: 42 public:
41 // Called by the component updater on the UI thread when there was a 43 // Called by the component updater on the main thread when there was a
42 // problem unpacking or verifying the component. |error| is a non-zero 44 // problem unpacking or verifying the component. |error| is a non-zero
43 // value which is only meaningful to the component updater. 45 // value which is only meaningful to the component updater.
44 virtual void OnUpdateError(int error) = 0; 46 virtual void OnUpdateError(int error) = 0;
45 47
46 // Called by the component updater when a component has been unpacked 48 // Called by the component updater when a component has been unpacked
47 // and is ready to be installed. |manifest| contains the CRX manifest 49 // and is ready to be installed. |manifest| contains the CRX manifest
48 // json dictionary and |unpack_path| contains the temporary directory 50 // json dictionary and |unpack_path| contains the temporary directory
49 // with all the unpacked CRX files. 51 // with all the unpacked CRX files. This method may be called from
52 // a thread other than the main thread.
50 virtual bool Install(const base::DictionaryValue& manifest, 53 virtual bool Install(const base::DictionaryValue& manifest,
51 const base::FilePath& unpack_path) = 0; 54 const base::FilePath& unpack_path) = 0;
52 55
53 // Set |installed_file| to the full path to the installed |file|. |file| is 56 // Set |installed_file| to the full path to the installed |file|. |file| is
54 // the filename of the file in this component's CRX. Returns false if this is 57 // the filename of the file in this component's CRX. Returns false if this is
55 // not possible (the file has been removed or modified, or its current 58 // not possible (the file has been removed or modified, or its current
56 // location is unknown). Otherwise, returns true. 59 // location is unknown). Otherwise, returns true.
57 virtual bool GetInstalledFile(const std::string& file, 60 virtual bool GetInstalledFile(const std::string& file,
58 base::FilePath* installed_file) = 0; 61 base::FilePath* installed_file) = 0;
59 62
(...skipping 29 matching lines...) Expand all
89 // to package extensions. To the update service each component is identified 92 // to package extensions. To the update service each component is identified
90 // by its public key hash (CrxComponent::pk_hash). If there is an update 93 // by its public key hash (CrxComponent::pk_hash). If there is an update
91 // available and its version is bigger than (CrxComponent::version), it will 94 // available and its version is bigger than (CrxComponent::version), it will
92 // be downloaded, verified and unpacked. Then component-specific installer 95 // be downloaded, verified and unpacked. Then component-specific installer
93 // ComponentInstaller::Install (of CrxComponent::installer) will be called. 96 // ComponentInstaller::Install (of CrxComponent::installer) will be called.
94 // 97 //
95 // During the normal operation of the component updater some specific 98 // During the normal operation of the component updater some specific
96 // notifications are fired, like COMPONENT_UPDATER_STARTED and 99 // notifications are fired, like COMPONENT_UPDATER_STARTED and
97 // COMPONENT_UPDATE_FOUND. See notification_type.h for more details. 100 // COMPONENT_UPDATE_FOUND. See notification_type.h for more details.
98 // 101 //
99 // All methods are safe to call ONLY from chrome's UI thread. 102 // All methods are safe to call ONLY from the browser's main thread.
100 class ComponentUpdateService { 103 class ComponentUpdateService {
101 public: 104 public:
102 enum Status { kOk, kReplaced, kInProgress, kError }; 105 enum Status { kOk, kReplaced, kInProgress, kError };
103 106
104 // Defines an interface to observe ComponentUpdateService. It provides 107 // Defines an interface to observe ComponentUpdateService. It provides
105 // notifications when state changes occur for the service or for the 108 // notifications when state changes occur for the service or for the
106 // registered components. 109 // registered components.
107 class Observer { 110 class Observer {
108 public: 111 public:
109 enum Events { 112 enum Events {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // before calling Start(). 164 // before calling Start().
162 virtual Status RegisterComponent(const CrxComponent& component) = 0; 165 virtual Status RegisterComponent(const CrxComponent& component) = 0;
163 166
164 // Returns a list of registered components. 167 // Returns a list of registered components.
165 virtual std::vector<std::string> GetComponentIDs() const = 0; 168 virtual std::vector<std::string> GetComponentIDs() const = 0;
166 169
167 // Returns an interface for on-demand updates. On-demand updates are 170 // Returns an interface for on-demand updates. On-demand updates are
168 // proactively triggered outside the normal component update service schedule. 171 // proactively triggered outside the normal component update service schedule.
169 virtual OnDemandUpdater& GetOnDemandUpdater() = 0; 172 virtual OnDemandUpdater& GetOnDemandUpdater() = 0;
170 173
174 // Returns a task runner suitable for use by component installers.
175 virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() = 0;
176
171 virtual ~ComponentUpdateService() {} 177 virtual ~ComponentUpdateService() {}
172 178
173 private: 179 private:
174 // Returns details about registered component in the |item| parameter. The 180 // Returns details about registered component in the |item| parameter. The
175 // function returns true in case of success and false in case of errors. 181 // function returns true in case of success and false in case of errors.
176 virtual bool GetComponentDetails(const std::string& component_id, 182 virtual bool GetComponentDetails(const std::string& component_id,
177 CrxUpdateItem* item) const = 0; 183 CrxUpdateItem* item) const = 0;
178 184
179 friend class ::ComponentsUI; 185 friend class ::ComponentsUI;
180 FRIEND_TEST_ALL_PREFIXES(ComponentUpdaterTest, ResourceThrottleLiveNoUpdate); 186 FRIEND_TEST_ALL_PREFIXES(ComponentUpdaterTest, ResourceThrottleLiveNoUpdate);
(...skipping 30 matching lines...) Expand all
211 const std::string& component_id) = 0; 217 const std::string& component_id) = 0;
212 }; 218 };
213 219
214 // Creates the component updater. You must pass a valid |config| allocated on 220 // Creates the component updater. You must pass a valid |config| allocated on
215 // the heap which the component updater will own. 221 // the heap which the component updater will own.
216 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config); 222 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config);
217 223
218 } // namespace component_updater 224 } // namespace component_updater
219 225
220 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ 226 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698