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

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

Issue 2560043004: [PageLoadMetrics] Record bytes usage per page (Closed)
Patch Set: Include main frame resource Created 4 years 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
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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
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,
363 base::TimeTicks request_creation_time,
362 base::TimeDelta request_loading_time) { 364 base::TimeDelta request_loading_time) {
363 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 365 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
364 content::WebContents* web_contents = web_contents_getter.Run(); 366 content::WebContents* web_contents = web_contents_getter.Run();
365 if (!web_contents) 367 if (!web_contents)
366 return; 368 return;
367 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) { 369 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) {
368 LogMainFrameMetricsOnUIThread(url, net_error, request_loading_time, 370 LogMainFrameMetricsOnUIThread(url, net_error, request_loading_time,
369 web_contents); 371 web_contents);
370 } 372 }
371 if (!was_cached) 373 if (!was_cached)
372 UpdatePrerenderNetworkBytesCallback(web_contents, total_received_bytes); 374 UpdatePrerenderNetworkBytesCallback(web_contents, total_received_bytes);
373 page_load_metrics::MetricsWebContentsObserver* metrics_observer = 375 page_load_metrics::MetricsWebContentsObserver* metrics_observer =
374 page_load_metrics::MetricsWebContentsObserver::FromWebContents( 376 page_load_metrics::MetricsWebContentsObserver::FromWebContents(
375 web_contents); 377 web_contents);
376 if (metrics_observer) { 378 if (metrics_observer) {
377 metrics_observer->OnRequestComplete(resource_type, was_cached, net_error); 379 metrics_observer->OnRequestComplete(resource_type, was_cached,
380 raw_body_bytes, request_creation_time);
378 } 381 }
379 } 382 }
380 383
381 } // namespace 384 } // namespace
382 385
383 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() 386 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate()
384 : download_request_limiter_(g_browser_process->download_request_limiter()), 387 : download_request_limiter_(g_browser_process->download_request_limiter()),
385 safe_browsing_(g_browser_process->safe_browsing_service()) 388 safe_browsing_(g_browser_process->safe_browsing_service())
386 #if BUILDFLAG(ENABLE_EXTENSIONS) 389 #if BUILDFLAG(ENABLE_EXTENSIONS)
387 , user_script_listener_(new extensions::UserScriptListener()) 390 , user_script_listener_(new extensions::UserScriptListener())
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 // once ResourceDispatcherHostDelegate is modified. 825 // once ResourceDispatcherHostDelegate is modified.
823 int net_error = url_request->status().error(); 826 int net_error = url_request->status().error();
824 const ResourceRequestInfo* info = 827 const ResourceRequestInfo* info =
825 ResourceRequestInfo::ForRequest(url_request); 828 ResourceRequestInfo::ForRequest(url_request);
826 BrowserThread::PostTask( 829 BrowserThread::PostTask(
827 BrowserThread::UI, FROM_HERE, 830 BrowserThread::UI, FROM_HERE,
828 base::Bind(&NotifyUIThreadOfRequestComplete, 831 base::Bind(&NotifyUIThreadOfRequestComplete,
829 info->GetWebContentsGetterForRequest(), url_request->url(), 832 info->GetWebContentsGetterForRequest(), url_request->url(),
830 info->GetResourceType(), url_request->was_cached(), net_error, 833 info->GetResourceType(), url_request->was_cached(), net_error,
831 url_request->GetTotalReceivedBytes(), 834 url_request->GetTotalReceivedBytes(),
835 url_request->GetRawBodyBytes(), url_request->creation_time(),
832 base::TimeTicks::Now() - url_request->creation_time())); 836 base::TimeTicks::Now() - url_request->creation_time()));
833 } 837 }
834 838
835 bool ChromeResourceDispatcherHostDelegate::ShouldEnableLoFiMode( 839 bool ChromeResourceDispatcherHostDelegate::ShouldEnableLoFiMode(
836 const net::URLRequest& url_request, 840 const net::URLRequest& url_request,
837 content::ResourceContext* resource_context) { 841 content::ResourceContext* resource_context) {
838 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 842 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
839 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = 843 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data =
840 io_data->data_reduction_proxy_io_data(); 844 io_data->data_reduction_proxy_io_data();
841 845
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 892 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
889 base::Unretained(this), url, request_loading_time)); 893 base::Unretained(this), url, request_loading_time));
890 return; 894 return;
891 } 895 }
892 896
893 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 897 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
894 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 898 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
895 rappor::SampleDomainAndRegistryFromGURL( 899 rappor::SampleDomainAndRegistryFromGURL(
896 g_browser_process->rappor_service(), metric_name, url); 900 g_browser_process->rappor_service(), metric_name, url);
897 } 901 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698