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

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

Issue 1423263003: Add time-to-first-contentful-paint to PageLoadMetrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: naming Created 5 years, 2 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/page_load_metrics/browser/metrics_web_contents_observer.cc
diff --git a/components/page_load_metrics/browser/metrics_web_contents_observer.cc b/components/page_load_metrics/browser/metrics_web_contents_observer.cc
index d3fe69e669953277f15f8f5de20f61e7ca94375c..f3657826adebe80090064715114ec8254a43c297 100644
--- a/components/page_load_metrics/browser/metrics_web_contents_observer.cc
+++ b/components/page_load_metrics/browser/metrics_web_contents_observer.cc
@@ -84,6 +84,14 @@ void RecordInternalError(InternalErrorLoadEvent event) {
"PageLoad.Events.InternalError", event, ERR_LAST_ENTRY);
}
+base::TimeDelta GetFirstContentfulPaint(const PageLoadTiming& timing) {
+ if (timing.first_text_paint.is_zero())
+ return timing.first_image_paint;
+ if (timing.first_image_paint.is_zero())
+ return timing.first_text_paint;
+ return std::min(timing.first_text_paint, timing.first_image_paint);
+}
+
} // namespace
PageLoadTracker::PageLoadTracker(
@@ -241,6 +249,18 @@ void PageLoadTracker::RecordTimingHistograms() {
timing_.first_image_paint);
}
}
+ base::TimeDelta first_contentful_paint = GetFirstContentfulPaint(timing_);
+ if (!first_contentful_paint.is_zero()) {
+ if (first_contentful_paint < background_delta) {
+ PAGE_LOAD_HISTOGRAM("PageLoad.Timing2.NavigationToFirstContentfulPaint",
+ first_contentful_paint);
+ } else {
+ PAGE_LOAD_HISTOGRAM(
+ "PageLoad.Timing2.NavigationToFirstContentfulPaint.Background",
+ first_contentful_paint);
+ }
+ }
+
// Log time to first foreground / time to first background. Log counts that we
// started a relevant page load in the foreground / background.
if (!background_time_.is_null()) {
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698