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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | 354 |
| 355 void NotifyUIThreadOfRequestComplete( | 355 void NotifyUIThreadOfRequestComplete( |
| 356 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | 356 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
| 357 const GURL& url, | 357 const GURL& url, |
| 358 content::ResourceType resource_type, | 358 content::ResourceType resource_type, |
| 359 bool was_cached, | 359 bool was_cached, |
| 360 int net_error, | 360 int net_error, |
| 361 int64_t total_received_bytes, | 361 int64_t total_received_bytes, |
| 362 int64_t raw_body_bytes, | |
| 362 base::TimeDelta request_loading_time) { | 363 base::TimeDelta request_loading_time) { |
| 363 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 364 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 364 content::WebContents* web_contents = web_contents_getter.Run(); | 365 content::WebContents* web_contents = web_contents_getter.Run(); |
| 365 if (!web_contents) | 366 if (!web_contents) |
| 366 return; | 367 return; |
| 367 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) { | 368 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) { |
| 368 LogMainFrameMetricsOnUIThread(url, net_error, request_loading_time, | 369 LogMainFrameMetricsOnUIThread(url, net_error, request_loading_time, |
| 369 web_contents); | 370 web_contents); |
| 370 } | 371 } |
| 371 if (!was_cached) | 372 if (!was_cached) |
| 372 UpdatePrerenderNetworkBytesCallback(web_contents, total_received_bytes); | 373 UpdatePrerenderNetworkBytesCallback(web_contents, total_received_bytes); |
| 373 page_load_metrics::MetricsWebContentsObserver* metrics_observer = | 374 page_load_metrics::MetricsWebContentsObserver* metrics_observer = |
| 374 page_load_metrics::MetricsWebContentsObserver::FromWebContents( | 375 page_load_metrics::MetricsWebContentsObserver::FromWebContents( |
| 375 web_contents); | 376 web_contents); |
| 376 if (metrics_observer) { | 377 if (metrics_observer) { |
| 377 metrics_observer->OnRequestComplete(resource_type, was_cached, net_error); | 378 metrics_observer->OnRequestComplete(resource_type, was_cached, net_error, |
| 379 raw_body_bytes); | |
| 378 } | 380 } |
| 379 } | 381 } |
| 380 | 382 |
| 381 } // namespace | 383 } // namespace |
| 382 | 384 |
| 383 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() | 385 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() |
| 384 : download_request_limiter_(g_browser_process->download_request_limiter()), | 386 : download_request_limiter_(g_browser_process->download_request_limiter()), |
| 385 safe_browsing_(g_browser_process->safe_browsing_service()) | 387 safe_browsing_(g_browser_process->safe_browsing_service()) |
| 386 #if BUILDFLAG(ENABLE_EXTENSIONS) | 388 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 387 , user_script_listener_(new extensions::UserScriptListener()) | 389 , user_script_listener_(new extensions::UserScriptListener()) |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 BrowserThread::PostTask( | 825 BrowserThread::PostTask( |
| 824 BrowserThread::UI, FROM_HERE, | 826 BrowserThread::UI, FROM_HERE, |
| 825 base::Bind(&NotifyUIThreadOfRequestComplete, | 827 base::Bind(&NotifyUIThreadOfRequestComplete, |
| 826 info->GetWebContentsGetterForRequest(), url_request->url(), | 828 info->GetWebContentsGetterForRequest(), url_request->url(), |
| 827 info->GetResourceType(), url_request->was_cached(), net_error, | 829 info->GetResourceType(), url_request->was_cached(), net_error, |
| 828 url_request->GetTotalReceivedBytes(), | 830 url_request->GetTotalReceivedBytes(), |
| 831 url_request->GetRawBodyBytes(), | |
|
RyanSturm
2016/12/12 22:29:38
I'm curious why you are using GetRawBodyBytes inst
jkarlin
2016/12/19 19:26:01
Right now only tracking received bytes. I'm using
RyanSturm
2016/12/19 19:40:05
I thought both of these tracked bytes after decodi
jkarlin
2016/12/20 14:03:58
You're right that they both track bytes before dec
| |
| 829 base::TimeTicks::Now() - url_request->creation_time())); | 832 base::TimeTicks::Now() - url_request->creation_time())); |
| 830 } | 833 } |
| 831 | 834 |
| 832 bool ChromeResourceDispatcherHostDelegate::ShouldEnableLoFiMode( | 835 bool ChromeResourceDispatcherHostDelegate::ShouldEnableLoFiMode( |
| 833 const net::URLRequest& url_request, | 836 const net::URLRequest& url_request, |
| 834 content::ResourceContext* resource_context) { | 837 content::ResourceContext* resource_context) { |
| 835 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 838 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| 836 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = | 839 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = |
| 837 io_data->data_reduction_proxy_io_data(); | 840 io_data->data_reduction_proxy_io_data(); |
| 838 | 841 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 885 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, | 888 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, |
| 886 base::Unretained(this), url, request_loading_time)); | 889 base::Unretained(this), url, request_loading_time)); |
| 887 return; | 890 return; |
| 888 } | 891 } |
| 889 | 892 |
| 890 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? | 893 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? |
| 891 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); | 894 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); |
| 892 rappor::SampleDomainAndRegistryFromGURL( | 895 rappor::SampleDomainAndRegistryFromGURL( |
| 893 g_browser_process->rappor_service(), metric_name, url); | 896 g_browser_process->rappor_service(), metric_name, url); |
| 894 } | 897 } |
| OLD | NEW |