| 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_netw
ork_delegate.h" | 5 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_netw
ork_delegate.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 if (data_reduction_proxy_io_data_->resource_type_provider()) { | 217 if (data_reduction_proxy_io_data_->resource_type_provider()) { |
| 218 // Sets content type of |request| in the resource type provider, so it can | 218 // Sets content type of |request| in the resource type provider, so it can |
| 219 // be later used for determining the proxy that should be used for fetching | 219 // be later used for determining the proxy that should be used for fetching |
| 220 // |request|. | 220 // |request|. |
| 221 data_reduction_proxy_io_data_->resource_type_provider()->SetContentType( | 221 data_reduction_proxy_io_data_->resource_type_provider()->SetContentType( |
| 222 *request); | 222 *request); |
| 223 } | 223 } |
| 224 | 224 |
| 225 if (data_reduction_proxy_io_data_->lofi_decider()) { | 225 if (data_reduction_proxy_io_data_->lofi_decider()) { |
| 226 data_reduction_proxy_io_data_->lofi_decider() | 226 data_reduction_proxy_io_data_->lofi_decider() |
| 227 ->MaybeSetAcceptTransformHeader( | 227 ->MaybeSetAcceptTransformHeader(*request, headers); |
| 228 *request, data_reduction_proxy_config_->lofi_off(), headers); | |
| 229 } | 228 } |
| 230 | 229 |
| 231 MaybeAddChromeProxyECTHeader(headers, *request); | 230 MaybeAddChromeProxyECTHeader(headers, *request); |
| 232 } | 231 } |
| 233 | 232 |
| 234 void DataReductionProxyNetworkDelegate::OnBeforeSendHeadersInternal( | 233 void DataReductionProxyNetworkDelegate::OnBeforeSendHeadersInternal( |
| 235 net::URLRequest* request, | 234 net::URLRequest* request, |
| 236 const net::ProxyInfo& proxy_info, | 235 const net::ProxyInfo& proxy_info, |
| 237 const net::ProxyRetryInfoMap& proxy_retry_info, | 236 const net::ProxyRetryInfoMap& proxy_retry_info, |
| 238 net::HttpRequestHeaders* headers) { | 237 net::HttpRequestHeaders* headers) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 312 |
| 314 if (data_reduction_proxy_io_data_ && | 313 if (data_reduction_proxy_io_data_ && |
| 315 (request->load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED)) { | 314 (request->load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED)) { |
| 316 data_reduction_proxy_io_data_->SetLoFiModeActiveOnMainFrame( | 315 data_reduction_proxy_io_data_->SetLoFiModeActiveOnMainFrame( |
| 317 lofi_decider ? lofi_decider->IsSlowPagePreviewRequested(*headers) | 316 lofi_decider ? lofi_decider->IsSlowPagePreviewRequested(*headers) |
| 318 : false); | 317 : false); |
| 319 } | 318 } |
| 320 | 319 |
| 321 if (data) { | 320 if (data) { |
| 322 data->set_lofi_requested( | 321 data->set_lofi_requested( |
| 323 lofi_decider ? lofi_decider->ShouldRecordLoFiUMA(*request) : false); | 322 lofi_decider ? lofi_decider->ShouldRecordPreviewsUMA(*request) : false); |
| 324 } | 323 } |
| 325 MaybeAddBrotliToAcceptEncodingHeader(proxy_info, headers, *request); | 324 MaybeAddBrotliToAcceptEncodingHeader(proxy_info, headers, *request); |
| 326 | 325 |
| 327 // Generate a page ID for main frame requests that don't already have one. | 326 // Generate a page ID for main frame requests that don't already have one. |
| 328 // TODO(ryansturm): remove LOAD_MAIN_FRAME_DEPRECATED from d_r_p. | 327 // TODO(ryansturm): remove LOAD_MAIN_FRAME_DEPRECATED from d_r_p. |
| 329 // crbug.com/709621 | 328 // crbug.com/709621 |
| 330 if (request->load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) { | 329 if (request->load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) { |
| 331 if (!page_id) { | 330 if (!page_id) { |
| 332 page_id = data_reduction_proxy_request_options_->GeneratePageId(); | 331 page_id = data_reduction_proxy_request_options_->GeneratePageId(); |
| 333 } | 332 } |
| 334 data->set_page_id(page_id.value()); | 333 data->set_page_id(page_id.value()); |
| 335 } | 334 } |
| 336 | 335 |
| 337 data_reduction_proxy_request_options_->AddRequestHeader(headers, page_id); | 336 data_reduction_proxy_request_options_->AddRequestHeader(headers, page_id); |
| 338 | 337 |
| 339 if (lofi_decider) | 338 if (lofi_decider) |
| 340 lofi_decider->MaybeSetIgnorePreviewsBlacklistDirective(headers); | 339 lofi_decider->MaybeSetForceLitePageDirective(headers); |
| 341 VerifyHttpRequestHeaders(true, *headers); | 340 VerifyHttpRequestHeaders(true, *headers); |
| 342 } | 341 } |
| 343 | 342 |
| 344 void DataReductionProxyNetworkDelegate::OnBeforeRedirectInternal( | 343 void DataReductionProxyNetworkDelegate::OnBeforeRedirectInternal( |
| 345 net::URLRequest* request, | 344 net::URLRequest* request, |
| 346 const GURL& new_location) { | 345 const GURL& new_location) { |
| 347 // Since this is after a redirect response, reset |request|'s | 346 // Since this is after a redirect response, reset |request|'s |
| 348 // DataReductionProxyData, but keep page ID and session. | 347 // DataReductionProxyData, but keep page ID and session. |
| 349 // TODO(ryansturm): Change ClearData logic to have persistent and | 348 // TODO(ryansturm): Change ClearData logic to have persistent and |
| 350 // non-persistent (WRT redirects) data. | 349 // non-persistent (WRT redirects) data. |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 } | 640 } |
| 642 | 641 |
| 643 void DataReductionProxyNetworkDelegate::RemoveChromeProxyECTHeader( | 642 void DataReductionProxyNetworkDelegate::RemoveChromeProxyECTHeader( |
| 644 net::HttpRequestHeaders* request_headers) const { | 643 net::HttpRequestHeaders* request_headers) const { |
| 645 DCHECK(thread_checker_.CalledOnValidThread()); | 644 DCHECK(thread_checker_.CalledOnValidThread()); |
| 646 | 645 |
| 647 request_headers->RemoveHeader(chrome_proxy_ect_header()); | 646 request_headers->RemoveHeader(chrome_proxy_ect_header()); |
| 648 } | 647 } |
| 649 | 648 |
| 650 } // namespace data_reduction_proxy | 649 } // namespace data_reduction_proxy |
| OLD | NEW |