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

Side by Side Diff: components/data_reduction_proxy/core/common/data_reduction_proxy_params.cc

Issue 903213003: Enable QUIC for proxies based on Finch config and command line switch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment Created 5 years, 10 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 "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
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 return true; 116 return true;
114 } 117 }
115 return false; 118 return false;
116 } 119 }
117 120
118 // static 121 // static
119 bool DataReductionProxyParams::CanProxyURLScheme(const GURL& url) { 122 bool DataReductionProxyParams::CanProxyURLScheme(const GURL& url) {
120 return url.SchemeIs(url::kHttpScheme); 123 return url.SchemeIs(url::kHttpScheme);
121 } 124 }
122 125
126 // static
127 bool DataReductionProxyParams::IsIncludedInQuicFieldTrial() {
128 return FieldTrialList::FindFullName(kQuicFieldTrial) == kEnabled;
129 }
130
131 // static
132 std::string DataReductionProxyParams::GetQuicFieldTrialName() {
133 return kQuicFieldTrial;
134 }
135
136 void DataReductionProxyParams::EnableQuic(bool enable) {
137 quic_enabled_ = enable;
138 DCHECK(!quic_enabled_ || IsIncludedInQuicFieldTrial());
139 if (override_quic_origin_.empty() && quic_enabled_)
140 origin_ = net::ProxyServer::FromURI(kDefaultQuicOrigin,
141 net::ProxyServer::SCHEME_HTTP);
142 }
143
123 DataReductionProxyTypeInfo::DataReductionProxyTypeInfo() 144 DataReductionProxyTypeInfo::DataReductionProxyTypeInfo()
124 : proxy_servers(), 145 : proxy_servers(),
125 is_fallback(false), 146 is_fallback(false),
126 is_alternative(false), 147 is_alternative(false),
127 is_ssl(false) { 148 is_ssl(false) {
128 } 149 }
129 150
130 DataReductionProxyTypeInfo::~DataReductionProxyTypeInfo(){ 151 DataReductionProxyTypeInfo::~DataReductionProxyTypeInfo(){
131 } 152 }
132 153
133 DataReductionProxyParams::DataReductionProxyParams(int flags) 154 DataReductionProxyParams::DataReductionProxyParams(int flags)
134 : allowed_((flags & kAllowed) == kAllowed), 155 : allowed_((flags & kAllowed) == kAllowed),
135 fallback_allowed_((flags & kFallbackAllowed) == kFallbackAllowed), 156 fallback_allowed_((flags & kFallbackAllowed) == kFallbackAllowed),
136 alt_allowed_((flags & kAlternativeAllowed) == kAlternativeAllowed), 157 alt_allowed_((flags & kAlternativeAllowed) == kAlternativeAllowed),
137 alt_fallback_allowed_( 158 alt_fallback_allowed_(
138 (flags & kAlternativeFallbackAllowed) == kAlternativeFallbackAllowed), 159 (flags & kAlternativeFallbackAllowed) == kAlternativeFallbackAllowed),
139 promo_allowed_((flags & kPromoAllowed) == kPromoAllowed), 160 promo_allowed_((flags & kPromoAllowed) == kPromoAllowed),
140 holdback_((flags & kHoldback) == kHoldback), 161 holdback_((flags & kHoldback) == kHoldback),
162 quic_enabled_(false),
141 configured_on_command_line_(false) { 163 configured_on_command_line_(false) {
142 bool result = Init( 164 bool result = Init(
143 allowed_, fallback_allowed_, alt_allowed_, alt_fallback_allowed_); 165 allowed_, fallback_allowed_, alt_allowed_, alt_fallback_allowed_);
144 DCHECK(result); 166 DCHECK(result);
145 } 167 }
146 168
147 scoped_ptr<DataReductionProxyParams> DataReductionProxyParams::Clone() { 169 scoped_ptr<DataReductionProxyParams> DataReductionProxyParams::Clone() {
148 return scoped_ptr<DataReductionProxyParams>( 170 return scoped_ptr<DataReductionProxyParams>(
149 new DataReductionProxyParams(*this)); 171 new DataReductionProxyParams(*this));
150 } 172 }
151 173
152 DataReductionProxyParams::DataReductionProxyParams( 174 DataReductionProxyParams::DataReductionProxyParams(
153 const DataReductionProxyParams& other) 175 const DataReductionProxyParams& other)
154 : origin_(other.origin_), 176 : origin_(other.origin_),
155 fallback_origin_(other.fallback_origin_), 177 fallback_origin_(other.fallback_origin_),
156 ssl_origin_(other.ssl_origin_), 178 ssl_origin_(other.ssl_origin_),
157 alt_origin_(other.alt_origin_), 179 alt_origin_(other.alt_origin_),
158 alt_fallback_origin_(other.alt_fallback_origin_), 180 alt_fallback_origin_(other.alt_fallback_origin_),
159 probe_url_(other.probe_url_), 181 probe_url_(other.probe_url_),
160 warmup_url_(other.warmup_url_), 182 warmup_url_(other.warmup_url_),
161 allowed_(other.allowed_), 183 allowed_(other.allowed_),
162 fallback_allowed_(other.fallback_allowed_), 184 fallback_allowed_(other.fallback_allowed_),
163 alt_allowed_(other.alt_allowed_), 185 alt_allowed_(other.alt_allowed_),
164 alt_fallback_allowed_(other.alt_fallback_allowed_), 186 alt_fallback_allowed_(other.alt_fallback_allowed_),
165 promo_allowed_(other.promo_allowed_), 187 promo_allowed_(other.promo_allowed_),
166 holdback_(other.holdback_), 188 holdback_(other.holdback_),
189 quic_enabled_(other.quic_enabled_),
190 override_quic_origin_(other.override_quic_origin_),
167 configured_on_command_line_(other.configured_on_command_line_) { 191 configured_on_command_line_(other.configured_on_command_line_) {
168 } 192 }
169 193
170 DataReductionProxyParams::~DataReductionProxyParams() { 194 DataReductionProxyParams::~DataReductionProxyParams() {
171 } 195 }
172 196
173 DataReductionProxyParams::DataReductionProxyList 197 DataReductionProxyParams::DataReductionProxyList
174 DataReductionProxyParams::GetAllowedProxies() const { 198 DataReductionProxyParams::GetAllowedProxies() const {
175 DataReductionProxyList list; 199 DataReductionProxyList list;
176 if (allowed_) { 200 if (allowed_) {
(...skipping 12 matching lines...) Expand all
189 213
190 DataReductionProxyParams::DataReductionProxyParams(int flags, 214 DataReductionProxyParams::DataReductionProxyParams(int flags,
191 bool should_call_init) 215 bool should_call_init)
192 : allowed_((flags & kAllowed) == kAllowed), 216 : allowed_((flags & kAllowed) == kAllowed),
193 fallback_allowed_((flags & kFallbackAllowed) == kFallbackAllowed), 217 fallback_allowed_((flags & kFallbackAllowed) == kFallbackAllowed),
194 alt_allowed_((flags & kAlternativeAllowed) == kAlternativeAllowed), 218 alt_allowed_((flags & kAlternativeAllowed) == kAlternativeAllowed),
195 alt_fallback_allowed_( 219 alt_fallback_allowed_(
196 (flags & kAlternativeFallbackAllowed) == kAlternativeFallbackAllowed), 220 (flags & kAlternativeFallbackAllowed) == kAlternativeFallbackAllowed),
197 promo_allowed_((flags & kPromoAllowed) == kPromoAllowed), 221 promo_allowed_((flags & kPromoAllowed) == kPromoAllowed),
198 holdback_((flags & kHoldback) == kHoldback), 222 holdback_((flags & kHoldback) == kHoldback),
223 quic_enabled_(false),
199 configured_on_command_line_(false) { 224 configured_on_command_line_(false) {
200 if (should_call_init) { 225 if (should_call_init) {
201 bool result = Init( 226 bool result = Init(
202 allowed_, fallback_allowed_, alt_allowed_, alt_fallback_allowed_); 227 allowed_, fallback_allowed_, alt_allowed_, alt_fallback_allowed_);
203 DCHECK(result); 228 DCHECK(result);
204 } 229 }
205 } 230 }
206 231
207 bool DataReductionProxyParams::Init(bool allowed, 232 bool DataReductionProxyParams::Init(bool allowed,
208 bool fallback_allowed, 233 bool fallback_allowed,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 332
308 std::string probe_url = command_line.GetSwitchValueASCII( 333 std::string probe_url = command_line.GetSwitchValueASCII(
309 switches::kDataReductionProxyProbeURL); 334 switches::kDataReductionProxyProbeURL);
310 std::string warmup_url = command_line.GetSwitchValueASCII( 335 std::string warmup_url = command_line.GetSwitchValueASCII(
311 switches::kDataReductionProxyWarmupURL); 336 switches::kDataReductionProxyWarmupURL);
312 337
313 // Set from preprocessor constants those params that are not specified on the 338 // Set from preprocessor constants those params that are not specified on the
314 // command line. 339 // command line.
315 if (origin.empty()) 340 if (origin.empty())
316 origin = GetDefaultDevOrigin(); 341 origin = GetDefaultDevOrigin();
342 override_quic_origin_ = origin;
317 if (origin.empty()) 343 if (origin.empty())
318 origin = GetDefaultOrigin(); 344 origin = GetDefaultOrigin();
319 if (fallback_origin.empty()) 345 if (fallback_origin.empty())
320 fallback_origin = GetDefaultDevFallbackOrigin(); 346 fallback_origin = GetDefaultDevFallbackOrigin();
321 if (fallback_origin.empty()) 347 if (fallback_origin.empty())
322 fallback_origin = GetDefaultFallbackOrigin(); 348 fallback_origin = GetDefaultFallbackOrigin();
323 if (ssl_origin.empty()) 349 if (ssl_origin.empty())
324 ssl_origin = GetDefaultSSLOrigin(); 350 ssl_origin = GetDefaultSSLOrigin();
325 if (alt_origin.empty()) 351 if (alt_origin.empty())
326 alt_origin = GetDefaultAltOrigin(); 352 alt_origin = GetDefaultAltOrigin();
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 } 561 }
536 562
537 if (retry_delay) 563 if (retry_delay)
538 *retry_delay = found->second.current_delay; 564 *retry_delay = found->second.current_delay;
539 565
540 return true; 566 return true;
541 } 567 }
542 568
543 // TODO(kundaji): Remove tests for macro definitions. 569 // TODO(kundaji): Remove tests for macro definitions.
544 std::string DataReductionProxyParams::GetDefaultOrigin() const { 570 std::string DataReductionProxyParams::GetDefaultOrigin() const {
545 return kDefaultOrigin; 571 return quic_enabled_ ?
572 kDefaultQuicOrigin : kDefaultSpdyOrigin;
546 } 573 }
547 574
548 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const { 575 std::string DataReductionProxyParams::GetDefaultFallbackOrigin() const {
549 return kDefaultFallbackOrigin; 576 return kDefaultFallbackOrigin;
550 } 577 }
551 578
552 std::string DataReductionProxyParams::GetDefaultSSLOrigin() const { 579 std::string DataReductionProxyParams::GetDefaultSSLOrigin() const {
553 return kDefaultSslOrigin; 580 return kDefaultSslOrigin;
554 } 581 }
555 582
556 std::string DataReductionProxyParams::GetDefaultAltOrigin() const { 583 std::string DataReductionProxyParams::GetDefaultAltOrigin() const {
557 return kDefaultAltOrigin; 584 return kDefaultAltOrigin;
558 } 585 }
559 586
560 std::string DataReductionProxyParams::GetDefaultAltFallbackOrigin() const { 587 std::string DataReductionProxyParams::GetDefaultAltFallbackOrigin() const {
561 return kDefaultAltFallbackOrigin; 588 return kDefaultAltFallbackOrigin;
562 } 589 }
563 590
564 std::string DataReductionProxyParams::GetDefaultProbeURL() const { 591 std::string DataReductionProxyParams::GetDefaultProbeURL() const {
565 return kDefaultProbeUrl; 592 return kDefaultProbeUrl;
566 } 593 }
567 594
568 std::string DataReductionProxyParams::GetDefaultWarmupURL() const { 595 std::string DataReductionProxyParams::GetDefaultWarmupURL() const {
569 return kDefaultWarmupUrl; 596 return kDefaultWarmupUrl;
570 } 597 }
571 598
572 } // namespace data_reduction_proxy 599 } // namespace data_reduction_proxy
OLDNEW
« no previous file with comments | « components/data_reduction_proxy/core/common/data_reduction_proxy_params.h ('k') | net/http/http_network_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698