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

Side by Side Diff: chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc

Issue 2624283004: Associate a main resource request with its PageLoadTracker. (Closed)
Patch Set: fix comment Created 3 years, 11 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/page_load_metrics/metrics_navigation_throttle.h » ('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/loader/chrome_resource_dispatcher_host_delegate.h" 5 #include "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 } else if (net_error == net::ERR_ABORTED) { 346 } else if (net_error == net::ERR_ABORTED) {
347 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.ErrAborted", 347 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.ErrAborted",
348 request_loading_time); 348 request_loading_time);
349 } 349 }
350 } 350 }
351 } 351 }
352 352
353 void NotifyUIThreadOfRequestComplete( 353 void NotifyUIThreadOfRequestComplete(
354 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, 354 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
355 const GURL& url, 355 const GURL& url,
356 const content::GlobalRequestID& request_id,
356 ResourceType resource_type, 357 ResourceType resource_type,
357 bool was_cached, 358 bool was_cached,
358 bool used_data_reduction_proxy, 359 bool used_data_reduction_proxy,
359 int net_error, 360 int net_error,
360 int64_t total_received_bytes, 361 int64_t total_received_bytes,
361 int64_t raw_body_bytes, 362 int64_t raw_body_bytes,
362 int64_t original_content_length, 363 int64_t original_content_length,
363 base::TimeTicks request_creation_time, 364 base::TimeTicks request_creation_time,
364 base::TimeDelta request_loading_time) { 365 base::TimeDelta request_loading_time) {
365 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 366 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
366 content::WebContents* web_contents = web_contents_getter.Run(); 367 content::WebContents* web_contents = web_contents_getter.Run();
367 if (!web_contents) 368 if (!web_contents)
368 return; 369 return;
369 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) { 370 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) {
370 LogMainFrameMetricsOnUIThread(url, net_error, request_loading_time, 371 LogMainFrameMetricsOnUIThread(url, net_error, request_loading_time,
371 web_contents); 372 web_contents);
372 } 373 }
373 if (!was_cached) 374 if (!was_cached)
374 UpdatePrerenderNetworkBytesCallback(web_contents, total_received_bytes); 375 UpdatePrerenderNetworkBytesCallback(web_contents, total_received_bytes);
375 page_load_metrics::MetricsWebContentsObserver* metrics_observer = 376 page_load_metrics::MetricsWebContentsObserver* metrics_observer =
376 page_load_metrics::MetricsWebContentsObserver::FromWebContents( 377 page_load_metrics::MetricsWebContentsObserver::FromWebContents(
377 web_contents); 378 web_contents);
378 if (metrics_observer) { 379 if (metrics_observer) {
379 metrics_observer->OnRequestComplete( 380 metrics_observer->OnRequestComplete(
380 resource_type, was_cached, used_data_reduction_proxy, raw_body_bytes, 381 request_id, resource_type, was_cached, used_data_reduction_proxy,
381 original_content_length, request_creation_time); 382 raw_body_bytes, original_content_length, request_creation_time);
382 } 383 }
383 } 384 }
384 385
385 } // namespace 386 } // namespace
386 387
387 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() 388 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate()
388 : download_request_limiter_(g_browser_process->download_request_limiter()), 389 : download_request_limiter_(g_browser_process->download_request_limiter()),
389 safe_browsing_(g_browser_process->safe_browsing_service()) 390 safe_browsing_(g_browser_process->safe_browsing_service())
390 #if BUILDFLAG(ENABLE_EXTENSIONS) 391 #if BUILDFLAG(ENABLE_EXTENSIONS)
391 , user_script_listener_(new extensions::UserScriptListener()) 392 , user_script_listener_(new extensions::UserScriptListener())
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 bool used_data_reduction_proxy = data && data->used_data_reduction_proxy(); 841 bool used_data_reduction_proxy = data && data->used_data_reduction_proxy();
841 int64_t original_content_length = 842 int64_t original_content_length =
842 used_data_reduction_proxy 843 used_data_reduction_proxy
843 ? data_reduction_proxy::util::CalculateEffectiveOCL(*url_request) 844 ? data_reduction_proxy::util::CalculateEffectiveOCL(*url_request)
844 : url_request->GetRawBodyBytes(); 845 : url_request->GetRawBodyBytes();
845 846
846 BrowserThread::PostTask( 847 BrowserThread::PostTask(
847 BrowserThread::UI, FROM_HERE, 848 BrowserThread::UI, FROM_HERE,
848 base::Bind(&NotifyUIThreadOfRequestComplete, 849 base::Bind(&NotifyUIThreadOfRequestComplete,
849 info->GetWebContentsGetterForRequest(), url_request->url(), 850 info->GetWebContentsGetterForRequest(), url_request->url(),
850 info->GetResourceType(), url_request->was_cached(), 851 info->GetGlobalRequestID(), info->GetResourceType(),
851 used_data_reduction_proxy, net_error, 852 url_request->was_cached(), used_data_reduction_proxy,
852 url_request->GetTotalReceivedBytes(), 853 net_error, url_request->GetTotalReceivedBytes(),
853 url_request->GetRawBodyBytes(), original_content_length, 854 url_request->GetRawBodyBytes(), original_content_length,
854 url_request->creation_time(), 855 url_request->creation_time(),
855 base::TimeTicks::Now() - url_request->creation_time())); 856 base::TimeTicks::Now() - url_request->creation_time()));
856 } 857 }
857 858
858 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState( 859 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState(
859 const net::URLRequest& url_request, 860 const net::URLRequest& url_request,
860 content::ResourceContext* resource_context) { 861 content::ResourceContext* resource_context) {
861 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 862 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
862 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = 863 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data =
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 915 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
915 base::Unretained(this), url, request_loading_time)); 916 base::Unretained(this), url, request_loading_time));
916 return; 917 return;
917 } 918 }
918 919
919 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 920 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
920 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 921 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
921 rappor::SampleDomainAndRegistryFromGURL( 922 rappor::SampleDomainAndRegistryFromGURL(
922 g_browser_process->rappor_service(), metric_name, url); 923 g_browser_process->rappor_service(), metric_name, url);
923 } 924 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/metrics_navigation_throttle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698