| 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 16467f14922df1455ebfe814c82a3054976a0dad..eea7828f191f12a570e8dbdc8a525c29bdf8af6c 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"
|
| @@ -152,35 +153,51 @@ DataReductionProxyNetworkDelegate::SessionNetworkStatsInfoToValue() const {
|
| 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 (data_reduction_proxy_config_->IsDataReductionProxy(
|
| + proxy_info.proxy_server().host_port_pair(), nullptr)) {
|
| + // Get an existing Data instance off of URLRequest or create a new Data
|
| + // instance for this URLRequest.
|
| + DataReductionProxyData* data =
|
| + DataReductionProxyData::DataForRequest(request, true);
|
| + if (data)
|
| + data->set_used_data_reduction_proxy(true);
|
| + }
|
| +
|
| if (proxy_info.is_empty())
|
| return;
|
|
|
| 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
|
| + // instance for this URLRequest.
|
| + DataReductionProxyData* data =
|
| + DataReductionProxyData::DataForRequest(request, true);
|
| + 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,
|
|
|