| 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 19e13b26b0622947bf7c613ef4d38003eac5c3cc..84e3052d1ed72af1eb8d0c55b216f0a17c5a2e7d 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"
|
| @@ -162,44 +163,52 @@ void DataReductionProxyNetworkDelegate::OnBeforeURLRequestInternal(
|
| (request->load_flags() & net::LOAD_MAIN_FRAME)) {
|
| data_reduction_proxy_io_data_->SetLoFiModeActiveOnMainFrame(false);
|
| }
|
| }
|
|
|
| void DataReductionProxyNetworkDelegate::OnBeforeSendProxyHeadersInternal(
|
| net::URLRequest* request,
|
| const net::ProxyInfo& proxy_info,
|
| net::HttpRequestHeaders* headers) {
|
| DCHECK(data_reduction_proxy_config_);
|
| -
|
| - if (proxy_info.is_empty())
|
| - return;
|
| if (!proxy_info.proxy_server().is_valid())
|
| return;
|
| if (proxy_info.proxy_server().is_direct())
|
| return;
|
| if (proxy_info.proxy_server().host_port_pair().IsEmpty())
|
| return;
|
| if (!data_reduction_proxy_config_->IsDataReductionProxy(
|
| proxy_info.proxy_server().host_port_pair(), nullptr)) {
|
| return;
|
| }
|
|
|
| + // Retrieves DataReductionProxyData from a request, creating a new instance
|
| + // if needed.
|
| + DataReductionProxyData* data =
|
| + DataReductionProxyData::GetDataAndCreateIfNecessary(request);
|
| + 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);
|
|
|
| if ((request->load_flags() & net::LOAD_MAIN_FRAME)) {
|
| data_reduction_proxy_io_data_->SetLoFiModeActiveOnMainFrame(
|
| is_using_lofi_mode);
|
| }
|
| + // Retrieves DataReductionProxyData from a request.
|
| + DataReductionProxyData* data = DataReductionProxyData::GetData(*request);
|
| + if (data)
|
| + data->set_lofi_requested(is_using_lofi_mode);
|
| }
|
|
|
| if (data_reduction_proxy_request_options_) {
|
| data_reduction_proxy_request_options_->AddRequestHeader(headers);
|
| }
|
| }
|
|
|
| void DataReductionProxyNetworkDelegate::OnCompletedInternal(
|
| net::URLRequest* request,
|
| bool started) {
|
|
|