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/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/browser/data_reduction_proxy_usage_sta
ts.h" | 10 #include "components/data_reduction_proxy/browser/data_reduction_proxy_usage_sta
ts.h" |
11 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" | 11 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" |
12 #include "net/base/load_flags.h" | 12 #include "net/base/load_flags.h" |
13 #include "net/http/http_response_headers.h" | 13 #include "net/http/http_response_headers.h" |
| 14 #include "net/proxy/proxy_config.h" |
14 #include "net/proxy/proxy_info.h" | 15 #include "net/proxy/proxy_info.h" |
15 #include "net/proxy/proxy_list.h" | 16 #include "net/proxy/proxy_list.h" |
| 17 #include "net/proxy/proxy_retry_info.h" |
16 #include "net/proxy/proxy_server.h" | 18 #include "net/proxy/proxy_server.h" |
17 #include "net/proxy/proxy_service.h" | 19 #include "net/proxy/proxy_service.h" |
18 #include "net/url_request/url_request.h" | 20 #include "net/url_request/url_request.h" |
19 #include "net/url_request/url_request_context.h" | 21 #include "net/url_request/url_request_context.h" |
20 #include "url/gurl.h" | 22 #include "url/gurl.h" |
21 | 23 |
22 namespace { | 24 namespace { |
23 | 25 |
24 bool SetProxyServerFromGURL(const GURL& gurl, | 26 bool SetProxyServerFromGURL(const GURL& gurl, |
25 net::ProxyServer* proxy_server) { | 27 net::ProxyServer* proxy_server) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 return false; | 97 return false; |
96 | 98 |
97 OverrideResponseAsRedirect(request, | 99 OverrideResponseAsRedirect(request, |
98 original_response_headers, | 100 original_response_headers, |
99 override_response_headers); | 101 override_response_headers); |
100 return true; | 102 return true; |
101 } | 103 } |
102 | 104 |
103 void OnResolveProxyHandler(const GURL& url, | 105 void OnResolveProxyHandler(const GURL& url, |
104 int load_flags, | 106 int load_flags, |
| 107 const net::ProxyConfig& data_reduction_proxy_config, |
| 108 const net::ProxyRetryInfoMap& proxy_retry_info, |
105 const DataReductionProxyParams* params, | 109 const DataReductionProxyParams* params, |
106 net::ProxyInfo* result) { | 110 net::ProxyInfo* result) { |
| 111 if (data_reduction_proxy_config.is_valid() && |
| 112 result->proxy_server().is_direct()) { |
| 113 net::ProxyInfo data_reduction_proxy_info; |
| 114 data_reduction_proxy_config.proxy_rules().Apply( |
| 115 url, &data_reduction_proxy_info); |
| 116 data_reduction_proxy_info.DeprioritizeBadProxies(proxy_retry_info); |
| 117 result->Use(data_reduction_proxy_info); |
| 118 } |
| 119 |
107 if ((load_flags & net::LOAD_BYPASS_DATA_REDUCTION_PROXY) && | 120 if ((load_flags & net::LOAD_BYPASS_DATA_REDUCTION_PROXY) && |
108 DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial() && | 121 DataReductionProxyParams::IsIncludedInCriticalPathBypassFieldTrial() && |
109 !result->is_empty() && | 122 !result->is_empty() && |
110 !result->is_direct() && | 123 !result->is_direct() && |
111 params && | 124 params && |
112 params->IsDataReductionProxy( | 125 params->IsDataReductionProxy( |
113 result->proxy_server().host_port_pair(), NULL)) { | 126 result->proxy_server().host_port_pair(), NULL)) { |
114 result->UseDirect(); | 127 result->UseDirect(); |
115 } | 128 } |
116 } | 129 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 net::ProxyService* proxy_service = request->context()->proxy_service(); | 187 net::ProxyService* proxy_service = request->context()->proxy_service(); |
175 DCHECK(proxy_service); | 188 DCHECK(proxy_service); |
176 | 189 |
177 proxy_service->MarkProxiesAsBadUntil(proxy_info, | 190 proxy_service->MarkProxiesAsBadUntil(proxy_info, |
178 bypass_duration, | 191 bypass_duration, |
179 fallback, | 192 fallback, |
180 request->net_log()); | 193 request->net_log()); |
181 } | 194 } |
182 | 195 |
183 } // namespace data_reduction_proxy | 196 } // namespace data_reduction_proxy |
OLD | NEW |