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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 // Reset |request|'s DataReductionProxyData. | 285 // Reset |request|'s DataReductionProxyData. |
286 DataReductionProxyData::ClearData(request); | 286 DataReductionProxyData::ClearData(request); |
287 | 287 |
288 if (params::IsIncludedInHoldbackFieldTrial()) { | 288 if (params::IsIncludedInHoldbackFieldTrial()) { |
289 if (!WasEligibleWithoutHoldback(*request, proxy_info, proxy_retry_info)) | 289 if (!WasEligibleWithoutHoldback(*request, proxy_info, proxy_retry_info)) |
290 return; | 290 return; |
291 // For the holdback field trial, still log UMA as if the proxy was used. | 291 // For the holdback field trial, still log UMA as if the proxy was used. |
292 data = DataReductionProxyData::GetDataAndCreateIfNecessary(request); | 292 data = DataReductionProxyData::GetDataAndCreateIfNecessary(request); |
293 if (data) | 293 if (data) |
294 data->set_used_data_reduction_proxy(true); | 294 data->set_used_data_reduction_proxy(true); |
| 295 |
| 296 headers->RemoveHeader(chrome_proxy_header()); |
295 VerifyHttpRequestHeaders(false, *headers); | 297 VerifyHttpRequestHeaders(false, *headers); |
296 return; | 298 return; |
297 } | 299 } |
298 | 300 |
299 bool using_data_reduction_proxy = true; | 301 bool using_data_reduction_proxy = true; |
300 // The following checks rule out direct, invalid, and other connection types. | 302 // The following checks rule out direct, invalid, and other connection types. |
301 if (!proxy_info.is_http() && !proxy_info.is_https() && | 303 if (!proxy_info.is_http() && !proxy_info.is_https() && |
302 !proxy_info.is_quic()) { | 304 !proxy_info.is_quic()) { |
303 using_data_reduction_proxy = false; | 305 using_data_reduction_proxy = false; |
304 } else if (proxy_info.proxy_server().host_port_pair().IsEmpty()) { | 306 } else if (proxy_info.proxy_server().host_port_pair().IsEmpty()) { |
305 using_data_reduction_proxy = false; | 307 using_data_reduction_proxy = false; |
306 } else if (!data_reduction_proxy_config_->IsDataReductionProxy( | 308 } else if (!data_reduction_proxy_config_->IsDataReductionProxy( |
307 proxy_info.proxy_server(), nullptr)) { | 309 proxy_info.proxy_server(), nullptr)) { |
308 using_data_reduction_proxy = false; | 310 using_data_reduction_proxy = false; |
309 } | 311 } |
310 | 312 |
311 LoFiDecider* lofi_decider = nullptr; | 313 LoFiDecider* lofi_decider = nullptr; |
312 if (data_reduction_proxy_io_data_) | 314 if (data_reduction_proxy_io_data_) |
313 lofi_decider = data_reduction_proxy_io_data_->lofi_decider(); | 315 lofi_decider = data_reduction_proxy_io_data_->lofi_decider(); |
314 | 316 |
315 if (!using_data_reduction_proxy) { | 317 if (!using_data_reduction_proxy) { |
316 if (lofi_decider) { | 318 if (lofi_decider) { |
317 // If not using the data reduction proxy, strip the | 319 // If not using the data reduction proxy, strip the |
318 // Chrome-Proxy-Accept-Transform header. | 320 // Chrome-Proxy-Accept-Transform header. |
319 lofi_decider->RemoveAcceptTransformHeader(headers); | 321 lofi_decider->RemoveAcceptTransformHeader(headers); |
320 } | 322 } |
321 RemoveChromeProxyECTHeader(headers); | 323 RemoveChromeProxyECTHeader(headers); |
| 324 headers->RemoveHeader(chrome_proxy_header()); |
322 VerifyHttpRequestHeaders(false, *headers); | 325 VerifyHttpRequestHeaders(false, *headers); |
323 return; | 326 return; |
324 } | 327 } |
325 | 328 |
326 // Retrieves DataReductionProxyData from a request, creating a new instance | 329 // Retrieves DataReductionProxyData from a request, creating a new instance |
327 // if needed. | 330 // if needed. |
328 data = DataReductionProxyData::GetDataAndCreateIfNecessary(request); | 331 data = DataReductionProxyData::GetDataAndCreateIfNecessary(request); |
329 if (data) { | 332 if (data) { |
330 data->set_used_data_reduction_proxy(true); | 333 data->set_used_data_reduction_proxy(true); |
331 // Only set GURL, NQE and session key string for main frame requests since | 334 // Only set GURL, NQE and session key string for main frame requests since |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 } | 692 } |
690 | 693 |
691 void DataReductionProxyNetworkDelegate::RemoveChromeProxyECTHeader( | 694 void DataReductionProxyNetworkDelegate::RemoveChromeProxyECTHeader( |
692 net::HttpRequestHeaders* request_headers) const { | 695 net::HttpRequestHeaders* request_headers) const { |
693 DCHECK(thread_checker_.CalledOnValidThread()); | 696 DCHECK(thread_checker_.CalledOnValidThread()); |
694 | 697 |
695 request_headers->RemoveHeader(chrome_proxy_ect_header()); | 698 request_headers->RemoveHeader(chrome_proxy_ect_header()); |
696 } | 699 } |
697 | 700 |
698 } // namespace data_reduction_proxy | 701 } // namespace data_reduction_proxy |
OLD | NEW |