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

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

Issue 2269833002: Refactor the DataUseMeasurement class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More mechanical changes Created 4 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
« no previous file with comments | « no previous file | chrome/browser/precache/precache_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 return extensions_delegate_->OnHeadersReceived( 336 return extensions_delegate_->OnHeadersReceived(
337 request, 337 request,
338 callback, 338 callback,
339 original_response_headers, 339 original_response_headers,
340 override_response_headers, 340 override_response_headers,
341 allowed_unsafe_redirect_url); 341 allowed_unsafe_redirect_url);
342 } 342 }
343 343
344 void ChromeNetworkDelegate::OnBeforeRedirect(net::URLRequest* request, 344 void ChromeNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
345 const GURL& new_location) { 345 const GURL& new_location) {
346 // Recording data use of request on redirects. 346 data_use_measurement_.OnBeforeRedirect(*request, new_location);
347 data_use_measurement_.ReportDataUseUMA(request);
348 if (domain_reliability_monitor_) 347 if (domain_reliability_monitor_)
349 domain_reliability_monitor_->OnBeforeRedirect(request); 348 domain_reliability_monitor_->OnBeforeRedirect(request);
350 extensions_delegate_->OnBeforeRedirect(request, new_location); 349 extensions_delegate_->OnBeforeRedirect(request, new_location);
351 } 350 }
352 351
353 352
354 void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) { 353 void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
355 extensions_delegate_->OnResponseStarted(request); 354 extensions_delegate_->OnResponseStarted(request);
356 } 355 }
357 356
358 void ChromeNetworkDelegate::OnNetworkBytesReceived(net::URLRequest* request, 357 void ChromeNetworkDelegate::OnNetworkBytesReceived(net::URLRequest* request,
359 int64_t bytes_received) { 358 int64_t bytes_received) {
360 #if defined(ENABLE_TASK_MANAGER) 359 #if defined(ENABLE_TASK_MANAGER)
361 // Note: Currently, OnNetworkBytesReceived is only implemented for HTTP jobs, 360 // Note: Currently, OnNetworkBytesReceived is only implemented for HTTP jobs,
362 // not FTP or other types, so those kinds of bytes will not be reported here. 361 // not FTP or other types, so those kinds of bytes will not be reported here.
363 task_manager::TaskManagerInterface::OnRawBytesRead(*request, bytes_received); 362 task_manager::TaskManagerInterface::OnRawBytesRead(*request, bytes_received);
364 #endif // defined(ENABLE_TASK_MANAGER) 363 #endif // defined(ENABLE_TASK_MANAGER)
365 364
366 ReportDataUsageStats(request, 0 /* tx_bytes */, bytes_received); 365 ReportDataUsageStats(request, 0 /* tx_bytes */, bytes_received);
367 } 366 }
368 367
369 void ChromeNetworkDelegate::OnNetworkBytesSent(net::URLRequest* request, 368 void ChromeNetworkDelegate::OnNetworkBytesSent(net::URLRequest* request,
370 int64_t bytes_sent) { 369 int64_t bytes_sent) {
371 ReportDataUsageStats(request, bytes_sent, 0 /* rx_bytes */); 370 ReportDataUsageStats(request, bytes_sent, 0 /* rx_bytes */);
372 } 371 }
373 372
374 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request, 373 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request,
375 bool started) { 374 bool started) {
376 // TODO(amohammadkhan): Verify that there is no double recording in data use 375 data_use_measurement_.OnCompleted(*request, started);
377 // of redirected requests.
378 data_use_measurement_.ReportDataUseUMA(request);
379 RecordNetworkErrorHistograms(request); 376 RecordNetworkErrorHistograms(request);
380 377
381 if (request->status().status() == net::URLRequestStatus::SUCCESS) { 378 if (request->status().status() == net::URLRequestStatus::SUCCESS) {
382 #if BUILDFLAG(ANDROID_JAVA_UI) 379 #if BUILDFLAG(ANDROID_JAVA_UI)
383 precache::UpdatePrecacheMetricsAndState(request, profile_); 380 precache::UpdatePrecacheMetricsAndState(request, profile_);
384 #endif // BUILDFLAG(ANDROID_JAVA_UI) 381 #endif // BUILDFLAG(ANDROID_JAVA_UI)
385 extensions_delegate_->OnCompleted(request, started); 382 extensions_delegate_->OnCompleted(request, started);
386 } else if (request->status().status() == net::URLRequestStatus::FAILED || 383 } else if (request->status().status() == net::URLRequestStatus::FAILED ||
387 request->status().status() == net::URLRequestStatus::CANCELED) { 384 request->status().status() == net::URLRequestStatus::CANCELED) {
388 extensions_delegate_->OnCompleted(request, started); 385 extensions_delegate_->OnCompleted(request, started);
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 if (!data_use_aggregator_) 584 if (!data_use_aggregator_)
588 return; 585 return;
589 586
590 if (is_data_usage_off_the_record_) { 587 if (is_data_usage_off_the_record_) {
591 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); 588 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes);
592 return; 589 return;
593 } 590 }
594 591
595 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); 592 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes);
596 } 593 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/precache/precache_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698