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

Unified Diff: chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.cc

Issue 1507813002: Don't log background navigations in StaleWhileRevalidateExperiment histograms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move ShouldLogEvent() to page_load_metrics_util. Created 5 years 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/observers/from_gws_page_load_metrics_observer.cc
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 da8046aa770ac281e62ba05efefc51798d0168ef..8cf3c74221b30b95849fa167e1dd9b77bd4ffabb 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
@@ -49,12 +49,6 @@ bool IsFromGoogleSearchResult(const GURL& url, const GURL& referrer) {
return is_possible_search_referrer && !IsFromGoogle(url);
}
-bool ShouldLogEvent(const base::TimeDelta& event,
- const base::TimeDelta& first_background) {
- return !event.is_zero() &&
- (first_background.is_zero() || event < first_background);
-}
-
} // namespace
FromGWSPageLoadMetricsObserver::FromGWSPageLoadMetricsObserver(
@@ -70,6 +64,8 @@ void FromGWSPageLoadMetricsObserver::OnCommit(
void FromGWSPageLoadMetricsObserver::OnComplete(
const page_load_metrics::PageLoadTiming& timing,
const page_load_metrics::PageLoadExtraInfo& extra_info) {
+ using page_load_metrics::EventOccurredInForeground;
+
if (!navigation_from_gws_)
return;
// Filter out navigations that started in the background.
@@ -77,39 +73,40 @@ void FromGWSPageLoadMetricsObserver::OnComplete(
return;
const base::TimeDelta& first_background = extra_info.first_background_time;
- if (ShouldLogEvent(timing.dom_content_loaded_event_start, first_background)) {
+ if (EventOccurredInForeground(timing.dom_content_loaded_event_start,
+ first_background)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.FromGWS.Timing2."
"NavigationToDOMContentLoadedEventFired",
timing.dom_content_loaded_event_start);
}
- if (ShouldLogEvent(timing.load_event_start, first_background)) {
+ if (EventOccurredInForeground(timing.load_event_start, first_background)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.FromGWS.Timing2.NavigationToLoadEventFired",
timing.load_event_start);
}
- if (ShouldLogEvent(timing.first_layout, first_background)) {
+ if (EventOccurredInForeground(timing.first_layout, first_background)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.FromGWS.Timing2.NavigationToFirstLayout",
timing.first_layout);
}
- if (ShouldLogEvent(timing.first_text_paint, first_background)) {
+ if (EventOccurredInForeground(timing.first_text_paint, first_background)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.FromGWS.Timing2.NavigationToFirstTextPaint",
timing.first_text_paint);
}
- if (ShouldLogEvent(timing.first_image_paint, first_background)) {
+ if (EventOccurredInForeground(timing.first_image_paint, first_background)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.FromGWS.Timing2.NavigationToFirstImagePaint",
timing.first_image_paint);
}
- if (ShouldLogEvent(timing.first_paint, first_background)) {
+ if (EventOccurredInForeground(timing.first_paint, first_background)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.FromGWS.Timing2.NavigationToFirstPaint",
timing.first_paint);
}
base::TimeDelta first_contentful_paint = GetFirstContentfulPaint(timing);
- if (ShouldLogEvent(first_contentful_paint, first_background)) {
+ if (EventOccurredInForeground(first_contentful_paint, first_background)) {
PAGE_LOAD_HISTOGRAM(
"PageLoad.Clients.FromGWS.Timing2.NavigationToFirstContentfulPaint",
first_contentful_paint);

Powered by Google App Engine
This is Rietveld 408576698