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

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

Issue 2560043004: [PageLoadMetrics] Record bytes usage per page (Closed)
Patch Set: Fix test Created 3 years, 11 months 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
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/metrics_web_contents_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ResourceType resource_type, 358 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 // once ResourceDispatcherHostDelegate is modified. 832 // once ResourceDispatcherHostDelegate is modified.
830 int net_error = url_request->status().error(); 833 int net_error = url_request->status().error();
831 const ResourceRequestInfo* info = 834 const ResourceRequestInfo* info =
832 ResourceRequestInfo::ForRequest(url_request); 835 ResourceRequestInfo::ForRequest(url_request);
833 BrowserThread::PostTask( 836 BrowserThread::PostTask(
834 BrowserThread::UI, FROM_HERE, 837 BrowserThread::UI, FROM_HERE,
835 base::Bind(&NotifyUIThreadOfRequestComplete, 838 base::Bind(&NotifyUIThreadOfRequestComplete,
836 info->GetWebContentsGetterForRequest(), url_request->url(), 839 info->GetWebContentsGetterForRequest(), url_request->url(),
837 info->GetResourceType(), url_request->was_cached(), net_error, 840 info->GetResourceType(), url_request->was_cached(), net_error,
838 url_request->GetTotalReceivedBytes(), 841 url_request->GetTotalReceivedBytes(),
842 url_request->GetRawBodyBytes(), url_request->creation_time(),
839 base::TimeTicks::Now() - url_request->creation_time())); 843 base::TimeTicks::Now() - url_request->creation_time()));
840 } 844 }
841 845
842 bool ChromeResourceDispatcherHostDelegate::ShouldEnableLoFiMode( 846 bool ChromeResourceDispatcherHostDelegate::ShouldEnableLoFiMode(
843 const net::URLRequest& url_request, 847 const net::URLRequest& url_request,
844 content::ResourceContext* resource_context) { 848 content::ResourceContext* resource_context) {
845 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 849 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
846 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = 850 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data =
847 io_data->data_reduction_proxy_io_data(); 851 io_data->data_reduction_proxy_io_data();
848 852
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 899 base::Bind(&ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
896 base::Unretained(this), url, request_loading_time)); 900 base::Unretained(this), url, request_loading_time));
897 return; 901 return;
898 } 902 }
899 903
900 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 904 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
901 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 905 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
902 rappor::SampleDomainAndRegistryFromGURL( 906 rappor::SampleDomainAndRegistryFromGURL(
903 g_browser_process->rappor_service(), metric_name, url); 907 g_browser_process->rappor_service(), metric_name, url);
904 } 908 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/metrics_web_contents_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698