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

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

Issue 2780003003: Send an event to the page load metrics to track resource starting. (Closed)
Patch Set: FREEZE.unindexed - took merge and fixed it up Created 3 years, 8 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
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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 if (net_error == net::OK) { 338 if (net_error == net::OK) {
339 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.Success", 339 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.Success",
340 request_loading_time); 340 request_loading_time);
341 } else if (net_error == net::ERR_ABORTED) { 341 } else if (net_error == net::ERR_ABORTED) {
342 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.ErrAborted", 342 UMA_HISTOGRAM_LONG_TIMES("Net.NTP.Local.RequestTime2.ErrAborted",
343 request_loading_time); 343 request_loading_time);
344 } 344 }
345 } 345 }
346 } 346 }
347 347
348 void NotifyUIThreadOfRequestStarted(
349 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
350 const content::GlobalRequestID& request_id,
351 ResourceType resource_type,
352 base::TimeTicks request_creation_time) {
353 content::WebContents* web_contents = web_contents_getter.Run();
354
355 if (!web_contents)
356 return;
357
358 page_load_metrics::MetricsWebContentsObserver* metrics_observer =
359 page_load_metrics::MetricsWebContentsObserver::FromWebContents(
360 web_contents);
361
362 if (metrics_observer) {
363 metrics_observer->OnRequestStarted(request_id, resource_type,
364 request_creation_time);
365 }
366 }
367
348 void NotifyUIThreadOfRequestComplete( 368 void NotifyUIThreadOfRequestComplete(
349 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, 369 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter,
350 const GURL& url, 370 const GURL& url,
351 const content::GlobalRequestID& request_id, 371 const content::GlobalRequestID& request_id,
352 ResourceType resource_type, 372 ResourceType resource_type,
353 bool was_cached, 373 bool was_cached,
354 std::unique_ptr<data_reduction_proxy::DataReductionProxyData> 374 std::unique_ptr<data_reduction_proxy::DataReductionProxyData>
355 data_reduction_proxy_data, 375 data_reduction_proxy_data,
356 int net_error, 376 int net_error,
357 int64_t total_received_bytes, 377 int64_t total_received_bytes,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 void ChromeResourceDispatcherHostDelegate::RequestBeginning( 459 void ChromeResourceDispatcherHostDelegate::RequestBeginning(
440 net::URLRequest* request, 460 net::URLRequest* request,
441 content::ResourceContext* resource_context, 461 content::ResourceContext* resource_context,
442 content::AppCacheService* appcache_service, 462 content::AppCacheService* appcache_service,
443 ResourceType resource_type, 463 ResourceType resource_type,
444 std::vector<std::unique_ptr<content::ResourceThrottle>>* throttles) { 464 std::vector<std::unique_ptr<content::ResourceThrottle>>* throttles) {
445 if (safe_browsing_.get()) 465 if (safe_browsing_.get())
446 safe_browsing_->OnResourceRequest(request); 466 safe_browsing_->OnResourceRequest(request);
447 467
448 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 468 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
469
470 // TODO(petewil): Unify the safe browsing request and the metrics observer
471 // request if possible so we only have to cross to the main thread once.
472 // http://crbug.com/712312.
473 BrowserThread::PostTask(
474 BrowserThread::UI, FROM_HERE,
475 base::Bind(&NotifyUIThreadOfRequestStarted,
476 info->GetWebContentsGetterForRequest(),
477 info->GetGlobalRequestID(), info->GetResourceType(),
478 request->creation_time()));
479
449 ProfileIOData* io_data = ProfileIOData::FromResourceContext( 480 ProfileIOData* io_data = ProfileIOData::FromResourceContext(
450 resource_context); 481 resource_context);
451 482
452 #if defined(OS_ANDROID) 483 #if defined(OS_ANDROID)
453 if (resource_type != content::RESOURCE_TYPE_MAIN_FRAME) 484 if (resource_type != content::RESOURCE_TYPE_MAIN_FRAME)
454 InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo(request); 485 InterceptNavigationDelegate::UpdateUserGestureCarryoverInfo(request);
455 #endif 486 #endif
456 487
457 #if defined(OS_CHROMEOS) 488 #if defined(OS_CHROMEOS)
458 // Check if we need to add merge session throttle. This throttle will postpone 489 // Check if we need to add merge session throttle. This throttle will postpone
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 &ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 951 &ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
921 base::Unretained(this), url, request_loading_time)); 952 base::Unretained(this), url, request_loading_time));
922 return; 953 return;
923 } 954 }
924 955
925 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 956 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
926 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 957 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
927 rappor::SampleDomainAndRegistryFromGURL( 958 rappor::SampleDomainAndRegistryFromGURL(
928 g_browser_process->rappor_service(), metric_name, url); 959 g_browser_process->rappor_service(), metric_name, url);
929 } 960 }
OLDNEW
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | 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