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

Unified Diff: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc

Issue 2780003003: Send an event to the page load metrics to track resource starting. (Closed)
Patch Set: CR feedback per bmcquade 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
diff --git a/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc b/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
index a58984656eec1b8effd05e16e67ee570f0d744ab..309817c3441e530fa56a8d1f78b561c7eda358d6 100644
--- a/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
+++ b/chrome/browser/page_load_metrics/metrics_web_contents_observer.cc
@@ -252,6 +252,22 @@ PageLoadTracker* MetricsWebContentsObserver::GetTrackerOrNullForRequest(
return nullptr;
}
+void MetricsWebContentsObserver::OnRequestStarted(
+ const content::GlobalRequestID& request_id,
+ content::ResourceType resource_type,
+ base::TimeTicks creation_time) {
+ // Note for the main HTML page, the tracker may not exist yet, so
Bryan McQuade 2017/04/24 13:56:55 interesting - the fact that the tracker doesn't ex
Pete Williamson 2017/04/24 19:53:14 Done.
+ // OnStartedResource will not be called for the main page. While the main
+ // page is not being tracked today, if we do decide to track it, we will need
+ // to first make sure that GlobalRequestID is set in an earlier callback.
+ PageLoadTracker* tracker =
+ GetTrackerOrNullForRequest(request_id, resource_type, creation_time);
+ if (tracker) {
+ ExtraRequestStartInfo extra_request_start_info(resource_type);
+ tracker->OnStartedResource(extra_request_start_info);
+ }
+}
+
void MetricsWebContentsObserver::OnRequestComplete(
const content::GlobalRequestID& request_id,
content::ResourceType resource_type,
@@ -263,10 +279,10 @@ void MetricsWebContentsObserver::OnRequestComplete(
PageLoadTracker* tracker =
GetTrackerOrNullForRequest(request_id, resource_type, creation_time);
if (tracker) {
- ExtraRequestInfo extra_request_info(
+ ExtraRequestCompleteInfo extra_request_complete_info(
was_cached, raw_body_bytes, used_data_reduction_proxy,
- was_cached ? 0 : original_content_length);
- tracker->OnLoadedResource(extra_request_info);
+ was_cached ? 0 : original_content_length, resource_type);
+ tracker->OnLoadedResource(extra_request_complete_info);
}
}

Powered by Google App Engine
This is Rietveld 408576698