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

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

Issue 565363002: Implement support for fallback update check urls in the component updater (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 6 years, 3 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 #include "chrome/browser/component_updater/chrome_component_updater_configurator .h" 5 #include "chrome/browser/component_updater/chrome_component_updater_configurator .h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 27 matching lines...) Expand all
38 const char kSwitchRequestParam[] = "test-request"; 38 const char kSwitchRequestParam[] = "test-request";
39 39
40 // Disables pings. Pings are the requests sent to the update server that report 40 // Disables pings. Pings are the requests sent to the update server that report
41 // the success or the failure of component install or update attempts. 41 // the success or the failure of component install or update attempts.
42 extern const char kSwitchDisablePings[] = "disable-pings"; 42 extern const char kSwitchDisablePings[] = "disable-pings";
43 43
44 // Sets the URL for updates. 44 // Sets the URL for updates.
45 const char kSwitchUrlSource[] = "url-source"; 45 const char kSwitchUrlSource[] = "url-source";
46 46
47 #define COMPONENT_UPDATER_SERVICE_ENDPOINT \ 47 #define COMPONENT_UPDATER_SERVICE_ENDPOINT \
48 "//clients2.google.com/service/update2" 48 "//clients2.google.com/service/update2"
waffles 2014/09/12 22:38:26 Is there any point in having this #define anymore?
Sorin Jianu 2014/09/12 23:24:00 yes.
49 49
50 // The default url for the v3 protocol service endpoint. Can be 50 // The default url for the v3 protocol service endpoint.
51 // overridden with --component-updater=url-source=someurl. 51 // The value of |kDefaultUrlSource| can be overridden with
52 // --component-updater=url-source=someurl.
52 const char kDefaultUrlSource[] = "https:" COMPONENT_UPDATER_SERVICE_ENDPOINT; 53 const char kDefaultUrlSource[] = "https:" COMPONENT_UPDATER_SERVICE_ENDPOINT;
53 54
54 // The url to send the pings to.
55 const char kPingUrl[] = "https:" COMPONENT_UPDATER_SERVICE_ENDPOINT;
56
57 // Disables differential updates. 55 // Disables differential updates.
58 const char kSwitchDisableDeltaUpdates[] = "disable-delta-updates"; 56 const char kSwitchDisableDeltaUpdates[] = "disable-delta-updates";
59 57
60 #if defined(OS_WIN) 58 #if defined(OS_WIN)
61 // Disables background downloads. 59 // Disables background downloads.
62 const char kSwitchDisableBackgroundDownloads[] = "disable-background-downloads"; 60 const char kSwitchDisableBackgroundDownloads[] = "disable-background-downloads";
63 #endif // defined(OS_WIN) 61 #endif // defined(OS_WIN)
64 62
65 // Returns true if and only if |test| is contained in |vec|. 63 // Returns true if and only if |test| is contained in |vec|.
66 bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) { 64 bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) {
(...skipping 29 matching lines...) Expand all
96 net::URLRequestContextGetter* url_request_getter); 94 net::URLRequestContextGetter* url_request_getter);
97 95
98 virtual ~ChromeConfigurator() {} 96 virtual ~ChromeConfigurator() {}
99 97
100 virtual int InitialDelay() const OVERRIDE; 98 virtual int InitialDelay() const OVERRIDE;
101 virtual int NextCheckDelay() OVERRIDE; 99 virtual int NextCheckDelay() OVERRIDE;
102 virtual int StepDelay() const OVERRIDE; 100 virtual int StepDelay() const OVERRIDE;
103 virtual int StepDelayMedium() OVERRIDE; 101 virtual int StepDelayMedium() OVERRIDE;
104 virtual int MinimumReCheckWait() const OVERRIDE; 102 virtual int MinimumReCheckWait() const OVERRIDE;
105 virtual int OnDemandDelay() const OVERRIDE; 103 virtual int OnDemandDelay() const OVERRIDE;
106 virtual GURL UpdateUrl() const OVERRIDE; 104 virtual std::vector<GURL> UpdateUrl() const OVERRIDE;
107 virtual GURL PingUrl() const OVERRIDE; 105 virtual std::vector<GURL> PingUrl() const OVERRIDE;
108 virtual base::Version GetBrowserVersion() const OVERRIDE; 106 virtual base::Version GetBrowserVersion() const OVERRIDE;
109 virtual std::string GetChannel() const OVERRIDE; 107 virtual std::string GetChannel() const OVERRIDE;
110 virtual std::string GetLang() const OVERRIDE; 108 virtual std::string GetLang() const OVERRIDE;
111 virtual std::string GetOSLongName() const OVERRIDE; 109 virtual std::string GetOSLongName() const OVERRIDE;
112 virtual std::string ExtraRequestParams() const OVERRIDE; 110 virtual std::string ExtraRequestParams() const OVERRIDE;
113 virtual size_t UrlSizeLimit() const OVERRIDE; 111 virtual size_t UrlSizeLimit() const OVERRIDE;
114 virtual net::URLRequestContextGetter* RequestContext() const OVERRIDE; 112 virtual net::URLRequestContextGetter* RequestContext() const OVERRIDE;
115 virtual scoped_refptr<OutOfProcessPatcher> CreateOutOfProcessPatcher() 113 virtual scoped_refptr<OutOfProcessPatcher> CreateOutOfProcessPatcher()
116 const OVERRIDE; 114 const OVERRIDE;
117 virtual bool DeltasEnabled() const OVERRIDE; 115 virtual bool DeltasEnabled() const OVERRIDE;
118 virtual bool UseBackgroundDownloader() const OVERRIDE; 116 virtual bool UseBackgroundDownloader() const OVERRIDE;
119 virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() 117 virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner()
120 const OVERRIDE; 118 const OVERRIDE;
121 virtual scoped_refptr<base::SingleThreadTaskRunner> 119 virtual scoped_refptr<base::SingleThreadTaskRunner>
122 GetSingleThreadTaskRunner() const OVERRIDE; 120 GetSingleThreadTaskRunner() const OVERRIDE;
123 121
124 private: 122 private:
125 net::URLRequestContextGetter* url_request_getter_; 123 net::URLRequestContextGetter* url_request_getter_;
126 std::string extra_info_; 124 std::string extra_info_;
127 std::string url_source_; 125 GURL url_source_override_;
128 bool fast_update_; 126 bool fast_update_;
129 bool pings_enabled_; 127 bool pings_enabled_;
130 bool deltas_enabled_; 128 bool deltas_enabled_;
131 bool background_downloads_enabled_; 129 bool background_downloads_enabled_;
132 }; 130 };
133 131
134 ChromeConfigurator::ChromeConfigurator( 132 ChromeConfigurator::ChromeConfigurator(
135 const CommandLine* cmdline, 133 const CommandLine* cmdline,
136 net::URLRequestContextGetter* url_request_getter) 134 net::URLRequestContextGetter* url_request_getter)
137 : url_request_getter_(url_request_getter), 135 : url_request_getter_(url_request_getter),
(...skipping 10 matching lines...) Expand all
148 pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings); 146 pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings);
149 deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates); 147 deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates);
150 148
151 #if defined(OS_WIN) 149 #if defined(OS_WIN)
152 background_downloads_enabled_ = 150 background_downloads_enabled_ =
153 !HasSwitchValue(switch_values, kSwitchDisableBackgroundDownloads); 151 !HasSwitchValue(switch_values, kSwitchDisableBackgroundDownloads);
154 #else 152 #else
155 background_downloads_enabled_ = false; 153 background_downloads_enabled_ = false;
156 #endif 154 #endif
157 155
158 url_source_ = GetSwitchArgument(switch_values, kSwitchUrlSource); 156 url_source_override_ =
159 if (url_source_.empty()) { 157 GURL(GetSwitchArgument(switch_values, kSwitchUrlSource));
160 url_source_ = kDefaultUrlSource; 158 DCHECK(url_source_override_.is_valid());
161 }
162 159
163 if (HasSwitchValue(switch_values, kSwitchRequestParam)) 160 if (HasSwitchValue(switch_values, kSwitchRequestParam))
164 extra_info_ += "testrequest=\"1\""; 161 extra_info_ += "testrequest=\"1\"";
165 } 162 }
166 163
167 int ChromeConfigurator::InitialDelay() const { 164 int ChromeConfigurator::InitialDelay() const {
168 return fast_update_ ? 1 : (6 * kDelayOneMinute); 165 return fast_update_ ? 1 : (6 * kDelayOneMinute);
169 } 166 }
170 167
171 int ChromeConfigurator::NextCheckDelay() { 168 int ChromeConfigurator::NextCheckDelay() {
172 return fast_update_ ? 3 : (6 * kDelayOneHour); 169 return fast_update_ ? 3 : (6 * kDelayOneHour);
173 } 170 }
174 171
175 int ChromeConfigurator::StepDelayMedium() { 172 int ChromeConfigurator::StepDelayMedium() {
176 return fast_update_ ? 3 : (15 * kDelayOneMinute); 173 return fast_update_ ? 3 : (15 * kDelayOneMinute);
177 } 174 }
178 175
179 int ChromeConfigurator::StepDelay() const { 176 int ChromeConfigurator::StepDelay() const {
180 return fast_update_ ? 1 : 1; 177 return fast_update_ ? 1 : 1;
181 } 178 }
182 179
183 int ChromeConfigurator::MinimumReCheckWait() const { 180 int ChromeConfigurator::MinimumReCheckWait() const {
184 return fast_update_ ? 30 : (6 * kDelayOneHour); 181 return fast_update_ ? 30 : (6 * kDelayOneHour);
185 } 182 }
186 183
187 int ChromeConfigurator::OnDemandDelay() const { 184 int ChromeConfigurator::OnDemandDelay() const {
188 return fast_update_ ? 2 : (30 * kDelayOneMinute); 185 return fast_update_ ? 2 : (30 * kDelayOneMinute);
189 } 186 }
190 187
191 GURL ChromeConfigurator::UpdateUrl() const { 188 std::vector<GURL> ChromeConfigurator::UpdateUrl() const {
192 return GURL(url_source_); 189 std::vector<GURL> urls;
190 if (url_source_override_.is_valid()) {
191 urls.push_back(GURL(url_source_override_));
192 } else {
193 urls.push_back(GURL(kDefaultUrlSource));
194 }
195 return urls;
193 } 196 }
194 197
195 GURL ChromeConfigurator::PingUrl() const { 198 std::vector<GURL> ChromeConfigurator::PingUrl() const {
196 return pings_enabled_ ? GURL(kPingUrl) : GURL(); 199 return pings_enabled_ ? UpdateUrl() : std::vector<GURL>();
197 } 200 }
198 201
199 base::Version ChromeConfigurator::GetBrowserVersion() const { 202 base::Version ChromeConfigurator::GetBrowserVersion() const {
200 return base::Version(chrome::VersionInfo().Version()); 203 return base::Version(chrome::VersionInfo().Version());
201 } 204 }
202 205
203 std::string ChromeConfigurator::GetChannel() const { 206 std::string ChromeConfigurator::GetChannel() const {
204 return ChromeOmahaQueryParamsDelegate::GetChannelString(); 207 return ChromeOmahaQueryParamsDelegate::GetChannelString();
205 } 208 }
206 209
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 256
254 } // namespace 257 } // namespace
255 258
256 Configurator* MakeChromeComponentUpdaterConfigurator( 259 Configurator* MakeChromeComponentUpdaterConfigurator(
257 const base::CommandLine* cmdline, 260 const base::CommandLine* cmdline,
258 net::URLRequestContextGetter* context_getter) { 261 net::URLRequestContextGetter* context_getter) {
259 return new ChromeConfigurator(cmdline, context_getter); 262 return new ChromeConfigurator(cmdline, context_getter);
260 } 263 }
261 264
262 } // namespace component_updater 265 } // namespace component_updater
OLDNEW
« no previous file with comments | « no previous file | components/component_updater.gypi » ('j') | components/component_updater/request_sender.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698