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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaUtils.java

Issue 2519853004: Allow fetching variations while FRE is showing on Android first run. (Closed)
Patch Set: Fix recordForegroundStartTime(). Created 4 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/android/java/src/org/chromium/chrome/browser/metrics/UmaUtils.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaUtils.java
index 9ef0d443012cd55b787d8b98a7a7aff2ee84fdca..3704fb21666c20c5263d3cfc0da06e1d1ee5eeb8 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaUtils.java
@@ -18,6 +18,7 @@ public class UmaUtils {
private static boolean sRunningApplicationStart;
private static long sForegroundStartTimeMs;
+ private static long sBackgroundTimeMs;
/**
* Record the time at which the activity started. This should be called asap after
@@ -31,8 +32,23 @@ public class UmaUtils {
sApplicationStartWallClockMs = System.currentTimeMillis();
}
+ /**
+ * Record the time at which Chrome was brought to foreground.
+ */
public static void recordForegroundStartTime() {
- sForegroundStartTimeMs = SystemClock.uptimeMillis();
+ // Since this can be called from multiple places (e.g. ChromeActivitySessionTracker
+ // and FirstRunActivity), only set the time if it hasn't been set previously or if
+ // Chrome has been sent to background since the last foreground time.
+ if (sForegroundStartTimeMs == 0 || sForegroundStartTimeMs < sBackgroundTimeMs) {
+ sForegroundStartTimeMs = SystemClock.uptimeMillis();
+ }
+ }
+
+ /**
+ * Record the time at which Chrome was sent to background.
+ */
+ public static void recordBackgroundTime() {
+ sBackgroundTimeMs = SystemClock.uptimeMillis();
}
/**

Powered by Google App Engine
This is Rietveld 408576698