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

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: rebased 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 } 343 }
344 344
345 void ChromeNetworkDelegate::OnBeforeRedirect(net::URLRequest* request, 345 void ChromeNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
346 const GURL& new_location) { 346 const GURL& new_location) {
347 data_use_measurement_.OnBeforeRedirect(*request, new_location); 347 data_use_measurement_.OnBeforeRedirect(*request, new_location);
348 if (domain_reliability_monitor_) 348 if (domain_reliability_monitor_)
349 domain_reliability_monitor_->OnBeforeRedirect(request); 349 domain_reliability_monitor_->OnBeforeRedirect(request);
350 extensions_delegate_->OnBeforeRedirect(request, new_location); 350 extensions_delegate_->OnBeforeRedirect(request, new_location);
351 } 351 }
352 352
353 353 void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request,
354 void ChromeNetworkDelegate::OnResponseStarted(net::URLRequest* request) { 354 int net_error) {
355 extensions_delegate_->OnResponseStarted(request); 355 extensions_delegate_->OnResponseStarted(request, net_error);
356 } 356 }
357 357
358 void ChromeNetworkDelegate::OnNetworkBytesReceived(net::URLRequest* request, 358 void ChromeNetworkDelegate::OnNetworkBytesReceived(net::URLRequest* request,
359 int64_t bytes_received) { 359 int64_t bytes_received) {
360 #if defined(ENABLE_TASK_MANAGER) 360 #if defined(ENABLE_TASK_MANAGER)
361 // Note: Currently, OnNetworkBytesReceived is only implemented for HTTP jobs, 361 // 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. 362 // not FTP or other types, so those kinds of bytes will not be reported here.
363 task_manager::TaskManagerInterface::OnRawBytesRead(*request, bytes_received); 363 task_manager::TaskManagerInterface::OnRawBytesRead(*request, bytes_received);
364 #endif // defined(ENABLE_TASK_MANAGER) 364 #endif // defined(ENABLE_TASK_MANAGER)
365 365
366 ReportDataUsageStats(request, 0 /* tx_bytes */, bytes_received); 366 ReportDataUsageStats(request, 0 /* tx_bytes */, bytes_received);
367 } 367 }
368 368
369 void ChromeNetworkDelegate::OnNetworkBytesSent(net::URLRequest* request, 369 void ChromeNetworkDelegate::OnNetworkBytesSent(net::URLRequest* request,
370 int64_t bytes_sent) { 370 int64_t bytes_sent) {
371 ReportDataUsageStats(request, bytes_sent, 0 /* rx_bytes */); 371 ReportDataUsageStats(request, bytes_sent, 0 /* rx_bytes */);
372 } 372 }
373 373
374 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request, 374 void ChromeNetworkDelegate::OnCompleted(net::URLRequest* request,
375 bool started) { 375 bool started,
376 int net_error) {
377 DCHECK_NE(net::ERR_IO_PENDING, net_error);
378
379 // TODO(amohammadkhan): Verify that there is no double recording in data use
380 // of redirected requests.
376 data_use_measurement_.OnCompleted(*request, started); 381 data_use_measurement_.OnCompleted(*request, started);
377 RecordNetworkErrorHistograms(request); 382 RecordNetworkErrorHistograms(request, net_error);
378 383
379 if (request->status().status() == net::URLRequestStatus::SUCCESS) { 384 if (net_error == net::OK) {
380 #if BUILDFLAG(ANDROID_JAVA_UI) 385 #if BUILDFLAG(ANDROID_JAVA_UI)
381 precache::UpdatePrecacheMetricsAndState(request, profile_); 386 precache::UpdatePrecacheMetricsAndState(request, profile_);
382 #endif // BUILDFLAG(ANDROID_JAVA_UI) 387 #endif // BUILDFLAG(ANDROID_JAVA_UI)
383 extensions_delegate_->OnCompleted(request, started);
384 } else if (request->status().status() == net::URLRequestStatus::FAILED ||
385 request->status().status() == net::URLRequestStatus::CANCELED) {
386 extensions_delegate_->OnCompleted(request, started);
387 } else {
388 NOTREACHED();
389 } 388 }
389
390 extensions_delegate_->OnCompleted(request, started, net_error);
390 if (domain_reliability_monitor_) 391 if (domain_reliability_monitor_)
391 domain_reliability_monitor_->OnCompleted(request, started); 392 domain_reliability_monitor_->OnCompleted(request, started);
392 RecordRequestSourceBandwidth(request, started); 393 RecordRequestSourceBandwidth(request, started);
393 extensions_delegate_->ForwardProxyErrors(request); 394 extensions_delegate_->ForwardProxyErrors(request, net_error);
394 extensions_delegate_->ForwardDoneRequestStatus(request); 395 extensions_delegate_->ForwardDoneRequestStatus(request);
395 } 396 }
396 397
397 void ChromeNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) { 398 void ChromeNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {
398 extensions_delegate_->OnURLRequestDestroyed(request); 399 extensions_delegate_->OnURLRequestDestroyed(request);
399 } 400 }
400 401
401 void ChromeNetworkDelegate::OnPACScriptError(int line_number, 402 void ChromeNetworkDelegate::OnPACScriptError(int line_number,
402 const base::string16& error) { 403 const base::string16& error) {
403 extensions_delegate_->OnPACScriptError(line_number, error); 404 extensions_delegate_->OnPACScriptError(line_number, error);
(...skipping 181 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