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

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 bengr's feedback 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
21 namespace { 22 namespace {
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));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // Only retry idempotent methods. 79 // Only retry idempotent methods.
79 if (!IsRequestIdempotent(request)) 80 if (!IsRequestIdempotent(request))
80 return false; 81 return false;
81 82
82 OverrideResponseAsRedirect(request, 83 OverrideResponseAsRedirect(request,
83 original_response_headers, 84 original_response_headers,
84 override_response_headers); 85 override_response_headers);
85 return true; 86 return true;
86 } 87 }
87 88
88 89 void OnResolveProxyHandler(const GURL& url,
90 int load_flags,
91 const DataReductionProxyParams* params,
92 net::ProxyInfo* result) {
93 if ((load_flags & net::LOAD_BYPASS_DATA_REDUCTION_PROXY) &&
94 DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial() &&
95 !result->is_empty() &&
96 !result->is_direct() &&
97 params &&
98 params->IsDataReductionProxy(
99 result->proxy_server().host_port_pair(), NULL)) {
100 result->UseDirect();
101 }
102 }
89 103
90 bool IsRequestIdempotent(const net::URLRequest* request) { 104 bool IsRequestIdempotent(const net::URLRequest* request) {
91 DCHECK(request); 105 DCHECK(request);
92 if (request->method() == "GET" || 106 if (request->method() == "GET" ||
93 request->method() == "OPTIONS" || 107 request->method() == "OPTIONS" ||
94 request->method() == "HEAD" || 108 request->method() == "HEAD" ||
95 request->method() == "PUT" || 109 request->method() == "PUT" ||
96 request->method() == "DELETE" || 110 request->method() == "DELETE" ||
97 request->method() == "TRACE") 111 request->method() == "TRACE")
98 return true; 112 return true;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 net::ProxyService* proxy_service = request->context()->proxy_service(); 160 net::ProxyService* proxy_service = request->context()->proxy_service();
147 DCHECK(proxy_service); 161 DCHECK(proxy_service);
148 162
149 proxy_service->MarkProxiesAsBadUntil(proxy_info, 163 proxy_service->MarkProxiesAsBadUntil(proxy_info,
150 bypass_duration, 164 bypass_duration,
151 fallback, 165 fallback,
152 request->net_log()); 166 request->net_log());
153 } 167 }
154 168
155 } // namespace data_reduction_proxy 169 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698