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

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

Issue 2264903003: Adjust callers and networking delegates in chrome/ to modified APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@URLRequestRead
Patch Set: fix while loop Created 4 years, 2 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 if (!target_url.SchemeIsHTTPOrHTTPS()) 121 if (!target_url.SchemeIsHTTPOrHTTPS())
122 return; 122 return;
123 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 123 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
124 base::Bind(&ReportInvalidReferrerSendOnUI)); 124 base::Bind(&ReportInvalidReferrerSendOnUI));
125 base::debug::DumpWithoutCrashing(); 125 base::debug::DumpWithoutCrashing();
126 NOTREACHED(); 126 NOTREACHED();
127 } 127 }
128 128
129 // Record network errors that HTTP requests complete with, including OK and 129 // Record network errors that HTTP requests complete with, including OK and
130 // ABORTED. 130 // ABORTED.
131 void RecordNetworkErrorHistograms(const net::URLRequest* request) { 131 void RecordNetworkErrorHistograms(const net::URLRequest* request,
132 int net_error) {
132 if (request->url().SchemeIs("http")) { 133 if (request->url().SchemeIs("http")) {
133 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.HttpRequestCompletionErrorCodes", 134 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.HttpRequestCompletionErrorCodes",
134 std::abs(request->status().error())); 135 std::abs(net_error));
135 136
136 if (request->load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) { 137 if (request->load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) {
137 UMA_HISTOGRAM_SPARSE_SLOWLY( 138 UMA_HISTOGRAM_SPARSE_SLOWLY(
138 "Net.HttpRequestCompletionErrorCodes.MainFrame", 139 "Net.HttpRequestCompletionErrorCodes.MainFrame", std::abs(net_error));
139 std::abs(request->status().error()));
140 } 140 }
141 } 141 }
142 } 142 }
143 143
144 } // namespace 144 } // namespace
145 145
146 ChromeNetworkDelegate::ChromeNetworkDelegate( 146 ChromeNetworkDelegate::ChromeNetworkDelegate(
147 extensions::EventRouterForwarder* event_router, 147 extensions::EventRouterForwarder* event_router,
148 BooleanPrefMember* enable_referrers, 148 BooleanPrefMember* enable_referrers,
149 const metrics::UpdateUsagePrefCallbackType& metrics_data_use_forwarder) 149 const metrics::UpdateUsagePrefCallbackType& metrics_data_use_forwarder)
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } 346 }
347 347
348 void ChromeNetworkDelegate::OnBeforeRedirect(net::URLRequest* request, 348 void ChromeNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
349 const GURL& new_location) { 349 const GURL& new_location) {
350 data_use_measurement_.OnBeforeRedirect(*request, new_location); 350 data_use_measurement_.OnBeforeRedirect(*request, new_location);
351 if (domain_reliability_monitor_) 351 if (domain_reliability_monitor_)
352 domain_reliability_monitor_->OnBeforeRedirect(request); 352 domain_reliability_monitor_->OnBeforeRedirect(request);
353 extensions_delegate_->OnBeforeRedirect(request, new_location); 353 extensions_delegate_->OnBeforeRedirect(request, new_location);
354 } 354 }
355 355
356 356 void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request,
357 void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) { 357 int net_error) {
358 extensions_delegate_->OnResponseStarted(request); 358 extensions_delegate_->OnResponseStarted(request, net_error);
359 } 359 }
360 360
361 void ChromeNetworkDelegate::OnNetworkBytesReceived(net::URLRequest* request, 361 void ChromeNetworkDelegate::OnNetworkBytesReceived(net::URLRequest* request,
362 int64_t bytes_received) { 362 int64_t bytes_received) {
363 #if defined(ENABLE_TASK_MANAGER) 363 #if defined(ENABLE_TASK_MANAGER)
364 // Note: Currently, OnNetworkBytesReceived is only implemented for HTTP jobs, 364 // Note: Currently, OnNetworkBytesReceived is only implemented for HTTP jobs,
365 // not FTP or other types, so those kinds of bytes will not be reported here. 365 // not FTP or other types, so those kinds of bytes will not be reported here.
366 task_manager::TaskManagerInterface::OnRawBytesRead(*request, bytes_received); 366 task_manager::TaskManagerInterface::OnRawBytesRead(*request, bytes_received);
367 #endif // defined(ENABLE_TASK_MANAGER) 367 #endif // defined(ENABLE_TASK_MANAGER)
368 368
369 ReportDataUsageStats(request, 0 /* tx_bytes */, bytes_received); 369 ReportDataUsageStats(request, 0 /* tx_bytes */, bytes_received);
370 data_use_measurement_.OnNetworkBytesReceived(*request, bytes_received); 370 data_use_measurement_.OnNetworkBytesReceived(*request, bytes_received);
371 } 371 }
372 372
373 void ChromeNetworkDelegate::OnNetworkBytesSent(net::URLRequest* request, 373 void ChromeNetworkDelegate::OnNetworkBytesSent(net::URLRequest* request,
374 int64_t bytes_sent) { 374 int64_t bytes_sent) {
375 ReportDataUsageStats(request, bytes_sent, 0 /* rx_bytes */); 375 ReportDataUsageStats(request, bytes_sent, 0 /* rx_bytes */);
376 data_use_measurement_.OnNetworkBytesSent(*request, bytes_sent); 376 data_use_measurement_.OnNetworkBytesSent(*request, bytes_sent);
377 } 377 }
378 378
379 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request, 379 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request,
380 bool started) { 380 bool started,
381 int net_error) {
382 DCHECK_NE(net::ERR_IO_PENDING, net_error);
383
384 // TODO(amohammadkhan): Verify that there is no double recording in data use
385 // of redirected requests.
381 data_use_measurement_.OnCompleted(*request, started); 386 data_use_measurement_.OnCompleted(*request, started);
382 RecordNetworkErrorHistograms(request); 387 RecordNetworkErrorHistograms(request, net_error);
383 388
384 if (request->status().status() == net::URLRequestStatus::SUCCESS) { 389 if (net_error == net::OK) {
385 #if BUILDFLAG(ANDROID_JAVA_UI) 390 #if BUILDFLAG(ANDROID_JAVA_UI)
386 precache::UpdatePrecacheMetricsAndState(request, profile_); 391 precache::UpdatePrecacheMetricsAndState(request, profile_);
387 #endif // BUILDFLAG(ANDROID_JAVA_UI) 392 #endif // BUILDFLAG(ANDROID_JAVA_UI)
388 extensions_delegate_->OnCompleted(request, started);
389 } else if (request->status().status() == net::URLRequestStatus::FAILED ||
390 request->status().status() == net::URLRequestStatus::CANCELED) {
391 extensions_delegate_->OnCompleted(request, started);
392 } else {
393 NOTREACHED();
394 } 393 }
394
395 extensions_delegate_->OnCompleted(request, started, net_error);
395 if (domain_reliability_monitor_) 396 if (domain_reliability_monitor_)
396 domain_reliability_monitor_->OnCompleted(request, started); 397 domain_reliability_monitor_->OnCompleted(request, started);
397 RecordRequestSourceBandwidth(request, started); 398 RecordRequestSourceBandwidth(request, started);
398 extensions_delegate_->ForwardProxyErrors(request); 399 extensions_delegate_->ForwardProxyErrors(request, net_error);
399 extensions_delegate_->ForwardDoneRequestStatus(request); 400 extensions_delegate_->ForwardDoneRequestStatus(request);
400 } 401 }
401 402
402 void ChromeNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) { 403 void ChromeNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {
403 extensions_delegate_->OnURLRequestDestroyed(request); 404 extensions_delegate_->OnURLRequestDestroyed(request);
404 } 405 }
405 406
406 void ChromeNetworkDelegate::OnPACScriptError(int line_number, 407 void ChromeNetworkDelegate::OnPACScriptError(int line_number,
407 const base::string16& error) { 408 const base::string16& error) {
408 extensions_delegate_->OnPACScriptError(line_number, error); 409 extensions_delegate_->OnPACScriptError(line_number, error);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 if (!data_use_aggregator_) 587 if (!data_use_aggregator_)
587 return; 588 return;
588 589
589 if (is_data_usage_off_the_record_) { 590 if (is_data_usage_off_the_record_) {
590 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes); 591 data_use_aggregator_->ReportOffTheRecordDataUse(tx_bytes, rx_bytes);
591 return; 592 return;
592 } 593 }
593 594
594 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes); 595 data_use_aggregator_->ReportDataUse(request, tx_bytes, rx_bytes);
595 } 596 }
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_network_delegate.h ('k') | chrome/browser/predictors/resource_prefetch_predictor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698