| 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/core/browser/data_reduction_proxy_inte
rceptor.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_inte
rceptor.h" |
| 6 | 6 |
| 7 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypa
ss_protocol.h" | 7 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypa
ss_protocol.h" |
| 8 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_usag
e_stats.h" | 8 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypa
ss_stats.h" |
| 9 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" | 9 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" |
| 10 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
| 11 #include "net/url_request/url_request.h" | 11 #include "net/url_request/url_request.h" |
| 12 #include "net/url_request/url_request_context.h" | 12 #include "net/url_request/url_request_context.h" |
| 13 #include "net/url_request/url_request_http_job.h" | 13 #include "net/url_request/url_request_http_job.h" |
| 14 #include "net/url_request/url_request_job_manager.h" | 14 #include "net/url_request/url_request_job_manager.h" |
| 15 #include "url/url_constants.h" | 15 #include "url/url_constants.h" |
| 16 | 16 |
| 17 namespace data_reduction_proxy { | 17 namespace data_reduction_proxy { |
| 18 | 18 |
| 19 DataReductionProxyInterceptor::DataReductionProxyInterceptor( | 19 DataReductionProxyInterceptor::DataReductionProxyInterceptor( |
| 20 DataReductionProxyConfig* config, | 20 DataReductionProxyConfig* config, |
| 21 DataReductionProxyUsageStats* stats, | 21 DataReductionProxyBypassStats* stats, |
| 22 DataReductionProxyEventStore* event_store) | 22 DataReductionProxyEventStore* event_store) |
| 23 : usage_stats_(stats), | 23 : bypass_stats_(stats), |
| 24 bypass_protocol_( | 24 bypass_protocol_( |
| 25 new DataReductionProxyBypassProtocol(config, event_store)) { | 25 new DataReductionProxyBypassProtocol(config, event_store)) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 DataReductionProxyInterceptor::~DataReductionProxyInterceptor() { | 28 DataReductionProxyInterceptor::~DataReductionProxyInterceptor() { |
| 29 } | 29 } |
| 30 | 30 |
| 31 net::URLRequestJob* DataReductionProxyInterceptor::MaybeInterceptRequest( | 31 net::URLRequestJob* DataReductionProxyInterceptor::MaybeInterceptRequest( |
| 32 net::URLRequest* request, | 32 net::URLRequest* request, |
| 33 net::NetworkDelegate* network_delegate) const { | 33 net::NetworkDelegate* network_delegate) const { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 49 | 49 |
| 50 net::URLRequestJob* | 50 net::URLRequestJob* |
| 51 DataReductionProxyInterceptor::MaybeInterceptResponseOrRedirect( | 51 DataReductionProxyInterceptor::MaybeInterceptResponseOrRedirect( |
| 52 net::URLRequest* request, | 52 net::URLRequest* request, |
| 53 net::NetworkDelegate* network_delegate) const { | 53 net::NetworkDelegate* network_delegate) const { |
| 54 if (request->response_info().was_cached) | 54 if (request->response_info().was_cached) |
| 55 return nullptr; | 55 return nullptr; |
| 56 DataReductionProxyBypassType bypass_type = BYPASS_EVENT_TYPE_MAX; | 56 DataReductionProxyBypassType bypass_type = BYPASS_EVENT_TYPE_MAX; |
| 57 bool should_retry = bypass_protocol_->MaybeBypassProxyAndPrepareToRetry( | 57 bool should_retry = bypass_protocol_->MaybeBypassProxyAndPrepareToRetry( |
| 58 request, &bypass_type); | 58 request, &bypass_type); |
| 59 if (usage_stats_ && bypass_type != BYPASS_EVENT_TYPE_MAX) | 59 if (bypass_stats_ && bypass_type != BYPASS_EVENT_TYPE_MAX) |
| 60 usage_stats_->SetBypassType(bypass_type); | 60 bypass_stats_->SetBypassType(bypass_type); |
| 61 if (!should_retry) | 61 if (!should_retry) |
| 62 return nullptr; | 62 return nullptr; |
| 63 // Returning non-NULL has the effect of restarting the request with the | 63 // Returning non-NULL has the effect of restarting the request with the |
| 64 // supplied job. | 64 // supplied job. |
| 65 DCHECK(request->url().SchemeIs(url::kHttpScheme)); | 65 DCHECK(request->url().SchemeIs(url::kHttpScheme)); |
| 66 return net::URLRequestJobManager::GetInstance()->CreateJob( | 66 return net::URLRequestJobManager::GetInstance()->CreateJob( |
| 67 request, network_delegate); | 67 request, network_delegate); |
| 68 } | 68 } |
| 69 | 69 |
| 70 } // namespace data_reduction_proxy | 70 } // namespace data_reduction_proxy |
| OLD | NEW |