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

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

Issue 2917873003: Ignore download bytes in page load metrics. (Closed)
Patch Set: address comment Created 3 years, 6 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/page_load_metrics_browsertest.cc » ('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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.ErrAborted", 343 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.ErrAborted",
344 request_loading_time); 344 request_loading_time);
345 } 345 }
346 } 346 }
347 } 347 }
348 348
349 void NotifyUIThreadOfRequestStarted( 349 void NotifyUIThreadOfRequestStarted(
350 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, 350 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
351 const content::GlobalRequestID& request_id, 351 const content::GlobalRequestID& request_id,
352 ResourceType resource_type, 352 ResourceType resource_type,
353 bool is_download,
353 base::TimeTicks request_creation_time) { 354 base::TimeTicks request_creation_time) {
354 content::WebContents* web_contents = web_contents_getter.Run(); 355 content::WebContents* web_contents = web_contents_getter.Run();
355
356 if (!web_contents) 356 if (!web_contents)
357 return; 357 return;
358 358
359 page_load_metrics::MetricsWebContentsObserver* metrics_observer = 359 if (!is_download) {
360 page_load_metrics::MetricsWebContentsObserver::FromWebContents( 360 page_load_metrics::MetricsWebContentsObserver* metrics_observer =
361 web_contents); 361 page_load_metrics::MetricsWebContentsObserver::FromWebContents(
362 web_contents);
362 363
363 if (metrics_observer) { 364 if (metrics_observer) {
364 metrics_observer->OnRequestStarted(request_id, resource_type, 365 metrics_observer->OnRequestStarted(request_id, resource_type,
365 request_creation_time); 366 request_creation_time);
367 }
366 } 368 }
367 } 369 }
368 370
369 void NotifyUIThreadOfRequestComplete( 371 void NotifyUIThreadOfRequestComplete(
370 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, 372 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
371 const content::ResourceRequestInfo::FrameTreeNodeIdGetter& 373 const content::ResourceRequestInfo::FrameTreeNodeIdGetter&
372 frame_tree_node_id_getter, 374 frame_tree_node_id_getter,
373 const GURL& url, 375 const GURL& url,
374 const content::GlobalRequestID& request_id, 376 const content::GlobalRequestID& request_id,
375 ResourceType resource_type, 377 ResourceType resource_type,
378 bool is_download,
376 bool was_cached, 379 bool was_cached,
377 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> 380 std::unique_ptr<data_reduction_proxy::DataReductionProxyData>
378 data_reduction_proxy_data, 381 data_reduction_proxy_data,
379 int net_error, 382 int net_error,
380 int64_t total_received_bytes, 383 int64_t total_received_bytes,
381 int64_t raw_body_bytes, 384 int64_t raw_body_bytes,
382 int64_t original_content_length, 385 int64_t original_content_length,
383 base::TimeTicks request_creation_time, 386 base::TimeTicks request_creation_time,
384 base::TimeDelta request_loading_time) { 387 base::TimeDelta request_loading_time) {
385 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 388 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
386 content::WebContents* web_contents = web_contents_getter.Run(); 389 content::WebContents* web_contents = web_contents_getter.Run();
387 if (!web_contents) 390 if (!web_contents)
388 return; 391 return;
389 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) { 392 if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) {
390 LogMainFrameMetricsOnUIThread(url, net_error, request_loading_time, 393 LogMainFrameMetricsOnUIThread(url, net_error, request_loading_time,
391 web_contents); 394 web_contents);
392 } 395 }
393 if (!was_cached) { 396 if (!was_cached) {
394 UpdatePrerenderNetworkBytesCallback(web_contents, total_received_bytes); 397 UpdatePrerenderNetworkBytesCallback(web_contents, total_received_bytes);
395 #if defined(OS_ANDROID) 398 #if defined(OS_ANDROID)
396 offline_pages::BackgroundLoaderOffliner* background_loader = 399 offline_pages::BackgroundLoaderOffliner* background_loader =
397 offline_pages::BackgroundLoaderOffliner::FromWebContents(web_contents); 400 offline_pages::BackgroundLoaderOffliner::FromWebContents(web_contents);
398 401
399 if (background_loader) 402 if (background_loader)
400 background_loader->OnNetworkBytesChanged(total_received_bytes); 403 background_loader->OnNetworkBytesChanged(total_received_bytes);
401 #endif // OS_ANDROID 404 #endif // OS_ANDROID
402 } 405 }
403 page_load_metrics::MetricsWebContentsObserver* metrics_observer = 406 if (!is_download) {
404 page_load_metrics::MetricsWebContentsObserver::FromWebContents( 407 page_load_metrics::MetricsWebContentsObserver* metrics_observer =
405 web_contents); 408 page_load_metrics::MetricsWebContentsObserver::FromWebContents(
406 if (metrics_observer) { 409 web_contents);
407 metrics_observer->OnRequestComplete( 410 if (metrics_observer) {
408 url, frame_tree_node_id_getter.Run(), request_id, resource_type, 411 metrics_observer->OnRequestComplete(
409 was_cached, std::move(data_reduction_proxy_data), raw_body_bytes, 412 url, frame_tree_node_id_getter.Run(), request_id, resource_type,
410 original_content_length, request_creation_time); 413 was_cached, std::move(data_reduction_proxy_data), raw_body_bytes,
414 original_content_length, request_creation_time);
415 }
411 } 416 }
412 } 417 }
413 418
414 } // namespace 419 } // namespace
415 420
416 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate() 421 ChromeResourceDispatcherHostDelegate::ChromeResourceDispatcherHostDelegate()
417 : download_request_limiter_(g_browser_process->download_request_limiter()), 422 : download_request_limiter_(g_browser_process->download_request_limiter()),
418 safe_browsing_(g_browser_process->safe_browsing_service()) 423 safe_browsing_(g_browser_process->safe_browsing_service())
419 #if BUILDFLAG(ENABLE_EXTENSIONS) 424 #if BUILDFLAG(ENABLE_EXTENSIONS)
420 , user_script_listener_(new extensions::UserScriptListener()) 425 , user_script_listener_(new extensions::UserScriptListener())
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 476 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
472 477
473 // TODO(petewil): Unify the safe browsing request and the metrics observer 478 // TODO(petewil): Unify the safe browsing request and the metrics observer
474 // request if possible so we only have to cross to the main thread once. 479 // request if possible so we only have to cross to the main thread once.
475 // http://crbug.com/712312. 480 // http://crbug.com/712312.
476 BrowserThread::PostTask( 481 BrowserThread::PostTask(
477 BrowserThread::UI, FROM_HERE, 482 BrowserThread::UI, FROM_HERE,
478 base::Bind(&NotifyUIThreadOfRequestStarted, 483 base::Bind(&NotifyUIThreadOfRequestStarted,
479 info->GetWebContentsGetterForRequest(), 484 info->GetWebContentsGetterForRequest(),
480 info->GetGlobalRequestID(), info->GetResourceType(), 485 info->GetGlobalRequestID(), info->GetResourceType(),
481 request->creation_time())); 486 info->IsDownload(), request->creation_time()));
482 487
483 ProfileIOData* io_data = ProfileIOData::FromResourceContext( 488 ProfileIOData* io_data = ProfileIOData::FromResourceContext(
484 resource_context); 489 resource_context);
485 490
486 #if defined(OS_ANDROID) 491 #if defined(OS_ANDROID)
487 if (resource_type != content::RESOURCE_TYPE_MAIN_FRAME) 492 if (resource_type != content::RESOURCE_TYPE_MAIN_FRAME)
488 InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo(request); 493 InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo(request);
489 #endif 494 #endif
490 495
491 #if defined(OS_CHROMEOS) 496 #if defined(OS_CHROMEOS)
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 data_reduction_proxy_data; 868 data_reduction_proxy_data;
864 if (data) 869 if (data)
865 data_reduction_proxy_data = data->DeepCopy(); 870 data_reduction_proxy_data = data->DeepCopy();
866 int64_t original_content_length = 871 int64_t original_content_length =
867 data && data->used_data_reduction_proxy() 872 data && data->used_data_reduction_proxy()
868 ? data_reduction_proxy::util::CalculateEffectiveOCL(*url_request) 873 ? data_reduction_proxy::util::CalculateEffectiveOCL(*url_request)
869 : url_request->GetRawBodyBytes(); 874 : url_request->GetRawBodyBytes();
870 875
871 BrowserThread::PostTask( 876 BrowserThread::PostTask(
872 BrowserThread::UI, FROM_HERE, 877 BrowserThread::UI, FROM_HERE,
873 base::BindOnce(&NotifyUIThreadOfRequestComplete, 878 base::BindOnce(
874 info->GetWebContentsGetterForRequest(), 879 &NotifyUIThreadOfRequestComplete,
875 info->GetFrameTreeNodeIdGetterForRequest(), 880 info->GetWebContentsGetterForRequest(),
876 url_request->url(), info->GetGlobalRequestID(), 881 info->GetFrameTreeNodeIdGetterForRequest(), url_request->url(),
877 info->GetResourceType(), url_request->was_cached(), 882 info->GetGlobalRequestID(), info->GetResourceType(),
878 base::Passed(&data_reduction_proxy_data), net_error, 883 info->IsDownload(), url_request->was_cached(),
879 url_request->GetTotalReceivedBytes(), 884 base::Passed(&data_reduction_proxy_data), net_error,
880 url_request->GetRawBodyBytes(), original_content_length, 885 url_request->GetTotalReceivedBytes(), url_request->GetRawBodyBytes(),
881 url_request->creation_time(), 886 original_content_length, url_request->creation_time(),
882 base::TimeTicks::Now() - url_request->creation_time())); 887 base::TimeTicks::Now() - url_request->creation_time()));
883 } 888 }
884 889
885 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState( 890 content::PreviewsState ChromeResourceDispatcherHostDelegate::GetPreviewsState(
886 const net::URLRequest& url_request, 891 const net::URLRequest& url_request,
887 content::ResourceContext* resource_context) { 892 content::ResourceContext* resource_context) {
888 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 893 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
889 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data = 894 data_reduction_proxy::DataReductionProxyIOData* data_reduction_proxy_io_data =
890 io_data->data_reduction_proxy_io_data(); 895 io_data->data_reduction_proxy_io_data();
891 896
892 content::PreviewsState previews_state = content::PREVIEWS_UNSPECIFIED; 897 content::PreviewsState previews_state = content::PREVIEWS_UNSPECIFIED;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 &ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 970 &ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
966 base::Unretained(this), url, request_loading_time)); 971 base::Unretained(this), url, request_loading_time));
967 return; 972 return;
968 } 973 }
969 974
970 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 975 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
971 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 976 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
972 rappor::SampleDomainAndRegistryFromGURL( 977 rappor::SampleDomainAndRegistryFromGURL(
973 g_browser_process->rappor_service(), metric_name, url); 978 g_browser_process->rappor_service(), metric_name, url);
974 } 979 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/page_load_metrics/page_load_metrics_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698