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); |
} |