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/common/data_reduction_proxy_headers.h" | 10 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
29 net::ProxyServer::SCHEME_HTTPS, | 29 net::ProxyServer::SCHEME_HTTPS, |
30 net::HostPortPair::FromURL(gurl)); | 30 net::HostPortPair::FromURL(gurl)); |
31 return true; | 31 return true; |
32 } | 32 } |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 namespace data_reduction_proxy { | 35 namespace data_reduction_proxy { |
36 | 36 |
37 bool MaybeBypassProxyAndPrepareToRetry( | 37 bool MaybeBypassProxyAndPrepareToRetry( |
38 const DataReductionProxyParams* data_reduction_proxy_params, | 38 const DataReductionProxyParams* data_reduction_proxy_params, |
39 DataReductionProxyUsageStats* usage_stats, | |
39 net::URLRequest* request, | 40 net::URLRequest* request, |
40 const net::HttpResponseHeaders* original_response_headers, | 41 const net::HttpResponseHeaders* original_response_headers, |
41 scoped_refptr<net::HttpResponseHeaders>* override_response_headers) { | 42 scoped_refptr<net::HttpResponseHeaders>* override_response_headers) { |
42 if (!data_reduction_proxy_params) | 43 if (!data_reduction_proxy_params) |
43 return false; | 44 return false; |
44 std::pair<GURL, GURL> data_reduction_proxies; | 45 std::pair<GURL, GURL> data_reduction_proxies; |
45 if (!data_reduction_proxy_params->WasDataReductionProxyUsed( | 46 if (!data_reduction_proxy_params->WasDataReductionProxyUsed( |
46 request, &data_reduction_proxies)) { | 47 request, &data_reduction_proxies)) { |
47 return false; | 48 return false; |
48 } | 49 } |
49 | 50 |
50 // Empty implies either that the request was served from cache or that | 51 // Empty implies either that the request was served from cache or that |
51 // request was served directly from the origin. | 52 // request was served directly from the origin. |
52 if (request->proxy_server().IsEmpty()) | 53 if (request->proxy_server().IsEmpty()) |
53 return false; | 54 return false; |
54 | 55 |
55 if (data_reduction_proxies.first.is_empty()) | 56 if (data_reduction_proxies.first.is_empty()) |
56 return false; | 57 return false; |
57 | 58 |
58 DataReductionProxyInfo data_reduction_proxy_info; | 59 DataReductionProxyInfo data_reduction_proxy_info; |
59 net::ProxyService::DataReductionProxyBypassType bypass_type = | 60 net::ProxyService::DataReductionProxyBypassType bypass_type = |
60 GetDataReductionProxyBypassType( | 61 GetDataReductionProxyBypassType(original_response_headers, |
61 original_response_headers, &data_reduction_proxy_info); | 62 &data_reduction_proxy_info); |
63 usage_stats->SetBypassType(bypass_type); | |
bengr
2014/07/12 00:11:59
I would move this outside of MaybeBypassProxyAndPr
megjablon
2014/07/14 19:06:41
Done.
| |
62 if (bypass_type == net::ProxyService::BYPASS_EVENT_TYPE_MAX) { | 64 if (bypass_type == net::ProxyService::BYPASS_EVENT_TYPE_MAX) { |
63 return false; | 65 return false; |
64 } | 66 } |
65 | 67 |
66 DCHECK(request->context()); | 68 DCHECK(request->context()); |
67 DCHECK(request->context()->proxy_service()); | 69 DCHECK(request->context()->proxy_service()); |
68 net::ProxyServer proxy_server; | 70 net::ProxyServer proxy_server; |
69 SetProxyServerFromGURL(data_reduction_proxies.first, &proxy_server); | 71 SetProxyServerFromGURL(data_reduction_proxies.first, &proxy_server); |
70 request->context()->proxy_service()->RecordDataReductionProxyBypassInfo( | 72 request->context()->proxy_service()->RecordDataReductionProxyBypassInfo( |
71 !data_reduction_proxies.second.is_empty(), | 73 !data_reduction_proxies.second.is_empty(), |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 net::ProxyService* proxy_service = request->context()->proxy_service(); | 151 net::ProxyService* proxy_service = request->context()->proxy_service(); |
150 DCHECK(proxy_service); | 152 DCHECK(proxy_service); |
151 | 153 |
152 proxy_service->MarkProxiesAsBadUntil(proxy_info, | 154 proxy_service->MarkProxiesAsBadUntil(proxy_info, |
153 bypass_duration, | 155 bypass_duration, |
154 fallback, | 156 fallback, |
155 request->net_log()); | 157 request->net_log()); |
156 } | 158 } |
157 | 159 |
158 } // namespace data_reduction_proxy | 160 } // namespace data_reduction_proxy |
OLD | NEW |