| 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 web_contents); | 360 web_contents); |
| 361 | 361 |
| 362 if (metrics_observer) { | 362 if (metrics_observer) { |
| 363 metrics_observer->OnRequestStarted(request_id, resource_type, | 363 metrics_observer->OnRequestStarted(request_id, resource_type, |
| 364 request_creation_time); | 364 request_creation_time); |
| 365 } | 365 } |
| 366 } | 366 } |
| 367 | 367 |
| 368 void NotifyUIThreadOfRequestComplete( | 368 void NotifyUIThreadOfRequestComplete( |
| 369 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | 369 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
| 370 const content::ResourceRequestInfo::FrameTreeNodeIdGetter& | |
| 371 frame_tree_node_id_getter, | |
| 372 const GURL& url, | 370 const GURL& url, |
| 373 const content::GlobalRequestID& request_id, | 371 const content::GlobalRequestID& request_id, |
| 374 ResourceType resource_type, | 372 ResourceType resource_type, |
| 375 bool was_cached, | 373 bool was_cached, |
| 376 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> | 374 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> |
| 377 data_reduction_proxy_data, | 375 data_reduction_proxy_data, |
| 378 int net_error, | 376 int net_error, |
| 379 int64_t total_received_bytes, | 377 int64_t total_received_bytes, |
| 380 int64_t raw_body_bytes, | 378 int64_t raw_body_bytes, |
| 381 int64_t original_content_length, | 379 int64_t original_content_length, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 396 offline_pages::BackgroundLoaderOffliner::FromWebContents(web_contents); | 394 offline_pages::BackgroundLoaderOffliner::FromWebContents(web_contents); |
| 397 | 395 |
| 398 if (background_loader) | 396 if (background_loader) |
| 399 background_loader->OnNetworkBytesChanged(total_received_bytes); | 397 background_loader->OnNetworkBytesChanged(total_received_bytes); |
| 400 #endif // OS_ANDROID | 398 #endif // OS_ANDROID |
| 401 } | 399 } |
| 402 page_load_metrics::MetricsWebContentsObserver* metrics_observer = | 400 page_load_metrics::MetricsWebContentsObserver* metrics_observer = |
| 403 page_load_metrics::MetricsWebContentsObserver::FromWebContents( | 401 page_load_metrics::MetricsWebContentsObserver::FromWebContents( |
| 404 web_contents); | 402 web_contents); |
| 405 if (metrics_observer) { | 403 if (metrics_observer) { |
| 406 metrics_observer->OnRequestComplete( | 404 metrics_observer->OnRequestComplete(request_id, resource_type, was_cached, |
| 407 url, frame_tree_node_id_getter.Run(), request_id, resource_type, | 405 std::move(data_reduction_proxy_data), |
| 408 was_cached, std::move(data_reduction_proxy_data), raw_body_bytes, | 406 raw_body_bytes, original_content_length, |
| 409 original_content_length, request_creation_time); | 407 request_creation_time); |
| 410 } | 408 } |
| 411 } | 409 } |
| 412 | 410 |
| 413 } // namespace | 411 } // namespace |
| 414 | 412 |
| 415 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() | 413 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() |
| 416 : download_request_limiter_(g_browser_process->download_request_limiter()), | 414 : download_request_limiter_(g_browser_process->download_request_limiter()), |
| 417 safe_browsing_(g_browser_process->safe_browsing_service()) | 415 safe_browsing_(g_browser_process->safe_browsing_service()) |
| 418 #if BUILDFLAG(ENABLE_EXTENSIONS) | 416 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 419 , user_script_listener_(new extensions::UserScriptListener()) | 417 , user_script_listener_(new extensions::UserScriptListener()) |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 if (data) | 861 if (data) |
| 864 data_reduction_proxy_data = data->DeepCopy(); | 862 data_reduction_proxy_data = data->DeepCopy(); |
| 865 int64_t original_content_length = | 863 int64_t original_content_length = |
| 866 data && data->used_data_reduction_proxy() | 864 data && data->used_data_reduction_proxy() |
| 867 ? data_reduction_proxy::util::CalculateEffectiveOCL(*url_request) | 865 ? data_reduction_proxy::util::CalculateEffectiveOCL(*url_request) |
| 868 : url_request->GetRawBodyBytes(); | 866 : url_request->GetRawBodyBytes(); |
| 869 | 867 |
| 870 BrowserThread::PostTask( | 868 BrowserThread::PostTask( |
| 871 BrowserThread::UI, FROM_HERE, | 869 BrowserThread::UI, FROM_HERE, |
| 872 base::BindOnce(&NotifyUIThreadOfRequestComplete, | 870 base::BindOnce(&NotifyUIThreadOfRequestComplete, |
| 873 info->GetWebContentsGetterForRequest(), | 871 info->GetWebContentsGetterForRequest(), url_request->url(), |
| 874 info->GetFrameTreeNodeIdGetterForRequest(), | 872 info->GetGlobalRequestID(), info->GetResourceType(), |
| 875 url_request->url(), info->GetGlobalRequestID(), | 873 url_request->was_cached(), |
| 876 info->GetResourceType(), url_request->was_cached(), | |
| 877 base::Passed(&data_reduction_proxy_data), net_error, | 874 base::Passed(&data_reduction_proxy_data), net_error, |
| 878 url_request->GetTotalReceivedBytes(), | 875 url_request->GetTotalReceivedBytes(), |
| 879 url_request->GetRawBodyBytes(), original_content_length, | 876 url_request->GetRawBodyBytes(), original_content_length, |
| 880 url_request->creation_time(), | 877 url_request->creation_time(), |
| 881 base::TimeTicks::Now() - url_request->creation_time())); | 878 base::TimeTicks::Now() - url_request->creation_time())); |
| 882 } | 879 } |
| 883 | 880 |
| 884 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState( | 881 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState( |
| 885 const net::URLRequest& url_request, | 882 const net::URLRequest& url_request, |
| 886 content::ResourceContext* resource_context) { | 883 content::ResourceContext* resource_context) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 &ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 951 &ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
| 955 base::Unretained(this), url, request_loading_time)); | 952 base::Unretained(this), url, request_loading_time)); |
| 956 return; | 953 return; |
| 957 } | 954 } |
| 958 | 955 |
| 959 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 956 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
| 960 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 957 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
| 961 rappor::SampleDomainAndRegistryFromGURL( | 958 rappor::SampleDomainAndRegistryFromGURL( |
| 962 g_browser_process->rappor_service(), metric_name, url); | 959 g_browser_process->rappor_service(), metric_name, url); |
| 963 } | 960 } |
| OLD | NEW |