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

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

Issue 1279543002: Support needed to measure user and service traffic in Chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@NewHistogram
Patch Set: Addressed comments and rebased. Created 5 years, 3 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 (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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 return extensions_delegate_->OnHeadersReceived( 461 return extensions_delegate_->OnHeadersReceived(
462 request, 462 request,
463 callback, 463 callback,
464 original_response_headers, 464 original_response_headers,
465 override_response_headers, 465 override_response_headers,
466 allowed_unsafe_redirect_url); 466 allowed_unsafe_redirect_url);
467 } 467 }
468 468
469 void ChromeNetworkDelegate::OnBeforeRedirect(net::URLRequest* request, 469 void ChromeNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
470 const GURL& new_location) { 470 const GURL& new_location) {
471 // Recording data use of request on redirects.
472 #if !defined(OS_IOS)
473 data_use_measurement_.ReportDataUseUMA(request);
474 #endif
471 if (domain_reliability_monitor_) 475 if (domain_reliability_monitor_)
472 domain_reliability_monitor_->OnBeforeRedirect(request); 476 domain_reliability_monitor_->OnBeforeRedirect(request);
473 extensions_delegate_->OnBeforeRedirect(request, new_location); 477 extensions_delegate_->OnBeforeRedirect(request, new_location);
474 } 478 }
475 479
476 480
477 void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) { 481 void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
478 extensions_delegate_->OnResponseStarted(request); 482 extensions_delegate_->OnResponseStarted(request);
479 } 483 }
480 484
481 void ChromeNetworkDelegate::OnNetworkBytesReceived( 485 void ChromeNetworkDelegate::OnNetworkBytesReceived(
482 const net::URLRequest& request, 486 const net::URLRequest& request,
483 int64_t bytes_received) { 487 int64_t bytes_received) {
484 #if defined(ENABLE_TASK_MANAGER) 488 #if defined(ENABLE_TASK_MANAGER)
485 // Note: Currently, OnNetworkBytesReceived is only implemented for HTTP jobs, 489 // Note: Currently, OnNetworkBytesReceived is only implemented for HTTP jobs,
486 // not FTP or other types, so those kinds of bytes will not be reported here. 490 // not FTP or other types, so those kinds of bytes will not be reported here.
487 task_management::TaskManagerInterface::OnRawBytesRead(request, 491 task_management::TaskManagerInterface::OnRawBytesRead(request,
488 bytes_received); 492 bytes_received);
489 #endif // defined(ENABLE_TASK_MANAGER) 493 #endif // defined(ENABLE_TASK_MANAGER)
490 } 494 }
491 495
492 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request, 496 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request,
493 bool started) { 497 bool started) {
498 #if !defined(OS_IOS)
499 // TODO(amohammadkhan): Verify that there is no double recording in data use
500 // of redirected requests.
501 data_use_measurement_.ReportDataUseUMA(request);
502 #endif
494 RecordNetworkErrorHistograms(request); 503 RecordNetworkErrorHistograms(request);
495 if (started) { 504 if (started) {
496 // Only call in for requests that were started, to obey the precondition 505 // Only call in for requests that were started, to obey the precondition
497 // that RecordCacheStateStats can only be called on requests for which 506 // that RecordCacheStateStats can only be called on requests for which
498 // OnResponseStarted was called. 507 // OnResponseStarted was called.
499 RecordCacheStateStats(request); 508 RecordCacheStateStats(request);
500 } 509 }
501 510
502 if (request->status().status() == net::URLRequestStatus::SUCCESS) { 511 if (request->status().status() == net::URLRequestStatus::SUCCESS) {
503 #if defined(OS_ANDROID) 512 #if defined(OS_ANDROID)
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 return experimental_web_platform_features_enabled_; 698 return experimental_web_platform_features_enabled_;
690 } 699 }
691 700
692 bool ChromeNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader( 701 bool ChromeNetworkDelegate::OnCancelURLRequestWithPolicyViolatingReferrerHeader(
693 const net::URLRequest& request, 702 const net::URLRequest& request,
694 const GURL& target_url, 703 const GURL& target_url,
695 const GURL& referrer_url) const { 704 const GURL& referrer_url) const {
696 ReportInvalidReferrerSend(target_url, referrer_url); 705 ReportInvalidReferrerSend(target_url, referrer_url);
697 return true; 706 return true;
698 } 707 }
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