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

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

Issue 2707993003: [Android]: Hide add-to-homescreen app menu item when WebAPK is installed (Closed)
Patch Set: Add new state for 'Add to Homescreen' Menu item Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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.support.annotation.IntDef;
8
7 import org.chromium.base.metrics.RecordHistogram; 9 import org.chromium.base.metrics.RecordHistogram;
8 10
9 /** 11 /**
10 * Centralizes UMA data collection for WebAPKs. NOTE: Histogram names and values are defined in 12 * Centralizes UMA data collection for WebAPKs. NOTE: Histogram names and values are defined in
11 * tools/metrics/histograms/histograms.xml. Please update that file if any chang e is made. 13 * tools/metrics/histograms/histograms.xml. Please update that file if any chang e is made.
12 */ 14 */
13 public class WebApkUma { 15 public class WebApkUma {
14 // This enum is used to back UMA histograms, and should therefore be treated as append-only. 16 // This enum is used to back UMA histograms, and should therefore be treated as append-only.
15 public static final int UPDATE_REQUEST_SENT_FIRST_TRY = 0; 17 public static final int UPDATE_REQUEST_SENT_FIRST_TRY = 0;
16 public static final int UPDATE_REQUEST_SENT_ONSTOP = 1; 18 public static final int UPDATE_REQUEST_SENT_ONSTOP = 1;
17 public static final int UPDATE_REQUEST_SENT_WHILE_WEBAPK_IN_FOREGROUND = 2; 19 public static final int UPDATE_REQUEST_SENT_WHILE_WEBAPK_IN_FOREGROUND = 2;
18 public static final int UPDATE_REQUEST_SENT_MAX = 3; 20 public static final int UPDATE_REQUEST_SENT_MAX = 3;
19 21
20 // This enum is used to back UMA histograms, and should therefore be treated as append-only. 22 // This enum is used to back UMA histograms, and should therefore be treated as append-only.
21 // The queued request times shouldn't exceed three. 23 // The queued request times shouldn't exceed three.
22 public static final int UPDATE_REQUEST_QUEUED_ONCE = 0; 24 public static final int UPDATE_REQUEST_QUEUED_ONCE = 0;
23 public static final int UPDATE_REQUEST_QUEUED_TWICE = 1; 25 public static final int UPDATE_REQUEST_QUEUED_TWICE = 1;
24 public static final int UPDATE_REQUEST_QUEUED_THREE_TIMES = 2; 26 public static final int UPDATE_REQUEST_QUEUED_THREE_TIMES = 2;
25 public static final int UPDATE_REQUEST_QUEUED_MAX = 3; 27 public static final int UPDATE_REQUEST_QUEUED_MAX = 3;
26 28
27 public static final String HISTOGRAM_UPDATE_REQUEST_SENT = 29 public static final String HISTOGRAM_UPDATE_REQUEST_SENT =
28 "WebApk.Update.RequestSent"; 30 "WebApk.Update.RequestSent";
29 31
30 public static final String HISTOGRAM_UPDATE_REQUEST_QUEUED = "WebApk.Update. RequestQueued"; 32 public static final String HISTOGRAM_UPDATE_REQUEST_QUEUED = "WebApk.Update. RequestQueued";
31 33
34 // This enum is used to back UMA histograms, and should therefore be treated as append-only.
35 @IntDef({WEBAPK_OPEN_LAUNCH_SUCCESS, WEBAPK_OPEN_NO_LAUNCH_INTENT,
36 WEBAPK_OPEN_ACTIVITY_NOT_FOUND})
37 public @interface WebApkOpenResult {}
38 public static final int WEBAPK_OPEN_LAUNCH_SUCCESS = 0;
39 public static final int WEBAPK_OPEN_NO_LAUNCH_INTENT = 1;
40 public static final int WEBAPK_OPEN_ACTIVITY_NOT_FOUND = 2;
41 public static final int WEBAPK_OPEN_MAX = 3;
42
32 /** 43 /**
33 * Records the time point when a request to update a WebAPK is sent to the W ebAPK Server. 44 * Records the time point when a request to update a WebAPK is sent to the W ebAPK Server.
34 * @param type representing when the update request is sent to the WebAPK se rver. 45 * @param type representing when the update request is sent to the WebAPK se rver.
35 */ 46 */
36 public static void recordUpdateRequestSent(int type) { 47 public static void recordUpdateRequestSent(int type) {
nyquist 2017/02/28 18:19:17 While you're at it, would you want to do the @IntD
gonzalon 2017/02/28 20:46:04 Done.
37 assert type >= 0 && type < UPDATE_REQUEST_SENT_MAX; 48 assert type >= 0 && type < UPDATE_REQUEST_SENT_MAX;
38 RecordHistogram.recordEnumeratedHistogram(HISTOGRAM_UPDATE_REQUEST_SENT, 49 RecordHistogram.recordEnumeratedHistogram(HISTOGRAM_UPDATE_REQUEST_SENT,
39 type, UPDATE_REQUEST_SENT_MAX); 50 type, UPDATE_REQUEST_SENT_MAX);
40 } 51 }
41 52
42 /** 53 /**
43 * Records the times that an update request has been queued once, twice and three times before 54 * Records the times that an update request has been queued once, twice and three times before
44 * sending to WebAPK server. 55 * sending to WebAPK server.
45 * @param times representing the times that an update has been queued. 56 * @param times representing the times that an update has been queued.
46 */ 57 */
47 public static void recordUpdateRequestQueued(int times) { 58 public static void recordUpdateRequestQueued(int times) {
48 RecordHistogram.recordEnumeratedHistogram(HISTOGRAM_UPDATE_REQUEST_QUEUE D, times, 59 RecordHistogram.recordEnumeratedHistogram(HISTOGRAM_UPDATE_REQUEST_QUEUE D, times,
49 UPDATE_REQUEST_QUEUED_MAX); 60 UPDATE_REQUEST_QUEUED_MAX);
50 } 61 }
62
63 /**
64 * When a user presses on the "Open WebAPK" menu item, this records whether the WebAPK was
65 * opened successfully.
66 * @param type Result of trying to open WebAPK.
67 */
68 public static void recordWebApkOpenAttempt(@WebApkOpenResult int type) {
69 assert type >= 0 && type < WEBAPK_OPEN_MAX;
nyquist 2017/02/28 18:19:17 I'm not sure this is technically necessary now, bu
gonzalon 2017/02/28 20:46:04 Done.
70 RecordHistogram.recordEnumeratedHistogram("WebApk.OpenFromMenu", type, W EBAPK_OPEN_MAX);
71 }
51 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698