Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(806)

Side by Side Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc

Issue 2833523002: Adding opt out and previews type information to DRP pingback (Closed)
Patch Set: moved definition up Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 request->response_headers() 384 request->response_headers()
385 ? request->response_headers()->GetInt64HeaderValue( 385 ? request->response_headers()->GetInt64HeaderValue(
386 "x-original-content-length") 386 "x-original-content-length")
387 : -1; 387 : -1;
388 388
389 CalculateAndRecordDataUsage(*request, request_type); 389 CalculateAndRecordDataUsage(*request, request_type);
390 390
391 RecordContentLength(*request, request_type, original_content_length); 391 RecordContentLength(*request, request_type, original_content_length);
392 } 392 }
393 393
394 void DataReductionProxyNetworkDelegate::OnHeadersReceivedInternal(
395 net::URLRequest* request,
396 const net::CompletionCallback& callback,
397 const net::HttpResponseHeaders* original_response_headers,
bengr 2017/04/20 01:02:33 Is this guaranteed to be non-null?
RyanSturm 2017/04/20 20:25:45 I can't find any guarantees. The fact that it is a
398 scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
399 GURL* allowed_unsafe_redirect_url) {
400 if (original_response_headers &&
401 IsEmptyImagePreview(*original_response_headers)) {
402 DataReductionProxyData* data =
403 DataReductionProxyData::GetDataAndCreateIfNecessary(request);
404 data->set_lofi_received(true);
405 } else if (original_response_headers &&
406 IsLitePagePreview(*original_response_headers)) {
407 DataReductionProxyData* data =
408 DataReductionProxyData::GetDataAndCreateIfNecessary(request);
409 data->set_lite_page_received(true);
410 }
411 }
412
394 void DataReductionProxyNetworkDelegate::CalculateAndRecordDataUsage( 413 void DataReductionProxyNetworkDelegate::CalculateAndRecordDataUsage(
395 const net::URLRequest& request, 414 const net::URLRequest& request,
396 DataReductionProxyRequestType request_type) { 415 DataReductionProxyRequestType request_type) {
397 DCHECK(thread_checker_.CalledOnValidThread()); 416 DCHECK(thread_checker_.CalledOnValidThread());
398 int64_t data_used = request.GetTotalReceivedBytes(); 417 int64_t data_used = request.GetTotalReceivedBytes();
399 418
400 // Estimate how many bytes would have been used if the DataReductionProxy was 419 // Estimate how many bytes would have been used if the DataReductionProxy was
401 // not used, and record the data usage. 420 // not used, and record the data usage.
402 int64_t original_size = data_used; 421 int64_t original_size = data_used;
403 422
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 564
546 request_headers->RemoveHeader(net::HttpRequestHeaders::kAcceptEncoding); 565 request_headers->RemoveHeader(net::HttpRequestHeaders::kAcceptEncoding);
547 if (!header_value.empty()) 566 if (!header_value.empty())
548 header_value += ", "; 567 header_value += ", ";
549 header_value += kBrotli; 568 header_value += kBrotli;
550 request_headers->SetHeader(net::HttpRequestHeaders::kAcceptEncoding, 569 request_headers->SetHeader(net::HttpRequestHeaders::kAcceptEncoding,
551 header_value); 570 header_value);
552 } 571 }
553 572
554 } // namespace data_reduction_proxy 573 } // namespace data_reduction_proxy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698