Chromium Code Reviews| 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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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::WebContentsGetter& web_contents_getter, |
| 350 const GURL& url, | 350 const GURL& url, |
| 351 const content::GlobalRequestID& request_id, | 351 const content::GlobalRequestID& request_id, |
| 352 ResourceType resource_type, | 352 ResourceType resource_type, |
| 353 bool was_cached, | 353 bool was_cached, |
| 354 bool used_data_reduction_proxy, | 354 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> |
| 355 data_reduction_proxy_data, | |
| 355 int net_error, | 356 int net_error, |
| 356 int64_t total_received_bytes, | 357 int64_t total_received_bytes, |
| 357 int64_t raw_body_bytes, | 358 int64_t raw_body_bytes, |
| 358 int64_t original_content_length, | 359 int64_t original_content_length, |
| 359 base::TimeTicks request_creation_time, | 360 base::TimeTicks request_creation_time, |
| 360 base::TimeDelta request_loading_time) { | 361 base::TimeDelta request_loading_time) { |
| 361 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 362 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 362 content::WebContents* web_contents = web_contents_getter.Run(); | 363 content::WebContents* web_contents = web_contents_getter.Run(); |
| 363 if (!web_contents) | 364 if (!web_contents) |
| 364 return; | 365 return; |
| 365 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) { | 366 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) { |
| 366 LogMainFrameMetricsOnUIThread(url, net_error, request_loading_time, | 367 LogMainFrameMetricsOnUIThread(url, net_error, request_loading_time, |
| 367 web_contents); | 368 web_contents); |
| 368 } | 369 } |
| 369 if (!was_cached) { | 370 if (!was_cached) { |
| 370 UpdatePrerenderNetworkBytesCallback(web_contents, total_received_bytes); | 371 UpdatePrerenderNetworkBytesCallback(web_contents, total_received_bytes); |
| 371 #if defined(OS_ANDROID) | 372 #if defined(OS_ANDROID) |
| 372 offline_pages::BackgroundLoaderOffliner* background_loader = | 373 offline_pages::BackgroundLoaderOffliner* background_loader = |
| 373 offline_pages::BackgroundLoaderOffliner::FromWebContents(web_contents); | 374 offline_pages::BackgroundLoaderOffliner::FromWebContents(web_contents); |
| 374 | 375 |
| 375 if (background_loader) | 376 if (background_loader) |
| 376 background_loader->OnNetworkBytesChanged(total_received_bytes); | 377 background_loader->OnNetworkBytesChanged(total_received_bytes); |
| 377 #endif // OS_ANDROID | 378 #endif // OS_ANDROID |
| 378 } | 379 } |
| 379 page_load_metrics::MetricsWebContentsObserver* metrics_observer = | 380 page_load_metrics::MetricsWebContentsObserver* metrics_observer = |
| 380 page_load_metrics::MetricsWebContentsObserver::FromWebContents( | 381 page_load_metrics::MetricsWebContentsObserver::FromWebContents( |
| 381 web_contents); | 382 web_contents); |
| 382 if (metrics_observer) { | 383 if (metrics_observer) { |
| 383 metrics_observer->OnRequestComplete( | 384 metrics_observer->OnRequestComplete(request_id, resource_type, was_cached, |
| 384 request_id, resource_type, was_cached, used_data_reduction_proxy, | 385 std::move(data_reduction_proxy_data), |
| 385 raw_body_bytes, original_content_length, request_creation_time); | 386 raw_body_bytes, original_content_length, |
| 387 request_creation_time); | |
| 386 } | 388 } |
| 387 } | 389 } |
| 388 | 390 |
| 389 } // namespace | 391 } // namespace |
| 390 | 392 |
| 391 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() | 393 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() |
| 392 : download_request_limiter_(g_browser_process->download_request_limiter()), | 394 : download_request_limiter_(g_browser_process->download_request_limiter()), |
| 393 safe_browsing_(g_browser_process->safe_browsing_service()) | 395 safe_browsing_(g_browser_process->safe_browsing_service()) |
| 394 #if BUILDFLAG(ENABLE_EXTENSIONS) | 396 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 395 , user_script_listener_(new extensions::UserScriptListener()) | 397 , user_script_listener_(new extensions::UserScriptListener()) |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 816 if (!url_request) | 818 if (!url_request) |
| 817 return; | 819 return; |
| 818 // TODO(maksims): remove this and use net_error argument in RequestComplete | 820 // TODO(maksims): remove this and use net_error argument in RequestComplete |
| 819 // once ResourceDispatcherHostDelegate is modified. | 821 // once ResourceDispatcherHostDelegate is modified. |
| 820 int net_error = url_request->status().error(); | 822 int net_error = url_request->status().error(); |
| 821 const ResourceRequestInfo* info = | 823 const ResourceRequestInfo* info = |
| 822 ResourceRequestInfo::ForRequest(url_request); | 824 ResourceRequestInfo::ForRequest(url_request); |
| 823 | 825 |
| 824 data_reduction_proxy::DataReductionProxyData* data = | 826 data_reduction_proxy::DataReductionProxyData* data = |
| 825 data_reduction_proxy::DataReductionProxyData::GetData(*url_request); | 827 data_reduction_proxy::DataReductionProxyData::GetData(*url_request); |
| 826 bool used_data_reduction_proxy = data && data->used_data_reduction_proxy(); | 828 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> |
| 829 data_reduction_proxy_data; | |
| 830 if (data) | |
| 831 data_reduction_proxy_data = data->DeepCopy(); | |
|
bengr
2017/04/20 23:19:35
It's too bad you have to pass along the session ke
RyanSturm
2017/04/21 16:25:04
It's only for main frame requests, but still unfor
| |
| 827 int64_t original_content_length = | 832 int64_t original_content_length = |
| 828 used_data_reduction_proxy | 833 data && data->used_data_reduction_proxy() |
| 829 ? data_reduction_proxy::util::CalculateEffectiveOCL(*url_request) | 834 ? data_reduction_proxy::util::CalculateEffectiveOCL(*url_request) |
| 830 : url_request->GetRawBodyBytes(); | 835 : url_request->GetRawBodyBytes(); |
| 831 | 836 |
| 832 BrowserThread::PostTask( | 837 BrowserThread::PostTask( |
| 833 BrowserThread::UI, FROM_HERE, | 838 BrowserThread::UI, FROM_HERE, |
| 834 base::BindOnce(&NotifyUIThreadOfRequestComplete, | 839 base::BindOnce(&NotifyUIThreadOfRequestComplete, |
| 835 info->GetWebContentsGetterForRequest(), url_request->url(), | 840 info->GetWebContentsGetterForRequest(), url_request->url(), |
| 836 info->GetGlobalRequestID(), info->GetResourceType(), | 841 info->GetGlobalRequestID(), info->GetResourceType(), |
| 837 url_request->was_cached(), used_data_reduction_proxy, | 842 url_request->was_cached(), |
| 838 net_error, url_request->GetTotalReceivedBytes(), | 843 base::Passed(&data_reduction_proxy_data), net_error, |
| 844 url_request->GetTotalReceivedBytes(), | |
| 839 url_request->GetRawBodyBytes(), original_content_length, | 845 url_request->GetRawBodyBytes(), original_content_length, |
| 840 url_request->creation_time(), | 846 url_request->creation_time(), |
| 841 base::TimeTicks::Now() - url_request->creation_time())); | 847 base::TimeTicks::Now() - url_request->creation_time())); |
| 842 } | 848 } |
| 843 | 849 |
| 844 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState( | 850 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState( |
| 845 const net::URLRequest& url_request, | 851 const net::URLRequest& url_request, |
| 846 content::ResourceContext* resource_context) { | 852 content::ResourceContext* resource_context) { |
| 847 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 853 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| 848 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = | 854 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 914 &ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 920 &ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
| 915 base::Unretained(this), url, request_loading_time)); | 921 base::Unretained(this), url, request_loading_time)); |
| 916 return; | 922 return; |
| 917 } | 923 } |
| 918 | 924 |
| 919 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 925 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
| 920 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 926 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
| 921 rappor::SampleDomainAndRegistryFromGURL( | 927 rappor::SampleDomainAndRegistryFromGURL( |
| 922 g_browser_process->rappor_service(), metric_name, url); | 928 g_browser_process->rappor_service(), metric_name, url); |
| 923 } | 929 } |
| OLD | NEW |