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/core/common/data_reduction_proxy_param s.h" | 5 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param s.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 #include "net/proxy/proxy_service.h" | 23 #include "net/proxy/proxy_service.h" |
24 #include "net/url_request/url_request.h" | 24 #include "net/url_request/url_request.h" |
25 #include "net/url_request/url_request_context.h" | 25 #include "net/url_request/url_request_context.h" |
26 #include "url/url_constants.h" | 26 #include "url/url_constants.h" |
27 | 27 |
28 using base::FieldTrialList; | 28 using base::FieldTrialList; |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 const char kEnabled[] = "Enabled"; | 32 const char kEnabled[] = "Enabled"; |
33 const char kDefaultOrigin[] = "https://proxy.googlezip.net:443"; | 33 const char kDefaultSpdyOrigin[] = "https://proxy.googlezip.net:443"; |
34 const char kDefaultQuicOrigin[] = "quic://proxy.googlezip.net:443"; | |
34 const char kDevOrigin[] = "https://proxy-dev.googlezip.net:443"; | 35 const char kDevOrigin[] = "https://proxy-dev.googlezip.net:443"; |
35 const char kDevFallbackOrigin[] = "proxy-dev.googlezip.net:80"; | 36 const char kDevFallbackOrigin[] = "proxy-dev.googlezip.net:80"; |
36 const char kDefaultFallbackOrigin[] = "compress.googlezip.net:80"; | 37 const char kDefaultFallbackOrigin[] = "compress.googlezip.net:80"; |
37 // This is for a proxy that supports HTTP CONNECT to tunnel SSL traffic. | 38 // This is for a proxy that supports HTTP CONNECT to tunnel SSL traffic. |
38 // The proxy listens on port 443, but uses the HTTP protocol to set up | 39 // The proxy listens on port 443, but uses the HTTP protocol to set up |
39 // the tunnel, not HTTPS. | 40 // the tunnel, not HTTPS. |
40 const char kDefaultSslOrigin[] = "ssl.googlezip.net:443"; | 41 const char kDefaultSslOrigin[] = "ssl.googlezip.net:443"; |
41 const char kDefaultAltOrigin[] = "ssl.googlezip.net:80"; | 42 const char kDefaultAltOrigin[] = "ssl.googlezip.net:80"; |
42 const char kDefaultAltFallbackOrigin[] = "ssl.googlezip.net:80"; | 43 const char kDefaultAltFallbackOrigin[] = "ssl.googlezip.net:80"; |
43 const char kDefaultProbeUrl[] = "http://check.googlezip.net/connect"; | 44 const char kDefaultProbeUrl[] = "http://check.googlezip.net/connect"; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 "DataReductionProxyRemoveMissingViaHeaderOtherBypass") == "Relaxed"; | 92 "DataReductionProxyRemoveMissingViaHeaderOtherBypass") == "Relaxed"; |
92 } | 93 } |
93 | 94 |
94 // static | 95 // static |
95 bool DataReductionProxyParams::IsIncludedInAndroidOnePromoFieldTrial( | 96 bool DataReductionProxyParams::IsIncludedInAndroidOnePromoFieldTrial( |
96 const char* build_fingerprint) { | 97 const char* build_fingerprint) { |
97 base::StringPiece fingerprint(build_fingerprint); | 98 base::StringPiece fingerprint(build_fingerprint); |
98 return (fingerprint.find(kAndroidOneIdentifier) != std::string::npos); | 99 return (fingerprint.find(kAndroidOneIdentifier) != std::string::npos); |
99 } | 100 } |
100 | 101 |
102 // static | |
103 bool DataReductionProxyParams::IsIncludedInUseQUICFieldTrial() { | |
104 return FieldTrialList::FindFullName("DataReductionProxyUseQuic") == kEnabled; | |
105 } | |
106 | |
107 void DataReductionProxyParams::SetIsQuicEnabledForProxies( | |
108 bool quic_enabled_for_proxies) { | |
109 quic_enabled_for_proxies_ = quic_enabled_for_proxies; | |
110 if (command_line_origin_.empty() && IsIncludedInUseQUICFieldTrial() && | |
bengr
2015/02/10 20:18:31
I don't think you want to check if you're in the f
tbansal1
2015/02/10 22:24:38
I need to: quic_enabled_for_proxies_ can be true i
| |
111 quic_enabled_for_proxies_) | |
112 origin_ = net::ProxyServer::FromURI(kDefaultQuicOrigin, | |
113 net::ProxyServer::SCHEME_HTTP); | |
114 } | |
115 | |
101 DataReductionProxyTypeInfo::DataReductionProxyTypeInfo() | 116 DataReductionProxyTypeInfo::DataReductionProxyTypeInfo() |
102 : proxy_servers(), | 117 : proxy_servers(), |
103 is_fallback(false), | 118 is_fallback(false), |
104 is_alternative(false), | 119 is_alternative(false), |
105 is_ssl(false) { | 120 is_ssl(false) { |
106 } | 121 } |
107 | 122 |
108 DataReductionProxyTypeInfo::~DataReductionProxyTypeInfo(){ | 123 DataReductionProxyTypeInfo::~DataReductionProxyTypeInfo(){ |
109 } | 124 } |
110 | 125 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 command_line.GetSwitchValueASCII(switches::kDataReductionSSLProxy); | 282 command_line.GetSwitchValueASCII(switches::kDataReductionSSLProxy); |
268 std::string alt_origin = | 283 std::string alt_origin = |
269 command_line.GetSwitchValueASCII(switches::kDataReductionProxyAlt); | 284 command_line.GetSwitchValueASCII(switches::kDataReductionProxyAlt); |
270 std::string alt_fallback_origin = command_line.GetSwitchValueASCII( | 285 std::string alt_fallback_origin = command_line.GetSwitchValueASCII( |
271 switches::kDataReductionProxyAltFallback); | 286 switches::kDataReductionProxyAltFallback); |
272 | 287 |
273 configured_on_command_line_ = | 288 configured_on_command_line_ = |
274 !(origin.empty() && fallback_origin.empty() && ssl_origin.empty() && | 289 !(origin.empty() && fallback_origin.empty() && ssl_origin.empty() && |
275 alt_origin.empty() && alt_fallback_origin.empty()); | 290 alt_origin.empty() && alt_fallback_origin.empty()); |
276 | 291 |
292 // quic_globally_disabled_ = command_line.HasSwitch(switches::kDisableQuic); | |
bengr
2015/02/10 20:18:31
Remove dead code.
tbansal1
2015/02/10 22:24:38
Done.
| |
277 | 293 |
278 // Configuring the proxy on the command line overrides the values of | 294 // Configuring the proxy on the command line overrides the values of |
279 // |allowed_| and |alt_allowed_|. | 295 // |allowed_| and |alt_allowed_|. |
280 if (configured_on_command_line_) | 296 if (configured_on_command_line_) |
281 allowed_ = true; | 297 allowed_ = true; |
282 if (!(ssl_origin.empty() && | 298 if (!(ssl_origin.empty() && |
283 alt_origin.empty())) | 299 alt_origin.empty())) |
284 alt_allowed_ = true; | 300 alt_allowed_ = true; |
285 | 301 |
286 std::string probe_url = command_line.GetSwitchValueASCII( | 302 std::string probe_url = command_line.GetSwitchValueASCII( |
287 switches::kDataReductionProxyProbeURL); | 303 switches::kDataReductionProxyProbeURL); |
288 std::string warmup_url = command_line.GetSwitchValueASCII( | 304 std::string warmup_url = command_line.GetSwitchValueASCII( |
289 switches::kDataReductionProxyWarmupURL); | 305 switches::kDataReductionProxyWarmupURL); |
290 | 306 |
291 // Set from preprocessor constants those params that are not specified on the | 307 // Set from preprocessor constants those params that are not specified on the |
292 // command line. | 308 // command line. |
309 LOG(WARNING) << "InitWithoutChecks origin.empty()=" << origin.empty() | |
bengr
2015/02/10 20:18:31
Remove this logging. If you need it, don't use WAR
tbansal1
2015/02/10 22:24:38
Done.
| |
310 << " GetDefaultDevOrigin()=" << GetDefaultDevOrigin(); | |
311 | |
293 if (origin.empty()) | 312 if (origin.empty()) |
294 origin = GetDefaultDevOrigin(); | 313 origin = GetDefaultDevOrigin(); |
314 command_line_origin_ = origin; | |
295 if (origin.empty()) | 315 if (origin.empty()) |
296 origin = GetDefaultOrigin(); | 316 origin = GetDefaultOrigin(); |
297 if (fallback_origin.empty()) | 317 if (fallback_origin.empty()) |
298 fallback_origin = GetDefaultDevFallbackOrigin(); | 318 fallback_origin = GetDefaultDevFallbackOrigin(); |
299 if (fallback_origin.empty()) | 319 if (fallback_origin.empty()) |
300 fallback_origin = GetDefaultFallbackOrigin(); | 320 fallback_origin = GetDefaultFallbackOrigin(); |
301 if (ssl_origin.empty()) | 321 if (ssl_origin.empty()) |
302 ssl_origin = GetDefaultSSLOrigin(); | 322 ssl_origin = GetDefaultSSLOrigin(); |
303 if (alt_origin.empty()) | 323 if (alt_origin.empty()) |
304 alt_origin = GetDefaultAltOrigin(); | 324 alt_origin = GetDefaultAltOrigin(); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
513 } | 533 } |
514 | 534 |
515 if (retry_delay) | 535 if (retry_delay) |
516 *retry_delay = found->second.current_delay; | 536 *retry_delay = found->second.current_delay; |
517 | 537 |
518 return true; | 538 return true; |
519 } | 539 } |
520 | 540 |
521 // TODO(kundaji): Remove tests for macro definitions. | 541 // TODO(kundaji): Remove tests for macro definitions. |
522 std::string DataReductionProxyParams::GetDefaultOrigin() const { | 542 std::string DataReductionProxyParams::GetDefaultOrigin() const { |
523 return kDefaultOrigin; | 543 return IsIncludedInUseQUICFieldTrial() && quic_enabled_for_proxies_ |
bengr
2015/02/10 20:18:31
Don't check the field trial here.
tbansal1
2015/02/10 22:24:38
see above.
| |
544 ? kDefaultQuicOrigin | |
545 : kDefaultSpdyOrigin; | |
524 } | 546 } |
525 | 547 |
526 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const { | 548 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const { |
527 return kDefaultFallbackOrigin; | 549 return kDefaultFallbackOrigin; |
528 } | 550 } |
529 | 551 |
530 std::string DataReductionProxyParams::GetDefaultSSLOrigin() const { | 552 std::string DataReductionProxyParams::GetDefaultSSLOrigin() const { |
531 return kDefaultSslOrigin; | 553 return kDefaultSslOrigin; |
532 } | 554 } |
533 | 555 |
534 std::string DataReductionProxyParams::GetDefaultAltOrigin() const { | 556 std::string DataReductionProxyParams::GetDefaultAltOrigin() const { |
535 return kDefaultAltOrigin; | 557 return kDefaultAltOrigin; |
536 } | 558 } |
537 | 559 |
538 std::string DataReductionProxyParams::GetDefaultAltFallbackOrigin() const { | 560 std::string DataReductionProxyParams::GetDefaultAltFallbackOrigin() const { |
539 return kDefaultAltFallbackOrigin; | 561 return kDefaultAltFallbackOrigin; |
540 } | 562 } |
541 | 563 |
542 std::string DataReductionProxyParams::GetDefaultProbeURL() const { | 564 std::string DataReductionProxyParams::GetDefaultProbeURL() const { |
543 return kDefaultProbeUrl; | 565 return kDefaultProbeUrl; |
544 } | 566 } |
545 | 567 |
546 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { | 568 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { |
547 return kDefaultWarmupUrl; | 569 return kDefaultWarmupUrl; |
548 } | 570 } |
549 | 571 |
550 } // namespace data_reduction_proxy | 572 } // namespace data_reduction_proxy |
OLD | NEW |