| Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc
|
| diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc
|
| index 24be61b0998bdf0d2ccf1d351a23bc011451d626..9021c63fb4e16dc74dca7da1ff920e6e9857ca2a 100644
|
| --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc
|
| +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_request_options.cc
|
| @@ -159,25 +159,20 @@ void DataReductionProxyRequestOptions::UpdateVersion() {
|
| }
|
|
|
| void DataReductionProxyRequestOptions::MayRegenerateHeaderBasedOnLoFi(
|
| - const net::URLRequest* request) {
|
| + bool is_lofi_on) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| -
|
| - if (!data_reduction_proxy_config_)
|
| - return;
|
| -
|
| - bool lofi_now_enabled =
|
| - !(request && request->load_flags() & net::LOAD_BYPASS_CACHE) &&
|
| - data_reduction_proxy_config_->ShouldUseLoFiHeaderForRequests();
|
| + DCHECK_IMPLIES(is_lofi_on, params::IsIncludedInLoFiEnabledFieldTrial() ||
|
| + params::IsLoFiOnViaFlags());
|
|
|
| // Lo-Fi was not enabled, but now is. Add the header option.
|
| - if (lofi_.empty() && lofi_now_enabled) {
|
| + if (lofi_.empty() && is_lofi_on) {
|
| lofi_ = "low";
|
| RegenerateRequestHeaderValue();
|
| return;
|
| }
|
|
|
| // Lo-Fi was enabled, but no longer is. Remove the header option.
|
| - if (!lofi_.empty() && !lofi_now_enabled) {
|
| + if (!lofi_.empty() && !is_lofi_on) {
|
| lofi_ = std::string();
|
| RegenerateRequestHeaderValue();
|
| return;
|
| @@ -223,31 +218,34 @@ void DataReductionProxyRequestOptions::RandBytes(void* output,
|
| void DataReductionProxyRequestOptions::MaybeAddRequestHeader(
|
| net::URLRequest* request,
|
| const net::ProxyServer& proxy_server,
|
| - net::HttpRequestHeaders* request_headers) {
|
| + net::HttpRequestHeaders* request_headers,
|
| + bool is_lofi_on) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| if (!proxy_server.is_valid())
|
| return;
|
| if (proxy_server.is_direct())
|
| return;
|
| MaybeAddRequestHeaderImpl(request, proxy_server.host_port_pair(), false,
|
| - request_headers);
|
| + request_headers, is_lofi_on);
|
| }
|
|
|
| void DataReductionProxyRequestOptions::MaybeAddProxyTunnelRequestHandler(
|
| const net::HostPortPair& proxy_server,
|
| net::HttpRequestHeaders* request_headers) {
|
| DCHECK(thread_checker_.CalledOnValidThread());
|
| - MaybeAddRequestHeaderImpl(nullptr, proxy_server, true, request_headers);
|
| + MaybeAddRequestHeaderImpl(nullptr, proxy_server, true, request_headers,
|
| + false);
|
| }
|
|
|
| void DataReductionProxyRequestOptions::SetHeader(
|
| const net::URLRequest* request,
|
| - net::HttpRequestHeaders* headers) {
|
| + net::HttpRequestHeaders* headers,
|
| + bool is_lofi_on) {
|
| base::Time now = Now();
|
| // Authorization credentials must be regenerated if they are expired.
|
| if (!use_assigned_credentials_ && (now > credentials_expiration_time_))
|
| UpdateCredentials();
|
| - MayRegenerateHeaderBasedOnLoFi(request);
|
| + MayRegenerateHeaderBasedOnLoFi(is_lofi_on);
|
| const char kChromeProxyHeader[] = "Chrome-Proxy";
|
| std::string header_value;
|
| if (headers->HasHeader(kChromeProxyHeader)) {
|
| @@ -367,13 +365,14 @@ void DataReductionProxyRequestOptions::MaybeAddRequestHeaderImpl(
|
| const net::URLRequest* request,
|
| const net::HostPortPair& proxy_server,
|
| bool expect_ssl,
|
| - net::HttpRequestHeaders* request_headers) {
|
| + net::HttpRequestHeaders* request_headers,
|
| + bool is_lofi_on) {
|
| if (proxy_server.IsEmpty())
|
| return;
|
| if (data_reduction_proxy_config_->IsDataReductionProxy(proxy_server, NULL) &&
|
| data_reduction_proxy_config_->UsingHTTPTunnel(proxy_server) ==
|
| expect_ssl) {
|
| - SetHeader(request, request_headers);
|
| + SetHeader(request, request_headers, is_lofi_on);
|
| }
|
| }
|
|
|
|
|