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

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

Powered by Google App Engine
This is Rietveld 408576698