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

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

Issue 15908002: Differential updates for components. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/files/file_path.h"
11 #include "base/version.h" 12 #include "base/version.h"
12 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
13 14
14 namespace net { 15 namespace net {
15 class URLRequestContextGetter; 16 class URLRequestContextGetter;
16 } 17 }
17 18
18 namespace base { 19 namespace base {
19 class DictionaryValue; 20 class DictionaryValue;
20 class FilePath; 21 class FilePath;
cpu_(ooo_6.6-7.5) 2013/05/29 20:13:58 note filepath is fwd declared here.
waffles 2013/06/13 20:55:04 Done.
21 } 22 }
22 23
24 class ComponentPatcher;
25
23 // Component specific installers must derive from this class and implement 26 // Component specific installers must derive from this class and implement
24 // OnUpdateError() and Install(). A valid instance of this class must be 27 // OnUpdateError() and Install(). A valid instance of this class must be
25 // given to ComponentUpdateService::RegisterComponent(). 28 // given to ComponentUpdateService::RegisterComponent().
26 class ComponentInstaller { 29 class ComponentInstaller {
27 public : 30 public :
28 // Called by the component updater on the UI thread when there was a 31 // Called by the component updater on the UI thread when there was a
29 // problem unpacking or verifying the component. |error| is a non-zero 32 // problem unpacking or verifying the component. |error| is a non-zero
30 // value which is only meaningful to the component updater. 33 // value which is only meaningful to the component updater.
31 virtual void OnUpdateError(int error) = 0; 34 virtual void OnUpdateError(int error) = 0;
32 35
33 // Called by the component updater when a component has been unpacked 36 // Called by the component updater when a component has been unpacked
34 // and is ready to be installed. |manifest| contains the CRX manifest 37 // and is ready to be installed. |manifest| contains the CRX manifest
35 // json dictionary and |unpack_path| contains the temporary directory 38 // json dictionary and |unpack_path| contains the temporary directory
36 // with all the unpacked CRX files. 39 // with all the unpacked CRX files.
37 virtual bool Install(const base::DictionaryValue& manifest, 40 virtual bool Install(const base::DictionaryValue& manifest,
38 const base::FilePath& unpack_path) = 0; 41 const base::FilePath& unpack_path) = 0;
39 42
43 // Set |installed_file| to the full path to the installed |file|. |file| is
44 // the filename of the file in this component's CRX. Returns false if this is
45 // not possible (the file has been removed or modified, or its current
46 // location is unknown). Otherwise, returns true.
47 virtual bool GetInstalledFile(const std::string& file,
48 base::FilePath* installed_file) = 0;
49
40 protected: 50 protected:
41 virtual ~ComponentInstaller() {} 51 virtual ~ComponentInstaller() {}
42 }; 52 };
43 53
44 // Describes a particular component that can be installed or updated. This 54 // Describes a particular component that can be installed or updated. This
45 // structure is required to register a component with the component updater. 55 // structure is required to register a component with the component updater.
46 // Only |name| is optional. |pk_hash| is the SHA256 hash of the component's 56 // Only |name| is optional. |pk_hash| is the SHA256 hash of the component's
47 // public key. If the component is to be installed then version should be 57 // public key. If the component is to be installed then version should be
48 // "0" or "0.0", else it should be the current version. 58 // "0" or "0.0", else it should be the current version.
49 // |source| is by default pointing to BANDAID but if needed it can be made 59 // |source| is by default pointing to BANDAID but if needed it can be made
50 // to point to the webstore (CWS_PUBLIC) or to the webstore sandbox. It is 60 // to point to the webstore (CWS_PUBLIC) or to the webstore sandbox. It is
51 // important to note that the BANDAID source if active throught the day 61 // important to note that the BANDAID source if active throught the day
52 // can pre-empt updates from the other sources down the list. 62 // can pre-empt updates from the other sources down the list.
53 struct CrxComponent { 63 struct CrxComponent {
54 // Specifies the source url for manifest check. 64 // Specifies the source url for manifest check.
55 enum UrlSource { 65 enum UrlSource {
56 BANDAID, 66 BANDAID,
57 CWS_PUBLIC, 67 CWS_PUBLIC,
58 CWS_SANDBOX 68 CWS_SANDBOX,
59 }; 69 };
60 70
61 std::vector<uint8> pk_hash; 71 std::vector<uint8> pk_hash;
62 ComponentInstaller* installer; 72 ComponentInstaller* installer;
63 Version version; 73 Version version;
74 std::string fingerprint;
cpu_(ooo_6.6-7.5) 2013/05/29 20:13:58 if they have to provide the fingerprint, could thi
waffles 2013/06/13 20:55:04 The fingerprint uniquely identifies the installed
64 std::string name; 75 std::string name;
65 UrlSource source; 76 UrlSource source;
66 CrxComponent(); 77 CrxComponent();
67 ~CrxComponent(); 78 ~CrxComponent();
68 }; 79 };
69 80
70 // The component update service is in charge of installing or upgrading 81 // The component update service is in charge of installing or upgrading
71 // select parts of chrome. Each part is called a component and managed by 82 // select parts of chrome. Each part is called a component and managed by
72 // instances of CrxComponent registered using RegisterComponent(). On the 83 // instances of CrxComponent registered using RegisterComponent(). On the
73 // server, each component is packaged as a CRX which is the same format used 84 // server, each component is packaged as a CRX which is the same format used
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 virtual int NextCheckDelay() = 0; 120 virtual int NextCheckDelay() = 0;
110 // Delay in seconds from each task step. Used to smooth out CPU/IO usage. 121 // Delay in seconds from each task step. Used to smooth out CPU/IO usage.
111 virtual int StepDelay() = 0; 122 virtual int StepDelay() = 0;
112 // Minimum delta time in seconds before checking again the same component. 123 // Minimum delta time in seconds before checking again the same component.
113 virtual int MinimumReCheckWait() = 0; 124 virtual int MinimumReCheckWait() = 0;
114 // Minimum delta time in seconds before an on-demand check is allowed 125 // Minimum delta time in seconds before an on-demand check is allowed
115 // for the same component. 126 // for the same component.
116 virtual int OnDemandDelay() = 0; 127 virtual int OnDemandDelay() = 0;
117 // The url that is going to be used update checks over Omaha protocol. 128 // The url that is going to be used update checks over Omaha protocol.
118 virtual GURL UpdateUrl(CrxComponent::UrlSource source) = 0; 129 virtual GURL UpdateUrl(CrxComponent::UrlSource source) = 0;
130 // The url where the completion pings are sent.
131 virtual GURL PingUrl() = 0;
cpu_(ooo_6.6-7.5) 2013/05/29 20:13:58 hmmm, I already receive complains about undue QPS
waffles 2013/06/13 20:55:04 We've addressed this out of band. For the record,
119 // Parameters added to each url request. It can be null if none are needed. 132 // Parameters added to each url request. It can be null if none are needed.
120 virtual const char* ExtraRequestParams() = 0; 133 virtual const char* ExtraRequestParams() = 0;
121 // How big each update request can be. Don't go above 2000. 134 // How big each update request can be. Don't go above 2000.
122 virtual size_t UrlSizeLimit() = 0; 135 virtual size_t UrlSizeLimit() = 0;
123 // The source of contexts for all the url requests. 136 // The source of contexts for all the url requests.
124 virtual net::URLRequestContextGetter* RequestContext() = 0; 137 virtual net::URLRequestContextGetter* RequestContext() = 0;
125 // True means that all ops are performed in this process. 138 // True means that all ops are performed in this process.
126 virtual bool InProcess() = 0; 139 virtual bool InProcess() = 0;
127 // The component updater will call this function when an interesting event 140 // The component updater will call this function when an interesting event
128 // happens. It should be used mostly as a place to add application specific 141 // happens. It should be used mostly as a place to add application specific
129 // logging or telemetry. |extra| is |event| dependent. 142 // logging or telemetry. |extra| is |event| dependent.
130 virtual void OnEvent(Events event, int extra) = 0; 143 virtual void OnEvent(Events event, int extra) = 0;
144 // Creates a new ComponentPatcher in a platform-specific way. This is useful
145 // for dependency injection.
146 virtual ComponentPatcher* CreateComponentPatcher() = 0;
147 // True means that this client can handle delta updates.
148 virtual bool DeltasEnabled() const = 0;
149 // True means this client is allowed to send component update status pings.
150 virtual bool PingsEnabled() const = 0;
131 }; 151 };
132 152
133 // Start doing update checks and installing new versions of registered 153 // Start doing update checks and installing new versions of registered
134 // components after Configurator::InitialDelay() seconds. 154 // components after Configurator::InitialDelay() seconds.
135 virtual Status Start() = 0; 155 virtual Status Start() = 0;
136 156
137 // Stop doing update checks. In-flight requests and pending installations 157 // Stop doing update checks. In-flight requests and pending installations
138 // will not be canceled. 158 // will not be canceled.
139 virtual Status Stop() = 0; 159 virtual Status Stop() = 0;
140 160
(...skipping 14 matching lines...) Expand all
155 175
156 virtual ~ComponentUpdateService() {} 176 virtual ~ComponentUpdateService() {}
157 }; 177 };
158 178
159 // Creates the component updater. You must pass a valid |config| allocated on 179 // Creates the component updater. You must pass a valid |config| allocated on
160 // the heap which the component updater will own. 180 // the heap which the component updater will own.
161 ComponentUpdateService* ComponentUpdateServiceFactory( 181 ComponentUpdateService* ComponentUpdateServiceFactory(
162 ComponentUpdateService::Configurator* config); 182 ComponentUpdateService::Configurator* config);
163 183
164 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ 184 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698