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

Side by Side Diff: chrome/browser/net/chrome_network_delegate.cc

Issue 1421983002: Include tab IDs when reporting data use accounting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data_use_scoped_vector
Patch Set: Fixed external_data_use_observer test Created 5 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/net/chrome_network_delegate.h" 5 #include "chrome/browser/net/chrome_network_delegate.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 if (domain_reliability_monitor_) 485 if (domain_reliability_monitor_)
486 domain_reliability_monitor_->OnBeforeRedirect(request); 486 domain_reliability_monitor_->OnBeforeRedirect(request);
487 extensions_delegate_->OnBeforeRedirect(request, new_location); 487 extensions_delegate_->OnBeforeRedirect(request, new_location);
488 } 488 }
489 489
490 490
491 void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) { 491 void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
492 extensions_delegate_->OnResponseStarted(request); 492 extensions_delegate_->OnResponseStarted(request);
493 } 493 }
494 494
495 void ChromeNetworkDelegate::OnNetworkBytesReceived( 495 void ChromeNetworkDelegate::OnNetworkBytesReceived(net::URLRequest* request,
496 const net::URLRequest& request, 496 int64_t bytes_received) {
497 int64_t bytes_received) {
498 #if defined(ENABLE_TASK_MANAGER) 497 #if defined(ENABLE_TASK_MANAGER)
499 // Note: Currently, OnNetworkBytesReceived is only implemented for HTTP jobs, 498 // Note: Currently, OnNetworkBytesReceived is only implemented for HTTP jobs,
500 // not FTP or other types, so those kinds of bytes will not be reported here. 499 // not FTP or other types, so those kinds of bytes will not be reported here.
501 task_management::TaskManagerInterface::OnRawBytesRead(request, 500 task_management::TaskManagerInterface::OnRawBytesRead(*request,
502 bytes_received); 501 bytes_received);
503 #endif // defined(ENABLE_TASK_MANAGER) 502 #endif // defined(ENABLE_TASK_MANAGER)
504 503
505 if (data_use_aggregator_) { 504 ReportDataUsageStats(request, 0 /* tx_bytes */, bytes_received);
506 if (is_data_usage_off_the_record_) {
507 data_use_aggregator_->ReportOffTheRecordDataUse(0 /* tx_bytes */,
508 bytes_received);
509 } else {
510 data_use_aggregator_->ReportDataUse(request, -1 /* tab_id */,
511 0 /* tx_bytes */, bytes_received);
512 }
513 }
514 } 505 }
515 506
516 void ChromeNetworkDelegate::OnNetworkBytesSent(const net::URLRequest& request, 507 void ChromeNetworkDelegate::OnNetworkBytesSent(net::URLRequest* request,
517 int64_t bytes_sent) { 508 int64_t bytes_sent) {
518 if (data_use_aggregator_) { 509 ReportDataUsageStats(request, bytes_sent, 0 /* rx_bytes */);
519 if (is_data_usage_off_the_record_) {
520 data_use_aggregator_->ReportOffTheRecordDataUse(bytes_sent,
521 0 /* rx_bytes */);
522 } else {
523 data_use_aggregator_->ReportDataUse(request, -1 /* tab_id */, bytes_sent,
524 0 /* rx_bytes */);
525 }
526 }
527 } 510 }
528 511
529 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request, 512 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request,
530 bool started) { 513 bool started) {
531 #if !defined(OS_IOS) 514 #if !defined(OS_IOS)
532 // TODO(amohammadkhan): Verify that there is no double recording in data use 515 // TODO(amohammadkhan): Verify that there is no double recording in data use
533 // of redirected requests. 516 // of redirected requests.
534 data_use_measurement_.ReportDataUseUMA(request); 517 data_use_measurement_.ReportDataUseUMA(request);
535 #endif 518 #endif
536 RecordNetworkErrorHistograms(request); 519 RecordNetworkErrorHistograms(request);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 return experimental_web_platform_features_enabled_; 718 return experimental_web_platform_features_enabled_;
736 } 719 }
737 720
738 bool ChromeNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( 721 bool ChromeNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader(
739 const net::URLRequest& request, 722 const net::URLRequest& request,
740 const GURL& target_url, 723 const GURL& target_url,
741 const GURL& referrer_url) const { 724 const GURL& referrer_url) const {
742 ReportInvalidReferrerSend(target_url, referrer_url); 725 ReportInvalidReferrerSend(target_url, referrer_url);
743 return true; 726 return true;
744 } 727 }
728
729 void ChromeNetworkDelegate::ReportDataUsageStats(net::URLRequest* request,
730 int64_t tx_bytes,
731 int64_t rx_bytes) {
732 if (!data_use_aggregator_)
733 return;
734
735 if (is_data_usage_off_the_record_) {
736 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes);
737 return;
738 }
739
740 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes);
741 }
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_network_delegate.h ('k') | chrome/browser/net/chrome_network_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698