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

Side by Side Diff: components/component_updater/component_updater_service.h

Issue 808773005: Move most of the component updater artifacts to update_client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ 5 #ifndef COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_
6 #define COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ 6 #define COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/version.h" 15 #include "base/version.h"
16 #include "url/gurl.h" 16 #include "url/gurl.h"
17 17
18 class ComponentsUI; 18 class ComponentsUI;
19 class SupervisedUserWhitelistService; 19 class SupervisedUserWhitelistService;
20 20
21 namespace base { 21 namespace base {
22 class DictionaryValue; 22 class DictionaryValue;
23 class FilePath; 23 class FilePath;
24 class SequencedTaskRunner; 24 class SequencedTaskRunner;
25 } 25 }
26 26
27 namespace content {
28 class ResourceThrottle;
29 }
30
27 namespace net { 31 namespace net {
28 class URLRequestContextGetter; 32 class URLRequestContextGetter;
29 class URLRequest; 33 class URLRequest;
30 } 34 }
31 35
32 namespace content { 36 namespace update_client {
33 class ResourceThrottle; 37 class ComponentInstaller;
38 class Configurator;
39 struct CrxComponent;
40 struct CrxUpdateItem;
34 } 41 }
35 42
36 namespace component_updater { 43 namespace component_updater {
37 44
38 class Configurator;
39 class OnDemandUpdater; 45 class OnDemandUpdater;
40 46
41 // Component specific installers must derive from this class and implement
42 // OnUpdateError() and Install(). A valid instance of this class must be
43 // given to ComponentUpdateService::RegisterComponent().
44 class ComponentInstaller {
45 public:
46 // Called by the component updater on the main thread when there was a
47 // problem unpacking or verifying the component. |error| is a non-zero
48 // value which is only meaningful to the component updater.
49 virtual void OnUpdateError(int error) = 0;
50
51 // Called by the component updater when a component has been unpacked
52 // and is ready to be installed. |manifest| contains the CRX manifest
53 // json dictionary and |unpack_path| contains the temporary directory
54 // with all the unpacked CRX files. This method may be called from
55 // a thread other than the main thread.
56 virtual bool Install(const base::DictionaryValue& manifest,
57 const base::FilePath& unpack_path) = 0;
58
59 // Set |installed_file| to the full path to the installed |file|. |file| is
60 // the filename of the file in this component's CRX. Returns false if this is
61 // not possible (the file has been removed or modified, or its current
62 // location is unknown). Otherwise, returns true.
63 virtual bool GetInstalledFile(const std::string& file,
64 base::FilePath* installed_file) = 0;
65
66 virtual ~ComponentInstaller() {}
67 };
68
69 // Describes a particular component that can be installed or updated. This
70 // structure is required to register a component with the component updater.
71 // |pk_hash| is the SHA256 hash of the component's public key. If the component
72 // is to be installed then version should be "0" or "0.0", else it should be
73 // the current version. |fingerprint|, and |name| are optional.
74 // |allow_background_download| specifies that the component can be background
75 // downloaded in some cases. The default for this value is |true| and the value
76 // can be overriden at the registration time. This is a temporary change until
77 // the issue 340448 is resolved.
78 struct CrxComponent {
79 std::vector<uint8_t> pk_hash;
80 ComponentInstaller* installer;
81 Version version;
82 std::string fingerprint;
83 std::string name;
84 bool allow_background_download;
85 CrxComponent();
86 ~CrxComponent();
87 };
88
89 struct CrxUpdateItem;
90
91 // The component update service is in charge of installing or upgrading 47 // The component update service is in charge of installing or upgrading
92 // select parts of chrome. Each part is called a component and managed by 48 // select parts of chrome. Each part is called a component and managed by
93 // instances of CrxComponent registered using RegisterComponent(). On the 49 // instances of CrxComponent registered using RegisterComponent(). On the
94 // server, each component is packaged as a CRX which is the same format used 50 // server, each component is packaged as a CRX which is the same format used
95 // to package extensions. To the update service each component is identified 51 // to package extensions. To the update service each component is identified
96 // by its public key hash (CrxComponent::pk_hash). If there is an update 52 // by its public key hash (CrxComponent::pk_hash). If there is an update
97 // available and its version is bigger than (CrxComponent::version), it will 53 // available and its version is bigger than (CrxComponent::version), it will
98 // be downloaded, verified and unpacked. Then component-specific installer 54 // be downloaded, verified and unpacked. Then component-specific installer
99 // ComponentInstaller::Install (of CrxComponent::installer) will be called. 55 // ComponentInstaller::Install (of CrxComponent::installer) will be called.
100 // 56 //
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // Start doing update checks and installing new versions of registered 114 // Start doing update checks and installing new versions of registered
159 // components after Configurator::InitialDelay() seconds. 115 // components after Configurator::InitialDelay() seconds.
160 virtual Status Start() = 0; 116 virtual Status Start() = 0;
161 117
162 // Stop doing update checks. In-flight requests and pending installations 118 // Stop doing update checks. In-flight requests and pending installations
163 // will not be canceled. 119 // will not be canceled.
164 virtual Status Stop() = 0; 120 virtual Status Stop() = 0;
165 121
166 // Add component to be checked for updates. You can call this method 122 // Add component to be checked for updates. You can call this method
167 // before calling Start(). 123 // before calling Start().
168 virtual Status RegisterComponent(const CrxComponent& component) = 0; 124 virtual Status RegisterComponent(
125 const update_client::CrxComponent& component) = 0;
169 126
170 // Returns a list of registered components. 127 // Returns a list of registered components.
171 virtual std::vector<std::string> GetComponentIDs() const = 0; 128 virtual std::vector<std::string> GetComponentIDs() const = 0;
172 129
173 // Returns an interface for on-demand updates. On-demand updates are 130 // Returns an interface for on-demand updates. On-demand updates are
174 // proactively triggered outside the normal component update service schedule. 131 // proactively triggered outside the normal component update service schedule.
175 virtual OnDemandUpdater& GetOnDemandUpdater() = 0; 132 virtual OnDemandUpdater& GetOnDemandUpdater() = 0;
176 133
177 // This method is used to trigger an on-demand update for component |crx_id|. 134 // This method is used to trigger an on-demand update for component |crx_id|.
178 // This can be used when loading a resource that depends on this component. 135 // This can be used when loading a resource that depends on this component.
(...skipping 11 matching lines...) Expand all
190 const base::Closure& callback) = 0; 147 const base::Closure& callback) = 0;
191 148
192 // Returns a task runner suitable for use by component installers. 149 // Returns a task runner suitable for use by component installers.
193 virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() = 0; 150 virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() = 0;
194 151
195 virtual ~ComponentUpdateService() {} 152 virtual ~ComponentUpdateService() {}
196 153
197 private: 154 private:
198 // Returns details about registered component in the |item| parameter. The 155 // Returns details about registered component in the |item| parameter. The
199 // function returns true in case of success and false in case of errors. 156 // function returns true in case of success and false in case of errors.
200 virtual bool GetComponentDetails(const std::string& component_id, 157 virtual bool GetComponentDetails(
201 CrxUpdateItem* item) const = 0; 158 const std::string& component_id,
159 update_client::CrxUpdateItem* item) const = 0;
202 160
203 friend class ::ComponentsUI; 161 friend class ::ComponentsUI;
204 }; 162 };
205 163
206 typedef ComponentUpdateService::Observer ServiceObserver; 164 typedef ComponentUpdateService::Observer ServiceObserver;
207 165
208 class OnDemandUpdater { 166 class OnDemandUpdater {
209 public: 167 public:
210 virtual ~OnDemandUpdater() {} 168 virtual ~OnDemandUpdater() {}
211 169
212 private: 170 private:
213 friend class OnDemandTester; 171 friend class OnDemandTester;
214 friend class SupervisedUserWhitelistInstaller; 172 friend class SupervisedUserWhitelistInstaller;
215 friend class ::ComponentsUI; 173 friend class ::ComponentsUI;
216 174
217 // Triggers an update check for a component. |component_id| is a value 175 // Triggers an update check for a component. |component_id| is a value
218 // returned by GetCrxComponentID(). If an update for this component is already 176 // returned by GetCrxComponentID(). If an update for this component is already
219 // in progress, the function returns |kInProgress|. If an update is available, 177 // in progress, the function returns |kInProgress|. If an update is available,
220 // the update will be applied. The caller can subscribe to component update 178 // the update will be applied. The caller can subscribe to component update
221 // service notifications to get an indication about the outcome of the 179 // service notifications to get an indication about the outcome of the
222 // on-demand update. The function does not implement any cooldown interval. 180 // on-demand update. The function does not implement any cooldown interval.
223 virtual ComponentUpdateService::Status OnDemandUpdate( 181 virtual ComponentUpdateService::Status OnDemandUpdate(
224 const std::string& component_id) = 0; 182 const std::string& component_id) = 0;
225 }; 183 };
226 184
227 // Creates the component updater. You must pass a valid |config| allocated on 185 // Creates the component updater. You must pass a valid |config| allocated on
228 // the heap which the component updater will own. 186 // the heap which the component updater will own.
229 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config); 187 ComponentUpdateService* ComponentUpdateServiceFactory(
188 update_client::Configurator* config);
230 189
231 } // namespace component_updater 190 } // namespace component_updater
232 191
233 #endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ 192 #endif // COMPONENTS_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698