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

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

Issue 989523003: Add metrics for tracking how Chrome handled shortcut launches (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 9 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: chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchMetrics.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchMetrics.java b/chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchMetrics.java
new file mode 100644
index 0000000000000000000000000000000000000000..d3e66ef4acbed8639c73acde69795af526590d88
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/metrics/LaunchMetrics.java
@@ -0,0 +1,53 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.metrics;
+
+import org.chromium.base.JNINamespace;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Used for recording metrics about Chrome launches.
+ */
+@JNINamespace("metrics")
+public class LaunchMetrics {
Ted C 2015/03/06 21:12:48 Should this be HomescreenLaunchMetrics? This name
gone 2015/03/06 22:14:09 I was kind of hoping to move that stuff from Inten
+ private static final List<String> sActivityUrls = new ArrayList<String>();
+ private static final List<String> sTabUrls = new ArrayList<String>();
+
+ /**
+ * Records the launch of a standalone Activity for a URL (i.e. a WebappActivity).
+ * @param url URL that kicked off the Activity's creation.
+ */
+ public static void recordStandaloneActivityLaunch(String url) {
+ sActivityUrls.add(url);
+ }
+
+ /**
+ * Records the launch of a Tab for a URL (i.e. a Home screen shortcut).
+ * @param url URL that kicked off the Tab's creation.
+ */
+ public static void recordShortcutLaunch(String url) {
+ sTabUrls.add(url);
+ }
+
+ /**
+ * Calls out to native code to record URLs that have been launched via the Home screen.
+ * This intermediate step is necessary because Activity.onCreate() may be called when
+ * the native library has not yet been loaded.
+ */
+ public static void commitLaunchMetrics() {
+ for (String url : sActivityUrls) {
+ nativeRecordLaunch(true, url);
+ }
+ for (String url : sTabUrls) {
+ nativeRecordLaunch(false, url);
+ }
+ sActivityUrls.clear();
+ sTabUrls.clear();
+ }
+
+ private static native void nativeRecordLaunch(boolean standalone, String url);
+}

Powered by Google App Engine
This is Rietveld 408576698