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

Unified Diff: webrtc/api/android/java/src/org/webrtc/Metrics.java

Issue 2320473002: Make UMA stats creation available in the Java interface. (Closed)
Patch Set: Also update the example. Created 4 years, 3 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 | webrtc/api/android/jni/androidmetrics_jni.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/android/java/src/org/webrtc/Metrics.java
diff --git a/webrtc/api/android/java/src/org/webrtc/Metrics.java b/webrtc/api/android/java/src/org/webrtc/Metrics.java
index 90209ad062501bf25cfc2af945de02bba26516a8..69c81ee98b50a827ebc06ac791c65e1c7e9ea6b6 100644
--- a/webrtc/api/android/java/src/org/webrtc/Metrics.java
+++ b/webrtc/api/android/java/src/org/webrtc/Metrics.java
@@ -30,6 +30,8 @@ import java.util.Map;
// The metrics can for example be retrieved when a peer connection is closed.
public class Metrics {
+ private static final String TAG = "Metrics";
+
static {
System.loadLibrary("jingle_peerconnection_so");
}
@@ -57,6 +59,36 @@ public class Metrics {
}
}
+ /**
+ * Class for holding the native pointer of a histogram. Since there is no way to destroy a
+ * histogram, please don't create unnecessary instances of this object. This class is thread safe.
+ *
+ * Usage example:
+ * private static final Histogram someMetricHistogram =
+ * Histogram.createCounts("WebRTC.Video.SomeMetric", 1, 10000, 50);
+ * someMetricHistogram.addSample(someVariable);
+ */
+ static class Histogram {
+ private final long handle;
+ private final String name; // Only used for logging.
+
+ private Histogram(long handle, String name) {
+ this.handle = handle;
+ this.name = name;
+ }
+
+ static public Histogram createCounts(String name, int min, int max, int bucketCount) {
+ return new Histogram(nativeCreateCounts(name, min, max, bucketCount), name);
+ }
+
+ public void addSample(int sample) {
+ nativeAddSample(handle, sample);
+ }
+
+ private static native long nativeCreateCounts(String name, int min, int max, int bucketCount);
+ private static native void nativeAddSample(long handle, int sample);
+ }
+
private void add(String name, HistogramInfo info) {
map.put(name, info);
}
« no previous file with comments | « no previous file | webrtc/api/android/jni/androidmetrics_jni.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698