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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_protocol.cc

Issue 332313003: Add Finch experiment for selectively bypassing proxies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address mmenke's feedback R2 Created 6 years, 5 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/browser/data_reduction_proxy_protocol. h" 5 #include "components/data_reduction_proxy/browser/data_reduction_proxy_protocol. h"
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" 9 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h"
10 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" 10 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h"
11 #include "net/base/load_flags.h" 11 #include "net/base/load_flags.h"
12 #include "net/http/http_response_headers.h" 12 #include "net/http/http_response_headers.h"
13 #include "net/proxy/proxy_info.h" 13 #include "net/proxy/proxy_info.h"
14 #include "net/proxy/proxy_list.h" 14 #include "net/proxy/proxy_list.h"
15 #include "net/proxy/proxy_server.h" 15 #include "net/proxy/proxy_server.h"
16 #include "net/proxy/proxy_service.h" 16 #include "net/proxy/proxy_service.h"
17 #include "net/url_request/url_request.h" 17 #include "net/url_request/url_request.h"
18 #include "net/url_request/url_request_context.h" 18 #include "net/url_request/url_request_context.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 20
21 namespace { 21 namespace {
22
22 bool SetProxyServerFromGURL(const GURL& gurl, 23 bool SetProxyServerFromGURL(const GURL& gurl,
23 net::ProxyServer* proxy_server) { 24 net::ProxyServer* proxy_server) {
24 DCHECK(proxy_server); 25 DCHECK(proxy_server);
25 if (!gurl.SchemeIsHTTPOrHTTPS()) 26 if (!gurl.SchemeIsHTTPOrHTTPS())
26 return false; 27 return false;
27 *proxy_server = net::ProxyServer(gurl.SchemeIs("http") ? 28 *proxy_server = net::ProxyServer(gurl.SchemeIs("http") ?
28 net::ProxyServer::SCHEME_HTTP : 29 net::ProxyServer::SCHEME_HTTP :
29 net::ProxyServer::SCHEME_HTTPS, 30 net::ProxyServer::SCHEME_HTTPS,
30 net::HostPortPair::FromURL(gurl)); 31 net::HostPortPair::FromURL(gurl));
31 return true; 32 return true;
32 } 33 }
34
33 } // namespace 35 } // namespace
34 36
35 namespace data_reduction_proxy { 37 namespace data_reduction_proxy {
36 38
37 bool MaybeBypassProxyAndPrepareToRetry( 39 bool MaybeBypassProxyAndPrepareToRetry(
38 const DataReductionProxyParams* data_reduction_proxy_params, 40 const DataReductionProxyParams* data_reduction_proxy_params,
39 net::URLRequest* request, 41 net::URLRequest* request,
40 const net::HttpResponseHeaders* original_response_headers, 42 const net::HttpResponseHeaders* original_response_headers,
41 scoped_refptr<net::HttpResponseHeaders>* override_response_headers) { 43 scoped_refptr<net::HttpResponseHeaders>* override_response_headers) {
42 if (!data_reduction_proxy_params) 44 if (!data_reduction_proxy_params)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Only retry idempotent methods. 80 // Only retry idempotent methods.
79 if (!IsRequestIdempotent(request)) 81 if (!IsRequestIdempotent(request))
80 return false; 82 return false;
81 83
82 OverrideResponseAsRedirect(request, 84 OverrideResponseAsRedirect(request,
83 original_response_headers, 85 original_response_headers,
84 override_response_headers); 86 override_response_headers);
85 return true; 87 return true;
86 } 88 }
87 89
88 90 void OnResolveProxyHandler(const GURL& url,
91 int load_flags,
92 const DataReductionProxyParams* params,
93 net::ProxyInfo* result) {
94 if ((load_flags & net::LOAD_BYPASS_DATA_REDUCTION_PROXY) &&
95 DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial() &&
96 !result->is_empty() &&
97 !result->is_direct() &&
98 params &&
99 params->IsDataReductionProxy(
100 result->proxy_server().host_port_pair(), NULL)) {
101 result->UseDirect();
102 }
103 }
89 104
90 bool IsRequestIdempotent(const net::URLRequest* request) { 105 bool IsRequestIdempotent(const net::URLRequest* request) {
91 DCHECK(request); 106 DCHECK(request);
92 if (request->method() == "GET" || 107 if (request->method() == "GET" ||
93 request->method() == "OPTIONS" || 108 request->method() == "OPTIONS" ||
94 request->method() == "HEAD" || 109 request->method() == "HEAD" ||
95 request->method() == "PUT" || 110 request->method() == "PUT" ||
96 request->method() == "DELETE" || 111 request->method() == "DELETE" ||
97 request->method() == "TRACE") 112 request->method() == "TRACE")
98 return true; 113 return true;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 net::ProxyService* proxy_service = request->context()->proxy_service(); 161 net::ProxyService* proxy_service = request->context()->proxy_service();
147 DCHECK(proxy_service); 162 DCHECK(proxy_service);
148 163
149 proxy_service->MarkProxiesAsBadUntil(proxy_info, 164 proxy_service->MarkProxiesAsBadUntil(proxy_info,
150 bypass_duration, 165 bypass_duration,
151 fallback, 166 fallback,
152 request->net_log()); 167 request->net_log());
153 } 168 }
154 169
155 } // namespace data_reduction_proxy 170 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698