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

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

Issue 2121863002: Separate deferred startup into tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split up everything to the idle handler. Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.metrics; 5 package org.chromium.chrome.browser.metrics;
6 6
7 import android.os.SystemClock; 7 import android.os.SystemClock;
8 8
9 import org.chromium.base.annotations.CalledByNative; 9 import org.chromium.base.annotations.CalledByNative;
10 import org.chromium.base.annotations.JNINamespace; 10 import org.chromium.base.annotations.JNINamespace;
11 11
12 /** 12 /**
13 * Utilities to support startup metrics - Android version. 13 * Utilities to support startup metrics - Android version.
14 */ 14 */
15 @JNINamespace("chrome::android") 15 @JNINamespace("chrome::android")
16 public class UmaUtils { 16 public class UmaUtils {
17 private static long sApplicationStartWallClockMs; 17 private static long sApplicationStartWallClockMs;
18 private static long sApplicationStartUptimeMs; 18 private static long sApplicationStartUptimeMs;
19 19
20 private static boolean sRunningApplicationStart; 20 private static boolean sRunningApplicationStart;
21 private static long sForegroundStartTimeMs;
21 22
22 /** 23 /**
23 * Record the time at which the activity started. This should be called asap after 24 * Record the time at which the activity started. This should be called asap after
24 * the start of the activity's onCreate function. 25 * the start of the activity's onCreate function.
25 */ 26 */
26 public static void recordMainEntryPointTime() { 27 public static void recordMainEntryPointTime() {
27 // We can't simply pass this down through a JNI call, since the JNI for chrome 28 // We can't simply pass this down through a JNI call, since the JNI for chrome
28 // isn't initialized until we start the native content browser component , and we 29 // isn't initialized until we start the native content browser component , and we
29 // then need the start time in the C++ side before we return to Java. As such we 30 // then need the start time in the C++ side before we return to Java. As such we
30 // save it in a static that the C++ can fetch once it has initialized th e JNI. 31 // save it in a static that the C++ can fetch once it has initialized th e JNI.
31 sApplicationStartWallClockMs = System.currentTimeMillis(); 32 sApplicationStartWallClockMs = System.currentTimeMillis();
32 sApplicationStartUptimeMs = SystemClock.uptimeMillis(); 33 sApplicationStartUptimeMs = SystemClock.uptimeMillis();
33 } 34 }
34 35
36 public static void recordForegroundStartTime() {
37 sForegroundStartTimeMs = SystemClock.uptimeMillis();
38 }
39
35 /** 40 /**
36 * Whether the application is in the early stage since the browser process s tart. The 41 * Whether the application is in the early stage since the browser process s tart. The
37 * "application start" ends right after the last histogram related to browse r startup is 42 * "application start" ends right after the last histogram related to browse r startup is
38 * recorded. Currently, the very first navigation commit in the lifetime of the process ends the 43 * recorded. Currently, the very first navigation commit in the lifetime of the process ends the
39 * "application start". 44 * "application start".
40 * Must only be called on the UI thread. 45 * Must only be called on the UI thread.
41 */ 46 */
42 public static boolean isRunningApplicationStart() { 47 public static boolean isRunningApplicationStart() {
43 return sRunningApplicationStart; 48 return sRunningApplicationStart;
44 } 49 }
(...skipping 14 matching lines...) Expand all
59 public static void recordMetricsReportingDefaultOptIn(boolean optIn) { 64 public static void recordMetricsReportingDefaultOptIn(boolean optIn) {
60 nativeRecordMetricsReportingDefaultOptIn(optIn); 65 nativeRecordMetricsReportingDefaultOptIn(optIn);
61 } 66 }
62 67
63 @CalledByNative 68 @CalledByNative
64 public static long getMainEntryPointWallTime() { 69 public static long getMainEntryPointWallTime() {
65 return sApplicationStartWallClockMs; 70 return sApplicationStartWallClockMs;
66 } 71 }
67 72
68 public static long getMainEntryPointTime() { 73 public static long getMainEntryPointTime() {
69 return sApplicationStartUptimeMs; 74 return sApplicationStartUptimeMs;
Yaron 2016/07/06 14:27:50 so remove this now?
Peter Wen 2016/07/06 15:21:37 Done.
70 } 75 }
71 76
77 public static long getForegroundStartTime() {
78 assert sForegroundStartTimeMs != 0;
79 return sForegroundStartTimeMs;
80 }
81
72 private static native void nativeRecordMetricsReportingDefaultOptIn(boolean optIn); 82 private static native void nativeRecordMetricsReportingDefaultOptIn(boolean optIn);
73 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698