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

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
« no previous file with comments | « no previous file | components/component_updater.gypi » ('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 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 29 matching lines...) Expand all
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"
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 const std::string switch_url_source =
159 if (url_source_.empty()) { 157 GetSwitchArgument(switch_values, kSwitchUrlSource);
160 url_source_ = kDefaultUrlSource; 158 if (!switch_url_source.empty()) {
159 url_source_override_ = GURL(switch_url_source);
160 DCHECK(url_source_override_.is_valid());
161 } 161 }
162 162
163 if (HasSwitchValue(switch_values, kSwitchRequestParam)) 163 if (HasSwitchValue(switch_values, kSwitchRequestParam))
164 extra_info_ += "testrequest=\"1\""; 164 extra_info_ += "testrequest=\"1\"";
165 } 165 }
166 166
167 int ChromeConfigurator::InitialDelay() const { 167 int ChromeConfigurator::InitialDelay() const {
168 return fast_update_ ? 1 : (6 * kDelayOneMinute); 168 return fast_update_ ? 1 : (6 * kDelayOneMinute);
169 } 169 }
170 170
(...skipping 10 matching lines...) Expand all
181 } 181 }
182 182
183 int ChromeConfigurator::MinimumReCheckWait() const { 183 int ChromeConfigurator::MinimumReCheckWait() const {
184 return fast_update_ ? 30 : (6 * kDelayOneHour); 184 return fast_update_ ? 30 : (6 * kDelayOneHour);
185 } 185 }
186 186
187 int ChromeConfigurator::OnDemandDelay() const { 187 int ChromeConfigurator::OnDemandDelay() const {
188 return fast_update_ ? 2 : (30 * kDelayOneMinute); 188 return fast_update_ ? 2 : (30 * kDelayOneMinute);
189 } 189 }
190 190
191 GURL ChromeConfigurator::UpdateUrl() const { 191 std::vector<GURL> ChromeConfigurator::UpdateUrl() const {
192 return GURL(url_source_); 192 std::vector<GURL> urls;
193 if (url_source_override_.is_valid()) {
194 urls.push_back(GURL(url_source_override_));
195 } else {
196 urls.push_back(GURL(kDefaultUrlSource));
197 }
198 return urls;
193 } 199 }
194 200
195 GURL ChromeConfigurator::PingUrl() const { 201 std::vector<GURL> ChromeConfigurator::PingUrl() const {
196 return pings_enabled_ ? GURL(kPingUrl) : GURL(); 202 return pings_enabled_ ? UpdateUrl() : std::vector<GURL>();
197 } 203 }
198 204
199 base::Version ChromeConfigurator::GetBrowserVersion() const { 205 base::Version ChromeConfigurator::GetBrowserVersion() const {
200 return base::Version(chrome::VersionInfo().Version()); 206 return base::Version(chrome::VersionInfo().Version());
201 } 207 }
202 208
203 std::string ChromeConfigurator::GetChannel() const { 209 std::string ChromeConfigurator::GetChannel() const {
204 return ChromeOmahaQueryParamsDelegate::GetChannelString(); 210 return ChromeOmahaQueryParamsDelegate::GetChannelString();
205 } 211 }
206 212
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 259
254 } // namespace 260 } // namespace
255 261
256 Configurator* MakeChromeComponentUpdaterConfigurator( 262 Configurator* MakeChromeComponentUpdaterConfigurator(
257 const base::CommandLine* cmdline, 263 const base::CommandLine* cmdline,
258 net::URLRequestContextGetter* context_getter) { 264 net::URLRequestContextGetter* context_getter) {
259 return new ChromeConfigurator(cmdline, context_getter); 265 return new ChromeConfigurator(cmdline, context_getter);
260 } 266 }
261 267
262 } // namespace component_updater 268 } // namespace component_updater
OLDNEW
« no previous file with comments | « no previous file | components/component_updater.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698