| 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" |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypa
ss_stats.h" | 14 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypa
ss_stats.h" |
| 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" | 15 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
ig.h" |
| 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" | 16 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" |
| 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data
.h" | 17 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_data
.h" |
| 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" | 18 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d
ata.h" |
| 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ
est_options.h" | 19 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_requ
est_options.h" |
| 20 #include "components/data_reduction_proxy/core/browser/data_use_group.h" | 20 #include "components/data_reduction_proxy/core/browser/data_use_group.h" |
| 21 #include "components/data_reduction_proxy/core/browser/data_use_group_provider.h
" | 21 #include "components/data_reduction_proxy/core/browser/data_use_group_provider.h
" |
| 22 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_featu
res.h" |
| 22 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" | 23 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_heade
rs.h" |
| 23 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | 24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" |
| 24 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_util.
h" | 25 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_util.
h" |
| 25 #include "components/data_reduction_proxy/core/common/lofi_decider.h" | 26 #include "components/data_reduction_proxy/core/common/lofi_decider.h" |
| 26 #include "net/base/load_flags.h" | 27 #include "net/base/load_flags.h" |
| 27 #include "net/http/http_request_headers.h" | 28 #include "net/http/http_request_headers.h" |
| 28 #include "net/http/http_response_headers.h" | 29 #include "net/http/http_response_headers.h" |
| 29 #include "net/nqe/effective_connection_type.h" | 30 #include "net/nqe/effective_connection_type.h" |
| 30 #include "net/nqe/network_quality_estimator.h" | 31 #include "net/nqe/network_quality_estimator.h" |
| 31 #include "net/proxy/proxy_info.h" | 32 #include "net/proxy/proxy_info.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 util::CalculateEffectiveOCL(request); | 116 util::CalculateEffectiveOCL(request); |
| 116 } | 117 } |
| 117 | 118 |
| 118 // Verifies that the chrome proxy related request headers are set correctly. | 119 // Verifies that the chrome proxy related request headers are set correctly. |
| 119 // |via_chrome_proxy| is true if the request is being fetched via Chrome Data | 120 // |via_chrome_proxy| is true if the request is being fetched via Chrome Data |
| 120 // Saver proxy. | 121 // Saver proxy. |
| 121 void VerifyHttpRequestHeaders(bool via_chrome_proxy, | 122 void VerifyHttpRequestHeaders(bool via_chrome_proxy, |
| 122 const net::HttpRequestHeaders& headers) { | 123 const net::HttpRequestHeaders& headers) { |
| 123 if (via_chrome_proxy) { | 124 if (via_chrome_proxy) { |
| 124 DCHECK(headers.HasHeader(chrome_proxy_header())); | 125 DCHECK(headers.HasHeader(chrome_proxy_header())); |
| 125 DCHECK(headers.HasHeader(chrome_proxy_ect_header())); | 126 DCHECK_EQ( |
| 127 data_reduction_proxy::features::IsDataReductionProxyECTHeaderEnabled(), |
| 128 headers.HasHeader(chrome_proxy_ect_header())); |
| 126 } else { | 129 } else { |
| 127 DCHECK(!headers.HasHeader(chrome_proxy_header())); | 130 DCHECK(!headers.HasHeader(chrome_proxy_header())); |
| 128 DCHECK(!headers.HasHeader(chrome_proxy_accept_transform_header())); | 131 DCHECK(!headers.HasHeader(chrome_proxy_accept_transform_header())); |
| 129 DCHECK(!headers.HasHeader(chrome_proxy_ect_header())); | 132 DCHECK(!headers.HasHeader(chrome_proxy_ect_header())); |
| 130 } | 133 } |
| 131 } | 134 } |
| 132 | 135 |
| 133 } // namespace | 136 } // namespace |
| 134 | 137 |
| 135 DataReductionProxyNetworkDelegate::DataReductionProxyNetworkDelegate( | 138 DataReductionProxyNetworkDelegate::DataReductionProxyNetworkDelegate( |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 header_value += kBrotli; | 522 header_value += kBrotli; |
| 520 request_headers->SetHeader(net::HttpRequestHeaders::kAcceptEncoding, | 523 request_headers->SetHeader(net::HttpRequestHeaders::kAcceptEncoding, |
| 521 header_value); | 524 header_value); |
| 522 } | 525 } |
| 523 | 526 |
| 524 void DataReductionProxyNetworkDelegate::MaybeAddChromeProxyECTHeader( | 527 void DataReductionProxyNetworkDelegate::MaybeAddChromeProxyECTHeader( |
| 525 net::HttpRequestHeaders* request_headers, | 528 net::HttpRequestHeaders* request_headers, |
| 526 const net::URLRequest& request) const { | 529 const net::URLRequest& request) const { |
| 527 DCHECK(thread_checker_.CalledOnValidThread()); | 530 DCHECK(thread_checker_.CalledOnValidThread()); |
| 528 | 531 |
| 532 if (!data_reduction_proxy::features::IsDataReductionProxyECTHeaderEnabled()) |
| 533 return; |
| 534 |
| 529 // This method should be called only when the resolved proxy was a data | 535 // This method should be called only when the resolved proxy was a data |
| 530 // saver proxy. | 536 // saver proxy. |
| 531 DCHECK(request.url().is_valid()); | 537 DCHECK(request.url().is_valid()); |
| 532 DCHECK(!request.url().SchemeIsCryptographic()); | 538 DCHECK(!request.url().SchemeIsCryptographic()); |
| 533 DCHECK(request.url().SchemeIsHTTPOrHTTPS()); | 539 DCHECK(request.url().SchemeIsHTTPOrHTTPS()); |
| 534 | 540 |
| 535 if (request_headers->HasHeader(chrome_proxy_ect_header())) | 541 if (request_headers->HasHeader(chrome_proxy_ect_header())) |
| 536 request_headers->RemoveHeader(chrome_proxy_ect_header()); | 542 request_headers->RemoveHeader(chrome_proxy_ect_header()); |
| 537 | 543 |
| 538 if (request.context()->network_quality_estimator()) { | 544 if (request.context()->network_quality_estimator()) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 555 "ECT enum value is not handled."); | 561 "ECT enum value is not handled."); |
| 556 static_assert(net::EFFECTIVE_CONNECTION_TYPE_4G + 1 == | 562 static_assert(net::EFFECTIVE_CONNECTION_TYPE_4G + 1 == |
| 557 net::EFFECTIVE_CONNECTION_TYPE_LAST, | 563 net::EFFECTIVE_CONNECTION_TYPE_LAST, |
| 558 "ECT enum value is not handled."); | 564 "ECT enum value is not handled."); |
| 559 } | 565 } |
| 560 | 566 |
| 561 void DataReductionProxyNetworkDelegate::RemoveChromeProxyECTHeader( | 567 void DataReductionProxyNetworkDelegate::RemoveChromeProxyECTHeader( |
| 562 net::HttpRequestHeaders* request_headers) const { | 568 net::HttpRequestHeaders* request_headers) const { |
| 563 DCHECK(thread_checker_.CalledOnValidThread()); | 569 DCHECK(thread_checker_.CalledOnValidThread()); |
| 564 | 570 |
| 571 if (!data_reduction_proxy::features::IsDataReductionProxyECTHeaderEnabled()) |
| 572 return; |
| 573 |
| 565 request_headers->RemoveHeader(chrome_proxy_ect_header()); | 574 request_headers->RemoveHeader(chrome_proxy_ect_header()); |
| 566 } | 575 } |
| 567 | 576 |
| 568 } // namespace data_reduction_proxy | 577 } // namespace data_reduction_proxy |
| OLD | NEW |