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

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: callback design (not yet done) 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 #include "webkit/common/resource_type.h"
21
20 22
21 namespace { 23 namespace {
22 bool SetProxyServerFromGURL(const GURL& gurl, 24 bool SetProxyServerFromGURL(const GURL& gurl,
23 net::ProxyServer* proxy_server) { 25 net::ProxyServer* proxy_server) {
24 DCHECK(proxy_server); 26 DCHECK(proxy_server);
25 if (!gurl.SchemeIsHTTPOrHTTPS()) 27 if (!gurl.SchemeIsHTTPOrHTTPS())
26 return false; 28 return false;
27 *proxy_server = net::ProxyServer(gurl.SchemeIs("http") ? 29 *proxy_server = net::ProxyServer(gurl.SchemeIs("http") ?
28 net::ProxyServer::SCHEME_HTTP : 30 net::ProxyServer::SCHEME_HTTP :
29 net::ProxyServer::SCHEME_HTTPS, 31 net::ProxyServer::SCHEME_HTTPS,
(...skipping 48 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
90 int BuildLoadFlagsForRequest(ResourceType::Type resource_type) {
91 int flags = 0;
92 if (DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial() &&
93 resource_type != ResourceType::IMAGE)
94 flags |= net::LOAD_BYPASS_DATA_REDUCTION_PROXY;
95 return flags;
96 }
88 97
98 void OnResolveProxyHandler(const GURL& url, int load_flags,
99 net::ProxyInfo* result) {
100 if ((load_flags & net::LOAD_BYPASS_DATA_REDUCTION_PROXY) &&
101 !result->is_direct() &&
102 result->proxy_server().isDataReductionProxy()) {
103 result->UseDirect();
104 }
105 }
89 106
90 bool IsRequestIdempotent(const net::URLRequest* request) { 107 bool IsRequestIdempotent(const net::URLRequest* request) {
91 DCHECK(request); 108 DCHECK(request);
92 if (request->method() == "GET" || 109 if (request->method() == "GET" ||
93 request->method() == "OPTIONS" || 110 request->method() == "OPTIONS" ||
94 request->method() == "HEAD" || 111 request->method() == "HEAD" ||
95 request->method() == "PUT" || 112 request->method() == "PUT" ||
96 request->method() == "DELETE" || 113 request->method() == "DELETE" ||
97 request->method() == "TRACE") 114 request->method() == "TRACE")
98 return true; 115 return true;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 net::ProxyService* proxy_service = request->context()->proxy_service(); 163 net::ProxyService* proxy_service = request->context()->proxy_service();
147 DCHECK(proxy_service); 164 DCHECK(proxy_service);
148 165
149 proxy_service->MarkProxiesAsBadUntil(proxy_info, 166 proxy_service->MarkProxiesAsBadUntil(proxy_info,
150 bypass_duration, 167 bypass_duration,
151 fallback, 168 fallback,
152 request->net_log()); 169 request->net_log());
153 } 170 }
154 171
155 } // namespace data_reduction_proxy 172 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698