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

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

Issue 1686643002: Add metric with time between background tab being foregrounded and the first paint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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: components/page_load_metrics/browser/page_load_metrics_util.cc
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 e28a4a3ce7d34e8e40a66a782573224431da5357..df123952cd54bef1448f51c05552d0b9df46c705 100644
--- a/components/page_load_metrics/browser/page_load_metrics_util.cc
+++ b/components/page_load_metrics/browser/page_load_metrics_util.cc
@@ -11,11 +11,37 @@
namespace page_load_metrics {
-bool EventOccurredInForeground(const base::TimeDelta& event,
- const PageLoadExtraInfo& info) {
+namespace {
+
+// Returns whether the page moved to the foreground prior to |event|. True if
+// the page was always in the foreground.
Charlie Harrison 2016/02/22 16:08:32 Nit: Not quite true. This function will return tru
pkotwicz 2016/02/22 23:14:26 I created a function InForeground() and made both
+bool MovedToForegroundBefore(const base::TimeDelta& event,
Charlie Harrison 2016/02/22 16:08:32 I think this function could also be renamed to som
+ const PageLoadExtraInfo& info) {
+ return info.started_in_foreground || (!info.first_foreground_time.is_zero() &&
+ event > info.first_foreground_time);
+}
+
+// Returns whether the page moved to the background after |event|. True if the
+// page never moved to the background.
+bool MovedToBackgroundAfter(const base::TimeDelta& event,
Charlie Harrison 2016/02/22 16:08:32 This is a confusing name given the comment and wha
+ const PageLoadExtraInfo& info) {
+ return info.first_background_time.is_zero() ||
+ event < info.first_background_time;
+}
+
+} // namespace
+
+bool StartInForegroundEventInForeground(const 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);
+ MovedToBackgroundAfter(event, info);
+}
+
+bool StartInBackgroundEventInForeground(const base::TimeDelta& event,
Charlie Harrison 2016/02/22 16:08:32 nit: do you mind replacing all "const base::TimeDe
pkotwicz 2016/02/22 23:14:26 Done.
+ const PageLoadExtraInfo& info) {
+ return !info.started_in_foreground && !event.is_zero() &&
+ MovedToForegroundBefore(event, info) &&
+ MovedToBackgroundAfter(event, info);
}
} // namespace page_load_metrics

Powered by Google App Engine
This is Rietveld 408576698