OLD | NEW |
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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.Success", | 339 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.Success", |
340 request_loading_time); | 340 request_loading_time); |
341 } else if (net_error == net::ERR_ABORTED) { | 341 } else if (net_error == net::ERR_ABORTED) { |
342 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.ErrAborted", | 342 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.ErrAborted", |
343 request_loading_time); | 343 request_loading_time); |
344 } | 344 } |
345 } | 345 } |
346 } | 346 } |
347 | 347 |
348 void NotifyUIThreadOfRequestComplete( | 348 void NotifyUIThreadOfRequestComplete( |
349 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | 349 const content::ResourceRequestInfo::RenderFrameHostGetter& |
| 350 render_frame_host_getter, |
350 const GURL& url, | 351 const GURL& url, |
351 const content::GlobalRequestID& request_id, | 352 const content::GlobalRequestID& request_id, |
| 353 int frame_tree_node_id, |
352 ResourceType resource_type, | 354 ResourceType resource_type, |
353 bool was_cached, | 355 bool was_cached, |
354 bool used_data_reduction_proxy, | 356 bool used_data_reduction_proxy, |
355 int net_error, | 357 int net_error, |
356 int64_t total_received_bytes, | 358 int64_t total_received_bytes, |
357 int64_t raw_body_bytes, | 359 int64_t raw_body_bytes, |
358 int64_t original_content_length, | 360 int64_t original_content_length, |
359 base::TimeTicks request_creation_time, | 361 base::TimeTicks request_creation_time, |
360 base::TimeDelta request_loading_time) { | 362 base::TimeDelta request_loading_time) { |
361 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 363 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
362 content::WebContents* web_contents = web_contents_getter.Run(); | 364 content::RenderFrameHost* render_frame_host = render_frame_host_getter.Run(); |
| 365 if (!render_frame_host) |
| 366 return; |
| 367 content::WebContents* web_contents = |
| 368 content::WebContents::FromRenderFrameHost(render_frame_host); |
363 if (!web_contents) | 369 if (!web_contents) |
364 return; | 370 return; |
| 371 |
365 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) { | 372 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) { |
366 LogMainFrameMetricsOnUIThread(url, net_error, request_loading_time, | 373 LogMainFrameMetricsOnUIThread(url, net_error, request_loading_time, |
367 web_contents); | 374 web_contents); |
368 } | 375 } |
369 if (!was_cached) { | 376 if (!was_cached) { |
370 UpdatePrerenderNetworkBytesCallback(web_contents, total_received_bytes); | 377 UpdatePrerenderNetworkBytesCallback(web_contents, total_received_bytes); |
371 #if defined(OS_ANDROID) | 378 #if defined(OS_ANDROID) |
372 offline_pages::BackgroundLoaderOffliner* background_loader = | 379 offline_pages::BackgroundLoaderOffliner* background_loader = |
373 offline_pages::BackgroundLoaderOffliner::FromWebContents(web_contents); | 380 offline_pages::BackgroundLoaderOffliner::FromWebContents(web_contents); |
374 | 381 |
375 if (background_loader) | 382 if (background_loader) |
376 background_loader->OnNetworkBytesChanged(total_received_bytes); | 383 background_loader->OnNetworkBytesChanged(total_received_bytes); |
377 #endif // OS_ANDROID | 384 #endif // OS_ANDROID |
378 } | 385 } |
379 page_load_metrics::MetricsWebContentsObserver* metrics_observer = | 386 page_load_metrics::MetricsWebContentsObserver* metrics_observer = |
380 page_load_metrics::MetricsWebContentsObserver::FromWebContents( | 387 page_load_metrics::MetricsWebContentsObserver::FromWebContents( |
381 web_contents); | 388 web_contents); |
382 if (metrics_observer) { | 389 if (metrics_observer) { |
383 metrics_observer->OnRequestComplete( | 390 metrics_observer->OnRequestComplete( |
384 request_id, resource_type, was_cached, used_data_reduction_proxy, | 391 url, render_frame_host->GetFrameTreeNodeId(), request_id, resource_type, |
385 raw_body_bytes, original_content_length, request_creation_time); | 392 was_cached, used_data_reduction_proxy, raw_body_bytes, |
| 393 original_content_length, request_creation_time); |
386 } | 394 } |
387 } | 395 } |
388 | 396 |
389 } // namespace | 397 } // namespace |
390 | 398 |
391 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() | 399 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() |
392 : download_request_limiter_(g_browser_process->download_request_limiter()), | 400 : download_request_limiter_(g_browser_process->download_request_limiter()), |
393 safe_browsing_(g_browser_process->safe_browsing_service()) | 401 safe_browsing_(g_browser_process->safe_browsing_service()) |
394 #if BUILDFLAG(ENABLE_EXTENSIONS) | 402 #if BUILDFLAG(ENABLE_EXTENSIONS) |
395 , user_script_listener_(new extensions::UserScriptListener()) | 403 , user_script_listener_(new extensions::UserScriptListener()) |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 data_reduction_proxy::DataReductionProxyData::GetData(*url_request); | 853 data_reduction_proxy::DataReductionProxyData::GetData(*url_request); |
846 bool used_data_reduction_proxy = data && data->used_data_reduction_proxy(); | 854 bool used_data_reduction_proxy = data && data->used_data_reduction_proxy(); |
847 int64_t original_content_length = | 855 int64_t original_content_length = |
848 used_data_reduction_proxy | 856 used_data_reduction_proxy |
849 ? data_reduction_proxy::util::CalculateEffectiveOCL(*url_request) | 857 ? data_reduction_proxy::util::CalculateEffectiveOCL(*url_request) |
850 : url_request->GetRawBodyBytes(); | 858 : url_request->GetRawBodyBytes(); |
851 | 859 |
852 BrowserThread::PostTask( | 860 BrowserThread::PostTask( |
853 BrowserThread::UI, FROM_HERE, | 861 BrowserThread::UI, FROM_HERE, |
854 base::Bind(&NotifyUIThreadOfRequestComplete, | 862 base::Bind(&NotifyUIThreadOfRequestComplete, |
855 info->GetWebContentsGetterForRequest(), url_request->url(), | 863 info->GetRenderFrameHostGetterForRequest(), url_request->url(), |
856 info->GetGlobalRequestID(), info->GetResourceType(), | 864 info->GetGlobalRequestID(), info->GetFrameTreeNodeId(), |
857 url_request->was_cached(), used_data_reduction_proxy, | 865 info->GetResourceType(), url_request->was_cached(), |
858 net_error, url_request->GetTotalReceivedBytes(), | 866 used_data_reduction_proxy, net_error, |
| 867 url_request->GetTotalReceivedBytes(), |
859 url_request->GetRawBodyBytes(), original_content_length, | 868 url_request->GetRawBodyBytes(), original_content_length, |
860 url_request->creation_time(), | 869 url_request->creation_time(), |
861 base::TimeTicks::Now() - url_request->creation_time())); | 870 base::TimeTicks::Now() - url_request->creation_time())); |
862 } | 871 } |
863 | 872 |
864 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState( | 873 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState( |
865 const net::URLRequest& url_request, | 874 const net::URLRequest& url_request, |
866 content::ResourceContext* resource_context) { | 875 content::ResourceContext* resource_context) { |
867 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 876 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
868 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = | 877 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 942 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
934 base::Unretained(this), url, request_loading_time)); | 943 base::Unretained(this), url, request_loading_time)); |
935 return; | 944 return; |
936 } | 945 } |
937 | 946 |
938 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 947 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
939 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 948 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
940 rappor::SampleDomainAndRegistryFromGURL( | 949 rappor::SampleDomainAndRegistryFromGURL( |
941 g_browser_process->rappor_service(), metric_name, url); | 950 g_browser_process->rappor_service(), metric_name, url); |
942 } | 951 } |
OLD | NEW |