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

Side by Side Diff: chrome/browser/component_updater/component_updater_configurator.cc

Issue 11859044: Add a way to specify different source urls for the component updater (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/component_updater/component_updater_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/component_updater/component_updater_service.h" 5 #include "chrome/browser/component_updater/component_updater_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 13 matching lines...) Expand all
24 const int kDelayOneHour = kDelayOneMinute * 60; 24 const int kDelayOneHour = kDelayOneMinute * 60;
25 25
26 // Debug values you can pass to --component-updater-debug=value1,value2. 26 // Debug values you can pass to --component-updater-debug=value1,value2.
27 // Speed up component checking. 27 // Speed up component checking.
28 const char kDebugFastUpdate[] = "fast-update"; 28 const char kDebugFastUpdate[] = "fast-update";
29 // Force out-of-process-xml parsing. 29 // Force out-of-process-xml parsing.
30 const char kDebugOutOfProcess[] = "out-of-process"; 30 const char kDebugOutOfProcess[] = "out-of-process";
31 // Add "testrequest=1" parameter to the update check query. 31 // Add "testrequest=1" parameter to the update check query.
32 const char kDebugRequestParam[] = "test-request"; 32 const char kDebugRequestParam[] = "test-request";
33 33
34 // The urls from which an update manifest can be fetched.
35 const char* kUrlSources[] = {
36 "http://clients2.google.com/service/update2/crx", // BANDAID
37 "http://omaha.google.com/service/update2/crx", // CWS_PUBLIC
38 "http://omaha.sandbox.google.com/service/update2/crx" // CWS_SANDBOX
39 };
40
34 bool HasDebugValue(const std::vector<std::string>& vec, const char* test) { 41 bool HasDebugValue(const std::vector<std::string>& vec, const char* test) {
35 if (vec.empty()) 42 if (vec.empty())
36 return 0; 43 return 0;
37 return (std::find(vec.begin(), vec.end(), test) != vec.end()); 44 return (std::find(vec.begin(), vec.end(), test) != vec.end());
38 } 45 }
39 46
40 // The request extra information is the OS and architecture, this helps 47 // The request extra information is the OS and architecture, this helps
41 // the server select the right package to be delivered. 48 // the server select the right package to be delivered.
42 const char kExtraInfo[] = 49 const char kExtraInfo[] =
43 #if defined(OS_MACOSX) 50 #if defined(OS_MACOSX)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 public: 107 public:
101 ChromeConfigurator(const CommandLine* cmdline, 108 ChromeConfigurator(const CommandLine* cmdline,
102 net::URLRequestContextGetter* url_request_getter); 109 net::URLRequestContextGetter* url_request_getter);
103 110
104 virtual ~ChromeConfigurator() {} 111 virtual ~ChromeConfigurator() {}
105 112
106 virtual int InitialDelay() OVERRIDE; 113 virtual int InitialDelay() OVERRIDE;
107 virtual int NextCheckDelay() OVERRIDE; 114 virtual int NextCheckDelay() OVERRIDE;
108 virtual int StepDelay() OVERRIDE; 115 virtual int StepDelay() OVERRIDE;
109 virtual int MinimumReCheckWait() OVERRIDE; 116 virtual int MinimumReCheckWait() OVERRIDE;
110 virtual GURL UpdateUrl() OVERRIDE; 117 virtual GURL UpdateUrl(CrxComponent::UrlSource source) OVERRIDE;
111 virtual const char* ExtraRequestParams() OVERRIDE; 118 virtual const char* ExtraRequestParams() OVERRIDE;
112 virtual size_t UrlSizeLimit() OVERRIDE; 119 virtual size_t UrlSizeLimit() OVERRIDE;
113 virtual net::URLRequestContextGetter* RequestContext() OVERRIDE; 120 virtual net::URLRequestContextGetter* RequestContext() OVERRIDE;
114 virtual bool InProcess() OVERRIDE; 121 virtual bool InProcess() OVERRIDE;
115 virtual void OnEvent(Events event, int val) OVERRIDE; 122 virtual void OnEvent(Events event, int val) OVERRIDE;
116 123
117 private: 124 private:
118 net::URLRequestContextGetter* url_request_getter_; 125 net::URLRequestContextGetter* url_request_getter_;
119 std::string extra_info_; 126 std::string extra_info_;
120 bool fast_update_; 127 bool fast_update_;
121 bool out_of_process_; 128 bool out_of_process_;
122 GURL app_update_url_;
123 }; 129 };
124 130
125 ChromeConfigurator::ChromeConfigurator(const CommandLine* cmdline, 131 ChromeConfigurator::ChromeConfigurator(const CommandLine* cmdline,
126 net::URLRequestContextGetter* url_request_getter) 132 net::URLRequestContextGetter* url_request_getter)
127 : url_request_getter_(url_request_getter), 133 : url_request_getter_(url_request_getter),
128 extra_info_(kExtraInfo) { 134 extra_info_(kExtraInfo) {
129 // Parse comma-delimited debug flags. 135 // Parse comma-delimited debug flags.
130 std::vector<std::string> debug_values; 136 std::vector<std::string> debug_values;
131 Tokenize(cmdline->GetSwitchValueASCII(switches::kComponentUpdaterDebug), 137 Tokenize(cmdline->GetSwitchValueASCII(switches::kComponentUpdaterDebug),
132 ",", &debug_values); 138 ",", &debug_values);
133 fast_update_ = HasDebugValue(debug_values, kDebugFastUpdate); 139 fast_update_ = HasDebugValue(debug_values, kDebugFastUpdate);
134 out_of_process_ = HasDebugValue(debug_values, kDebugOutOfProcess); 140 out_of_process_ = HasDebugValue(debug_values, kDebugOutOfProcess);
135 141
136 // Allow switch to override update URL (piggyback on AppsGalleryUpdateURL).
137 if (cmdline->HasSwitch(switches::kAppsGalleryUpdateURL)) {
138 app_update_url_ =
139 GURL(cmdline->GetSwitchValueASCII(switches::kAppsGalleryUpdateURL));
140 } else {
141 app_update_url_ = GURL("http://clients2.google.com/service/update2/crx");
142 }
143
144 // Make the extra request params, they are necessary so omaha does 142 // Make the extra request params, they are necessary so omaha does
145 // not deliver components that are going to be rejected at install time. 143 // not deliver components that are going to be rejected at install time.
146 extra_info_ += chrome::VersionInfo().Version(); 144 extra_info_ += chrome::VersionInfo().Version();
147 #if defined(OS_WIN) 145 #if defined(OS_WIN)
148 if (base::win::OSInfo::GetInstance()->wow64_status() == 146 if (base::win::OSInfo::GetInstance()->wow64_status() ==
149 base::win::OSInfo::WOW64_ENABLED) 147 base::win::OSInfo::WOW64_ENABLED)
150 extra_info_ += "&wow64=1"; 148 extra_info_ += "&wow64=1";
151 #endif 149 #endif
152 if (HasDebugValue(debug_values, kDebugRequestParam)) 150 if (HasDebugValue(debug_values, kDebugRequestParam))
153 extra_info_ += "&testrequest=1"; 151 extra_info_ += "&testrequest=1";
154 } 152 }
155 153
156 int ChromeConfigurator::InitialDelay() { 154 int ChromeConfigurator::InitialDelay() {
157 return fast_update_ ? 1 : (6 * kDelayOneMinute); 155 return fast_update_ ? 1 : (6 * kDelayOneMinute);
158 } 156 }
159 157
160 int ChromeConfigurator::NextCheckDelay() { 158 int ChromeConfigurator::NextCheckDelay() {
161 return fast_update_ ? 3 : (2 * kDelayOneHour); 159 return fast_update_ ? 3 : (2 * kDelayOneHour);
162 } 160 }
163 161
164 int ChromeConfigurator::StepDelay() { 162 int ChromeConfigurator::StepDelay() {
165 return fast_update_ ? 1 : 4; 163 return fast_update_ ? 1 : 4;
166 } 164 }
167 165
168 int ChromeConfigurator::MinimumReCheckWait() { 166 int ChromeConfigurator::MinimumReCheckWait() {
169 return fast_update_ ? 30 : (6 * kDelayOneHour); 167 return fast_update_ ? 30 : (6 * kDelayOneHour);
170 } 168 }
171 169
172 GURL ChromeConfigurator::UpdateUrl() { 170 GURL ChromeConfigurator::UpdateUrl(CrxComponent::UrlSource source) {
173 return app_update_url_; 171 return GURL(kUrlSources[source]);
174 } 172 }
175 173
176 const char* ChromeConfigurator::ExtraRequestParams() { 174 const char* ChromeConfigurator::ExtraRequestParams() {
177 return extra_info_.c_str(); 175 return extra_info_.c_str();
178 } 176 }
179 177
180 size_t ChromeConfigurator::UrlSizeLimit() { 178 size_t ChromeConfigurator::UrlSizeLimit() {
181 return 1024ul; 179 return 1024ul;
182 } 180 }
183 181
(...skipping 28 matching lines...) Expand all
212 default: 210 default:
213 NOTREACHED(); 211 NOTREACHED();
214 break; 212 break;
215 } 213 }
216 } 214 }
217 215
218 ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator( 216 ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator(
219 const CommandLine* cmdline, net::URLRequestContextGetter* context_getter) { 217 const CommandLine* cmdline, net::URLRequestContextGetter* context_getter) {
220 return new ChromeConfigurator(cmdline, context_getter); 218 return new ChromeConfigurator(cmdline, context_getter);
221 } 219 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/component_updater/component_updater_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698