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"; |
44 const char kDefaultWarmupUrl[] = "http://www.gstatic.com/generate_204"; | 45 const char kDefaultWarmupUrl[] = "http://www.gstatic.com/generate_204"; |
45 | 46 |
46 const char kAndroidOneIdentifier[] = "sprout"; | 47 const char kAndroidOneIdentifier[] = "sprout"; |
48 | |
49 const char kQuicFieldTrial[] = "DataReductionProxyUseQuic"; | |
47 } // namespace | 50 } // namespace |
48 | 51 |
49 namespace data_reduction_proxy { | 52 namespace data_reduction_proxy { |
50 | 53 |
51 // static | 54 // static |
52 bool DataReductionProxyParams::IsIncludedInAlternativeFieldTrial() { | 55 bool DataReductionProxyParams::IsIncludedInAlternativeFieldTrial() { |
53 const std::string group_name = base::FieldTrialList::FindFullName( | 56 const std::string group_name = base::FieldTrialList::FindFullName( |
54 "DataCompressionProxyAlternativeConfiguration"); | 57 "DataCompressionProxyAlternativeConfiguration"); |
55 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 58 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
56 data_reduction_proxy::switches::kEnableDataReductionProxyAlt)) { | 59 data_reduction_proxy::switches::kEnableDataReductionProxyAlt)) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 "DataReductionProxyRemoveMissingViaHeaderOtherBypass") == "Relaxed"; | 94 "DataReductionProxyRemoveMissingViaHeaderOtherBypass") == "Relaxed"; |
92 } | 95 } |
93 | 96 |
94 // static | 97 // static |
95 bool DataReductionProxyParams::IsIncludedInAndroidOnePromoFieldTrial( | 98 bool DataReductionProxyParams::IsIncludedInAndroidOnePromoFieldTrial( |
96 const char* build_fingerprint) { | 99 const char* build_fingerprint) { |
97 base::StringPiece fingerprint(build_fingerprint); | 100 base::StringPiece fingerprint(build_fingerprint); |
98 return (fingerprint.find(kAndroidOneIdentifier) != std::string::npos); | 101 return (fingerprint.find(kAndroidOneIdentifier) != std::string::npos); |
99 } | 102 } |
100 | 103 |
104 // static | |
105 bool DataReductionProxyParams::IsIncludedInQuicFieldTrial() { | |
106 return FieldTrialList::FindFullName(kQuicFieldTrial) == kEnabled; | |
107 } | |
108 | |
109 // static | |
110 std::string DataReductionProxyParams::GetQuicFieldTrialName() { | |
111 return kQuicFieldTrial; | |
112 } | |
113 | |
114 void DataReductionProxyParams::EnableQuic(bool enable) { | |
115 quic_enabled_ = enable; | |
116 if (command_line_origin_.empty() && IsIncludedInQuicFieldTrial() && | |
bengr
2015/02/12 17:14:46
I thought I commented on this but maybe I didn't.
tbansal1
2015/02/13 17:10:40
Done.
| |
117 quic_enabled_) | |
118 origin_ = net::ProxyServer::FromURI(kDefaultQuicOrigin, | |
119 net::ProxyServer::SCHEME_HTTP); | |
120 } | |
121 | |
101 DataReductionProxyTypeInfo::DataReductionProxyTypeInfo() | 122 DataReductionProxyTypeInfo::DataReductionProxyTypeInfo() |
102 : proxy_servers(), | 123 : proxy_servers(), |
103 is_fallback(false), | 124 is_fallback(false), |
104 is_alternative(false), | 125 is_alternative(false), |
105 is_ssl(false) { | 126 is_ssl(false) { |
106 } | 127 } |
107 | 128 |
108 DataReductionProxyTypeInfo::~DataReductionProxyTypeInfo(){ | 129 DataReductionProxyTypeInfo::~DataReductionProxyTypeInfo(){ |
109 } | 130 } |
110 | 131 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 | 306 |
286 std::string probe_url = command_line.GetSwitchValueASCII( | 307 std::string probe_url = command_line.GetSwitchValueASCII( |
287 switches::kDataReductionProxyProbeURL); | 308 switches::kDataReductionProxyProbeURL); |
288 std::string warmup_url = command_line.GetSwitchValueASCII( | 309 std::string warmup_url = command_line.GetSwitchValueASCII( |
289 switches::kDataReductionProxyWarmupURL); | 310 switches::kDataReductionProxyWarmupURL); |
290 | 311 |
291 // Set from preprocessor constants those params that are not specified on the | 312 // Set from preprocessor constants those params that are not specified on the |
292 // command line. | 313 // command line. |
293 if (origin.empty()) | 314 if (origin.empty()) |
294 origin = GetDefaultDevOrigin(); | 315 origin = GetDefaultDevOrigin(); |
316 command_line_origin_ = origin; | |
295 if (origin.empty()) | 317 if (origin.empty()) |
296 origin = GetDefaultOrigin(); | 318 origin = GetDefaultOrigin(); |
297 if (fallback_origin.empty()) | 319 if (fallback_origin.empty()) |
298 fallback_origin = GetDefaultDevFallbackOrigin(); | 320 fallback_origin = GetDefaultDevFallbackOrigin(); |
299 if (fallback_origin.empty()) | 321 if (fallback_origin.empty()) |
300 fallback_origin = GetDefaultFallbackOrigin(); | 322 fallback_origin = GetDefaultFallbackOrigin(); |
301 if (ssl_origin.empty()) | 323 if (ssl_origin.empty()) |
302 ssl_origin = GetDefaultSSLOrigin(); | 324 ssl_origin = GetDefaultSSLOrigin(); |
303 if (alt_origin.empty()) | 325 if (alt_origin.empty()) |
304 alt_origin = GetDefaultAltOrigin(); | 326 alt_origin = GetDefaultAltOrigin(); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
513 } | 535 } |
514 | 536 |
515 if (retry_delay) | 537 if (retry_delay) |
516 *retry_delay = found->second.current_delay; | 538 *retry_delay = found->second.current_delay; |
517 | 539 |
518 return true; | 540 return true; |
519 } | 541 } |
520 | 542 |
521 // TODO(kundaji): Remove tests for macro definitions. | 543 // TODO(kundaji): Remove tests for macro definitions. |
522 std::string DataReductionProxyParams::GetDefaultOrigin() const { | 544 std::string DataReductionProxyParams::GetDefaultOrigin() const { |
523 return kDefaultOrigin; | 545 return IsIncludedInQuicFieldTrial() && quic_enabled_ ? |
bengr
2015/02/12 17:14:46
Likewise here, the quic origin should be return un
tbansal1
2015/02/13 17:10:40
Done.
| |
546 kDefaultQuicOrigin : kDefaultSpdyOrigin; | |
524 } | 547 } |
525 | 548 |
526 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const { | 549 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const { |
527 return kDefaultFallbackOrigin; | 550 return kDefaultFallbackOrigin; |
528 } | 551 } |
529 | 552 |
530 std::string DataReductionProxyParams::GetDefaultSSLOrigin() const { | 553 std::string DataReductionProxyParams::GetDefaultSSLOrigin() const { |
531 return kDefaultSslOrigin; | 554 return kDefaultSslOrigin; |
532 } | 555 } |
533 | 556 |
534 std::string DataReductionProxyParams::GetDefaultAltOrigin() const { | 557 std::string DataReductionProxyParams::GetDefaultAltOrigin() const { |
535 return kDefaultAltOrigin; | 558 return kDefaultAltOrigin; |
536 } | 559 } |
537 | 560 |
538 std::string DataReductionProxyParams::GetDefaultAltFallbackOrigin() const { | 561 std::string DataReductionProxyParams::GetDefaultAltFallbackOrigin() const { |
539 return kDefaultAltFallbackOrigin; | 562 return kDefaultAltFallbackOrigin; |
540 } | 563 } |
541 | 564 |
542 std::string DataReductionProxyParams::GetDefaultProbeURL() const { | 565 std::string DataReductionProxyParams::GetDefaultProbeURL() const { |
543 return kDefaultProbeUrl; | 566 return kDefaultProbeUrl; |
544 } | 567 } |
545 | 568 |
546 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { | 569 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { |
547 return kDefaultWarmupUrl; | 570 return kDefaultWarmupUrl; |
548 } | 571 } |
549 | 572 |
550 } // namespace data_reduction_proxy | 573 } // namespace data_reduction_proxy |
OLD | NEW |