OLD | NEW |
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 "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h
" | 9 #include "components/data_reduction_proxy/common/data_reduction_proxy_switches.h
" |
10 #include "net/url_request/url_request.h" | 10 #include "net/url_request/url_request.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 alt_fallback_origin.empty())) | 192 alt_fallback_origin.empty())) |
193 alt_allowed_ = true; | 193 alt_allowed_ = true; |
194 | 194 |
195 // Only use default key if non of the proxies are configured on the command | 195 // Only use default key if non of the proxies are configured on the command |
196 // line. | 196 // line. |
197 if (key_.empty() && !configured_on_command_line) | 197 if (key_.empty() && !configured_on_command_line) |
198 key_ = GetDefaultKey(); | 198 key_ = GetDefaultKey(); |
199 | 199 |
200 std::string probe_url = command_line.GetSwitchValueASCII( | 200 std::string probe_url = command_line.GetSwitchValueASCII( |
201 switches::kDataReductionProxyProbeURL); | 201 switches::kDataReductionProxyProbeURL); |
| 202 std::string warmup_url = command_line.GetSwitchValueASCII( |
| 203 switches::kDataReductionProxyWarmupURL); |
202 | 204 |
203 // Set from preprocessor constants those params that are not specified on the | 205 // Set from preprocessor constants those params that are not specified on the |
204 // command line. | 206 // command line. |
205 if (origin.empty()) | 207 if (origin.empty()) |
206 origin = GetDefaultDevOrigin(); | 208 origin = GetDefaultDevOrigin(); |
207 if (origin.empty()) | 209 if (origin.empty()) |
208 origin = GetDefaultOrigin(); | 210 origin = GetDefaultOrigin(); |
209 if (fallback_origin.empty()) | 211 if (fallback_origin.empty()) |
210 fallback_origin = GetDefaultFallbackOrigin(); | 212 fallback_origin = GetDefaultFallbackOrigin(); |
211 if (ssl_origin.empty()) | 213 if (ssl_origin.empty()) |
212 ssl_origin = GetDefaultSSLOrigin(); | 214 ssl_origin = GetDefaultSSLOrigin(); |
213 if (alt_origin.empty()) | 215 if (alt_origin.empty()) |
214 alt_origin = GetDefaultAltOrigin(); | 216 alt_origin = GetDefaultAltOrigin(); |
215 if (alt_fallback_origin.empty()) | 217 if (alt_fallback_origin.empty()) |
216 alt_fallback_origin = GetDefaultAltFallbackOrigin(); | 218 alt_fallback_origin = GetDefaultAltFallbackOrigin(); |
217 if (probe_url.empty()) | 219 if (probe_url.empty()) |
218 probe_url = GetDefaultProbeURL(); | 220 probe_url = GetDefaultProbeURL(); |
| 221 if (warmup_url.empty()) |
| 222 warmup_url = GetDefaultWarmupURL(); |
219 | 223 |
220 origin_ = GURL(origin); | 224 origin_ = GURL(origin); |
221 fallback_origin_ = GURL(fallback_origin); | 225 fallback_origin_ = GURL(fallback_origin); |
222 ssl_origin_ = GURL(ssl_origin); | 226 ssl_origin_ = GURL(ssl_origin); |
223 alt_origin_ = GURL(alt_origin); | 227 alt_origin_ = GURL(alt_origin); |
224 alt_fallback_origin_ = GURL(alt_fallback_origin); | 228 alt_fallback_origin_ = GURL(alt_fallback_origin); |
225 probe_url_ = GURL(probe_url); | 229 probe_url_ = GURL(probe_url); |
| 230 warmup_url_ = GURL(warmup_url); |
226 | 231 |
227 } | 232 } |
228 | 233 |
229 bool DataReductionProxyParams::WasDataReductionProxyUsed( | 234 bool DataReductionProxyParams::WasDataReductionProxyUsed( |
230 const net::URLRequest* request, | 235 const net::URLRequest* request, |
231 std::pair<GURL, GURL>* proxy_servers) const { | 236 std::pair<GURL, GURL>* proxy_servers) const { |
232 DCHECK(request); | 237 DCHECK(request); |
233 return IsDataReductionProxy(request->proxy_server(), proxy_servers); | 238 return IsDataReductionProxy(request->proxy_server(), proxy_servers); |
234 } | 239 } |
235 | 240 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 return std::string(); | 340 return std::string(); |
336 } | 341 } |
337 | 342 |
338 std::string DataReductionProxyParams::GetDefaultProbeURL() const { | 343 std::string DataReductionProxyParams::GetDefaultProbeURL() const { |
339 #if defined(DATA_REDUCTION_PROXY_PROBE_URL) | 344 #if defined(DATA_REDUCTION_PROXY_PROBE_URL) |
340 return DATA_REDUCTION_PROXY_PROBE_URL; | 345 return DATA_REDUCTION_PROXY_PROBE_URL; |
341 #endif | 346 #endif |
342 return std::string(); | 347 return std::string(); |
343 } | 348 } |
344 | 349 |
| 350 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { |
| 351 #if defined(DATA_REDUCTION_PROXY_WARMUP_URL) |
| 352 return DATA_REDUCTION_PROXY_WARMUP_URL; |
| 353 #endif |
| 354 return std::string(); |
| 355 } |
| 356 |
345 } // namespace data_reduction_proxy | 357 } // namespace data_reduction_proxy |
OLD | NEW |