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