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

Unified Diff: base/android/java/src/org/chromium/base/metrics/RecordUserAction.java

Issue 2766623003: Make Android Clipboard Keep Track of Last Modified Time (Closed)
Patch Set: final attempt at restoring 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/junit/src/org/chromium/chrome/browser/DisableHistogramsRule.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/java/src/org/chromium/base/metrics/RecordUserAction.java
diff --git a/base/android/java/src/org/chromium/base/metrics/RecordUserAction.java b/base/android/java/src/org/chromium/base/metrics/RecordUserAction.java
index 06004d69597630759b1f533a9ff09467d9ed51df..5334746d918caa1076f91318231516809f3322cf 100644
--- a/base/android/java/src/org/chromium/base/metrics/RecordUserAction.java
+++ b/base/android/java/src/org/chromium/base/metrics/RecordUserAction.java
@@ -5,6 +5,7 @@
package org.chromium.base.metrics;
import org.chromium.base.ThreadUtils;
+import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.JNINamespace;
/**
@@ -18,7 +19,23 @@ import org.chromium.base.annotations.JNINamespace;
*/
@JNINamespace("base::android")
public class RecordUserAction {
+ private static Throwable sDisabledBy;
+
+ /**
+ * Tests may not have native initialized, so they may need to disable metrics. The value should
+ * be reset after the test done, to avoid carrying over state to unrelated tests.
+ */
+ @VisibleForTesting
+ public static void setDisabledForTests(boolean disabled) {
+ if (disabled && sDisabledBy != null) {
+ throw new IllegalStateException("UserActions are already disabled.", sDisabledBy);
+ }
+ sDisabledBy = disabled ? new Throwable() : null;
+ }
+
public static void record(final String action) {
+ if (sDisabledBy != null) return;
+
if (ThreadUtils.runningOnUiThread()) {
nativeRecordUserAction(action);
return;
« no previous file with comments | « no previous file | chrome/android/junit/src/org/chromium/chrome/browser/DisableHistogramsRule.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698