summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer.cc2
-rw-r--r--chrome/browser/page_load_metrics/observers/core_page_load_metrics_observer.cc67
-rw-r--r--chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc23
-rw-r--r--chrome/browser/page_load_metrics/observers/stale_while_revalidate_metrics_observer.cc11
-rw-r--r--components/page_load_metrics/browser/metrics_web_contents_observer.cc9
-rw-r--r--components/page_load_metrics/browser/page_load_metrics_observer.h10
-rw-r--r--components/page_load_metrics/browser/page_load_metrics_util.cc4
-rw-r--r--components/page_load_metrics/browser/page_load_metrics_util.h16
-rw-r--r--tools/metrics/histograms/histograms.xml8
9 files changed, 96 insertions, 54 deletions
diff --git a/chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer.cc
index bdea7b9..4c101f6 100644
--- a/chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer.cc
+++ b/chrome/browser/page_load_metrics/observers/aborts_page_load_metrics_observer.cc
@@ -132,7 +132,7 @@ void AbortsPageLoadMetricsObserver::OnComplete(
DCHECK(!time_to_abort.is_zero());
// Don't log abort times if the page was backgrounded before the abort event.
- if (!EventOccurredInForeground(time_to_abort, extra_info))
+ if (!WasStartedInForegroundEventInForeground(time_to_abort, extra_info))
return;
if (extra_info.time_to_commit.is_zero()) {
diff --git a/chrome/browser/page_load_metrics/observers/core_page_load_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/core_page_load_metrics_observer.cc
index b85bc48..4d8ed1c 100644
--- a/chrome/browser/page_load_metrics/observers/core_page_load_metrics_observer.cc
+++ b/chrome/browser/page_load_metrics/observers/core_page_load_metrics_observer.cc
@@ -88,6 +88,9 @@ const char kHistogramBackgroundBeforeCommit[] =
const char kHistogramFailedProvisionalLoad[] =
"PageLoad.Timing2.NavigationToFailedProvisionalLoad";
+const char kHistogramForegroundToFirstPaint[] =
+ "PageLoad.Timing2.ForegroundToFirstPaint";
+
const char kRapporMetricsNameCoarseTiming[] =
"PageLoad.CoarseTiming.NavigationToFirstContentfulPaint";
@@ -125,8 +128,11 @@ void CorePageLoadMetricsObserver::OnFailedProvisionalLoad(
void CorePageLoadMetricsObserver::RecordTimingHistograms(
const page_load_metrics::PageLoadTiming& timing,
const page_load_metrics::PageLoadExtraInfo& info) {
- if (!info.first_background_time.is_zero() &&
- !EventOccurredInForeground(timing.first_paint, info)) {
+ // Record metrics for pages which starts in the foreground and is backgrounded
+ // prior to the first paint.
+ if (info.started_in_foreground && !info.first_background_time.is_zero() &&
+ (timing.first_paint.is_zero() ||
+ timing.first_paint > info.first_background_time)) {
if (!info.time_to_commit.is_zero()) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramBackgroundBeforePaint,
info.first_background_time);
@@ -138,8 +144,8 @@ void CorePageLoadMetricsObserver::RecordTimingHistograms(
if (failed_provisional_load_info_.error != net::OK) {
// Ignores a background failed provisional load.
- if (EventOccurredInForeground(failed_provisional_load_info_.interval,
- info)) {
+ if (WasStartedInForegroundEventInForeground(
+ failed_provisional_load_info_.interval, info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramFailedProvisionalLoad,
failed_provisional_load_info_.interval);
}
@@ -150,15 +156,15 @@ void CorePageLoadMetricsObserver::RecordTimingHistograms(
if (info.time_to_commit.is_zero() || timing.IsEmpty())
return;
- if (EventOccurredInForeground(info.time_to_commit, info)) {
+ if (WasStartedInForegroundEventInForeground(info.time_to_commit, info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramCommit, info.time_to_commit);
} else {
PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramCommit,
info.time_to_commit);
}
if (!timing.dom_content_loaded_event_start.is_zero()) {
- if (EventOccurredInForeground(timing.dom_content_loaded_event_start,
- info)) {
+ if (WasStartedInForegroundEventInForeground(
+ timing.dom_content_loaded_event_start, info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramDomContentLoaded,
timing.dom_content_loaded_event_start);
} else {
@@ -167,7 +173,8 @@ void CorePageLoadMetricsObserver::RecordTimingHistograms(
}
}
if (!timing.load_event_start.is_zero()) {
- if (EventOccurredInForeground(timing.load_event_start, info)) {
+ if (WasStartedInForegroundEventInForeground(timing.load_event_start,
+ info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramLoad, timing.load_event_start);
} else {
PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramLoad,
@@ -175,7 +182,7 @@ void CorePageLoadMetricsObserver::RecordTimingHistograms(
}
}
if (!timing.first_layout.is_zero()) {
- if (EventOccurredInForeground(timing.first_layout, info)) {
+ if (WasStartedInForegroundEventInForeground(timing.first_layout, info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstLayout, timing.first_layout);
} else {
PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstLayout,
@@ -183,15 +190,29 @@ void CorePageLoadMetricsObserver::RecordTimingHistograms(
}
}
if (!timing.first_paint.is_zero()) {
- if (EventOccurredInForeground(timing.first_paint, info)) {
+ if (WasStartedInForegroundEventInForeground(timing.first_paint, info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstPaint, timing.first_paint);
} else {
PAGE_LOAD_HISTOGRAM(internal::kBackgroundHistogramFirstPaint,
timing.first_paint);
}
+
+ // Record the time to first paint for pages which were:
+ // - Opened in the background.
+ // - Moved to the foreground prior to the first paint.
+ // - Not moved back to the background prior to the first paint.
+ if (!info.started_in_foreground && !info.first_foreground_time.is_zero() &&
+ timing.first_paint > info.first_foreground_time &&
+ (info.first_background_time.is_zero() ||
+ timing.first_paint < info.first_background_time)) {
+ PAGE_LOAD_HISTOGRAM(
+ internal::kHistogramForegroundToFirstPaint,
+ timing.first_paint - info.first_foreground_time);
+ }
}
if (!timing.first_text_paint.is_zero()) {
- if (EventOccurredInForeground(timing.first_text_paint, info)) {
+ if (WasStartedInForegroundEventInForeground(timing.first_text_paint,
+ info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstTextPaint,
timing.first_text_paint);
} else {
@@ -200,7 +221,8 @@ void CorePageLoadMetricsObserver::RecordTimingHistograms(
}
}
if (!timing.first_image_paint.is_zero()) {
- if (EventOccurredInForeground(timing.first_image_paint, info)) {
+ if (WasStartedInForegroundEventInForeground(timing.first_image_paint,
+ info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstImagePaint,
timing.first_image_paint);
} else {
@@ -209,7 +231,8 @@ void CorePageLoadMetricsObserver::RecordTimingHistograms(
}
}
if (!timing.first_contentful_paint.is_zero()) {
- if (EventOccurredInForeground(timing.first_contentful_paint, info)) {
+ if (WasStartedInForegroundEventInForeground(timing.first_contentful_paint,
+ info)) {
PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstContentfulPaint,
timing.first_contentful_paint);
// Bucket these histograms into high/low resolution clock systems. This
@@ -229,12 +252,15 @@ void CorePageLoadMetricsObserver::RecordTimingHistograms(
// Log time to first foreground / time to first background. Log counts that we
// started a relevant page load in the foreground / background.
- if (!info.first_background_time.is_zero())
- PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstBackground,
- info.first_background_time);
- else if (!info.first_foreground_time.is_zero())
- PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstForeground,
- info.first_foreground_time);
+ if (info.started_in_foreground) {
+ if (!info.first_background_time.is_zero())
+ PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstBackground,
+ info.first_background_time);
+ } else {
+ if (!info.first_foreground_time.is_zero())
+ PAGE_LOAD_HISTOGRAM(internal::kHistogramFirstForeground,
+ info.first_foreground_time);
+ }
}
void CorePageLoadMetricsObserver::RecordRappor(
@@ -253,7 +279,8 @@ void CorePageLoadMetricsObserver::RecordRappor(
return;
DCHECK(!info.committed_url.is_empty());
// Log the eTLD+1 of sites that show poor loading performance.
- if (!EventOccurredInForeground(timing.first_contentful_paint, info)) {
+ if (!WasStartedInForegroundEventInForeground(timing.first_contentful_paint,
+ info)) {
return;
}
scoped_ptr<rappor::Sample> sample =
diff --git a/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc
index d0a5e98..127479b 100644
--- a/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc
+++ b/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc
@@ -63,44 +63,49 @@ void FromGWSPageLoadMetricsObserver::OnCommit(
void FromGWSPageLoadMetricsObserver::OnComplete(
const page_load_metrics::PageLoadTiming& timing,
const page_load_metrics::PageLoadExtraInfo& extra_info) {
- using page_load_metrics::EventOccurredInForeground;
+ using page_load_metrics::WasStartedInForegroundEventInForeground;
if (!navigation_from_gws_)
return;
- if (EventOccurredInForeground(timing.dom_content_loaded_event_start,
- extra_info)) {
+ if (WasStartedInForegroundEventInForeground(
+ timing.dom_content_loaded_event_start, extra_info)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.FromGWS.Timing2."
"NavigationToDOMContentLoadedEventFired",
timing.dom_content_loaded_event_start);
}
- if (EventOccurredInForeground(timing.load_event_start, extra_info)) {
+ if (WasStartedInForegroundEventInForeground(timing.load_event_start,
+ extra_info)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.FromGWS.Timing2.NavigationToLoadEventFired",
timing.load_event_start);
}
- if (EventOccurredInForeground(timing.first_layout, extra_info)) {
+ if (WasStartedInForegroundEventInForeground(timing.first_layout,
+ extra_info)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.FromGWS.Timing2.NavigationToFirstLayout",
timing.first_layout);
}
- if (EventOccurredInForeground(timing.first_text_paint, extra_info)) {
+ if (WasStartedInForegroundEventInForeground(timing.first_text_paint,
+ extra_info)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.FromGWS.Timing2.NavigationToFirstTextPaint",
timing.first_text_paint);
}
- if (EventOccurredInForeground(timing.first_image_paint, extra_info)) {
+ if (WasStartedInForegroundEventInForeground(timing.first_image_paint,
+ extra_info)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.FromGWS.Timing2.NavigationToFirstImagePaint",
timing.first_image_paint);
}
- if (EventOccurredInForeground(timing.first_paint, extra_info)) {
+ if (WasStartedInForegroundEventInForeground(timing.first_paint, extra_info)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.FromGWS.Timing2.NavigationToFirstPaint",
timing.first_paint);
}
- if (EventOccurredInForeground(timing.first_contentful_paint, extra_info)) {
+ if (WasStartedInForegroundEventInForeground(timing.first_contentful_paint,
+ extra_info)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.FromGWS.Timing2.NavigationToFirstContentfulPaint",
timing.first_contentful_paint);
diff --git a/chrome/browser/page_load_metrics/observers/stale_while_revalidate_metrics_observer.cc b/chrome/browser/page_load_metrics/observers/stale_while_revalidate_metrics_observer.cc
index f474d2f..b021704 100644
--- a/chrome/browser/page_load_metrics/observers/stale_while_revalidate_metrics_observer.cc
+++ b/chrome/browser/page_load_metrics/observers/stale_while_revalidate_metrics_observer.cc
@@ -23,24 +23,27 @@ void StaleWhileRevalidateMetricsObserver::OnCommit(
void StaleWhileRevalidateMetricsObserver::OnComplete(
const page_load_metrics::PageLoadTiming& timing,
const page_load_metrics::PageLoadExtraInfo& extra_info) {
- using page_load_metrics::EventOccurredInForeground;
+ using page_load_metrics::WasStartedInForegroundEventInForeground;
if (!is_interesting_domain_)
return;
- if (EventOccurredInForeground(timing.load_event_start, extra_info)) {
+ if (WasStartedInForegroundEventInForeground(timing.load_event_start,
+ extra_info)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2."
"NavigationToLoadEventFired",
timing.load_event_start);
}
- if (EventOccurredInForeground(timing.first_layout, extra_info)) {
+ if (WasStartedInForegroundEventInForeground(timing.first_layout,
+ extra_info)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2."
"NavigationToFirstLayout",
timing.first_layout);
}
- if (EventOccurredInForeground(timing.first_text_paint, extra_info)) {
+ if (WasStartedInForegroundEventInForeground(timing.first_text_paint,
+ extra_info)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.StaleWhileRevalidateExperiment.Timing2."
"NavigationToFirstTextPaint",
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 8174799..21130fa 100644
--- a/components/page_load_metrics/browser/metrics_web_contents_observer.cc
+++ b/components/page_load_metrics/browser/metrics_web_contents_observer.cc
@@ -159,14 +159,13 @@ void PageLoadTracker::LogAbortChainHistograms(
void PageLoadTracker::WebContentsHidden() {
// Only log the first time we background in a given page load.
- if (started_in_foreground_ && background_time_.is_null())
+ if (background_time_.is_null())
background_time_ = base::TimeTicks::Now();
}
void PageLoadTracker::WebContentsShown() {
// Only log the first time we foreground in a given page load.
- // Don't log foreground time if we started foregrounded.
- if (!started_in_foreground_ && foreground_time_.is_null())
+ if (foreground_time_.is_null())
foreground_time_ = base::TimeTicks::Now();
}
@@ -227,9 +226,9 @@ PageLoadExtraInfo PageLoadTracker::GetPageLoadMetricsInfo() {
base::TimeDelta first_foreground_time;
base::TimeDelta time_to_abort;
base::TimeDelta time_to_commit;
- if (!background_time_.is_null() && started_in_foreground_)
+ if (!background_time_.is_null())
first_background_time = background_time_ - navigation_start_;
- if (!foreground_time_.is_null() && !started_in_foreground_)
+ if (!foreground_time_.is_null())
first_foreground_time = foreground_time_ - navigation_start_;
if (abort_type_ != ABORT_NONE) {
DCHECK_GT(abort_time_, navigation_start_);
diff --git a/components/page_load_metrics/browser/page_load_metrics_observer.h b/components/page_load_metrics/browser/page_load_metrics_observer.h
index 0f455c2..c42f36d 100644
--- a/components/page_load_metrics/browser/page_load_metrics_observer.h
+++ b/components/page_load_metrics/browser/page_load_metrics_observer.h
@@ -59,14 +59,12 @@ struct PageLoadExtraInfo {
UserAbortType abort_type,
base::TimeDelta time_to_abort);
- // Returns the time to first background if the page load started in the
- // foreground. If the page has not been backgrounded, or the page started in
- // the background, this will be base::TimeDelta().
+ // The first time that the page was backgrounded since the navigation started.
+ // If the page has not been backgrounded this will be base::TimeDelta().
const base::TimeDelta first_background_time;
- // Returns the time to first foreground if the page load started in the
- // background. If the page has not been foregrounded, or the page started in
- // the foreground, this will be base::TimeDelta().
+ // The first time that the page was foregrounded since the navigation started.
+ // If the page has not been foregrounded this will be base::TimeDelta().
const base::TimeDelta first_foreground_time;
// True if the page load started in the foreground.
diff --git a/components/page_load_metrics/browser/page_load_metrics_util.cc b/components/page_load_metrics/browser/page_load_metrics_util.cc
index 913b141..dbfa35e 100644
--- a/components/page_load_metrics/browser/page_load_metrics_util.cc
+++ b/components/page_load_metrics/browser/page_load_metrics_util.cc
@@ -11,8 +11,8 @@
namespace page_load_metrics {
-bool EventOccurredInForeground(base::TimeDelta event,
- const PageLoadExtraInfo& info) {
+bool WasStartedInForegroundEventInForeground(base::TimeDelta event,
+ const PageLoadExtraInfo& info) {
return info.started_in_foreground && !event.is_zero() &&
(info.first_background_time.is_zero() ||
event < info.first_background_time);
diff --git a/components/page_load_metrics/browser/page_load_metrics_util.h b/components/page_load_metrics/browser/page_load_metrics_util.h
index 375debb..380c077 100644
--- a/components/page_load_metrics/browser/page_load_metrics_util.h
+++ b/components/page_load_metrics/browser/page_load_metrics_util.h
@@ -18,13 +18,15 @@ namespace page_load_metrics {
struct PageLoadExtraInfo;
struct PageLoadTiming;
-// Returns false for events for which we have no timing information, and events
-// that happened on a page that had been in the background. When a page is
-// backgrounded, some events (e.g. paint) are delayed. Since these data points
-// can skew the mean, they should not be mixed with timing events that occurred
-// in the foreground.
-bool EventOccurredInForeground(base::TimeDelta event,
- const PageLoadExtraInfo& info);
+// Returns true if:
+// - We have timing information for the event.
+// - The page load started while the page was in the foreground.
+// - The event occurred prior to the page being moved to the background.
+// When a page is backgrounded, some events (e.g. paint) are delayed. Since
+// these data points can skew the mean, they should not be mixed with timing
+// events that occurred in the foreground.
+bool WasStartedInForegroundEventInForeground(base::TimeDelta event,
+ const PageLoadExtraInfo& info);
} // namespace page_load_metrics
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index f10c95d..70e4095 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -33298,6 +33298,14 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>
+<histogram name="PageLoad.Timing2.ForegroundToFirstPaint" units="ms">
+ <owner>pkotwicz@chromium.org</owner>
+ <summary>
+ Measures the time from a background tab being switched to the foreground to
+ the time the first paint is performed, for main frame documents.
+ </summary>
+</histogram>
+
<histogram name="PageLoad.Timing2.NavigationToCommit" units="ms">
<owner>bmcquade@chromium.org</owner>
<owner>csharrison@chromium.org</owner>