Chromium Code Reviews| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc |
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc |
| index cbf79c38e874f14cf6d75a1dd84826462e67a478..bed602b379a776e07d938ca3175db1360ab86a3f 100644 |
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc |
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc |
| @@ -6,20 +6,21 @@ |
| #include <utility> |
| #include "base/metrics/histogram_macros.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/time/time.h" |
| #include "base/values.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h" |
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" |
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.h" |
| #include "components/data_reduction_proxy/core/common/lofi_decider.h" |
| #include "net/base/load_flags.h" |
| #include "net/http/http_request_headers.h" |
| #include "net/http/http_response_headers.h" |
| #include "net/proxy/proxy_info.h" |
| #include "net/proxy/proxy_server.h" |
| #include "net/proxy/proxy_service.h" |
| #include "net/url_request/url_request.h" |
| @@ -151,36 +152,49 @@ DataReductionProxyNetworkDelegate::SessionNetworkStatsInfoToValue() const { |
| dict->SetString("session_original_content_length", |
| base::Int64ToString(total_original_received_bytes_)); |
| return dict; |
| } |
| void DataReductionProxyNetworkDelegate::OnBeforeSendProxyHeadersInternal( |
| net::URLRequest* request, |
| const net::ProxyInfo& proxy_info, |
| net::HttpRequestHeaders* headers) { |
| DCHECK(data_reduction_proxy_config_); |
| - |
| - if (proxy_info.is_empty()) |
| + if (proxy_info.is_empty() || |
| + !data_reduction_proxy_config_->IsDataReductionProxy( |
|
RyanSturm
2016/04/28 21:22:03
Add a proxy_server().is_valid() and proxy_server()
RyanSturm
2016/05/02 19:52:21
Done.
|
| + proxy_info.proxy_server().host_port_pair(), nullptr)) |
| return; |
| + // Get an existing Data instance off of URLRequest or create a new Data |
|
bengr
2016/04/29 21:14:22
I'd rewrite as:
Retrieves DataReductionProxyData f
RyanSturm
2016/05/02 19:52:21
Done.
|
| + // instance for this URLRequest. |
| + DataReductionProxyData* data = |
| + DataReductionProxyData::DataForRequest(request, true); |
| + if (data) |
| + data->set_used_data_reduction_proxy(true); |
| if (data_reduction_proxy_io_data_ && |
| data_reduction_proxy_io_data_->lofi_decider() && request) { |
| LoFiDecider* lofi_decider = data_reduction_proxy_io_data_->lofi_decider(); |
| bool is_using_lofi_mode = lofi_decider->MaybeAddLoFiDirectiveToHeaders( |
| *request, headers, proxy_info.proxy_server(), |
| data_reduction_proxy_config_); |
| if ((request->load_flags() & net::LOAD_MAIN_FRAME)) { |
| // TODO(megjablon): Need to switch to per page. |
| data_reduction_proxy_io_data_->SetLoFiModeActiveOnMainFrame( |
| is_using_lofi_mode); |
| } |
| + // Get an existing Data instance off of URLRequest or create a new Data |
|
bengr
2016/04/29 21:14:22
Same here.
RyanSturm
2016/05/02 19:52:21
Done.
|
| + // instance for this URLRequest. |
| + DataReductionProxyData* data = |
| + DataReductionProxyData::DataForRequest(request, true); |
|
bengr
2016/04/29 21:14:22
Why is if (data) needed? You know there will be da
RyanSturm
2016/05/02 19:52:21
Done.
|
| + if (data) |
| + data->set_is_using_lofi(is_using_lofi_mode); |
| } |
| if (data_reduction_proxy_request_options_) { |
| data_reduction_proxy_request_options_->MaybeAddRequestHeader( |
| proxy_info.proxy_server(), headers); |
| } |
| } |
| void DataReductionProxyNetworkDelegate::OnCompletedInternal( |
| net::URLRequest* request, |