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

Unified Diff: base/android/record_histogram.cc

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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
« no previous file with comments | « base/android/jni_android.cc ('k') | base/base.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/record_histogram.cc
diff --git a/base/android/record_histogram.cc b/base/android/record_histogram.cc
index 0df0487ce8eaef337f6f2df2b62a5b4fad005e1a..8b7f7bd1d96df21b94b6d36d705dc0647735a071 100644
--- a/base/android/record_histogram.cc
+++ b/base/android/record_histogram.cc
@@ -60,6 +60,31 @@ class HistogramCache {
return InsertLocked(j_histogram_key, histogram);
}
+ HistogramBase* CountHistogram(JNIEnv* env,
+ jstring j_histogram_name,
+ jint j_histogram_key) {
+ // These values are based on the hard-coded constants in the
+ // UMA_HISTOGRAM_COUNTS macro from base/metrics/histogram_macros.h.
+ const int histogram_min = 1;
+ const int histogram_max = 1000000;
+ const int histogram_num_buckets = 50;
+
+ DCHECK(j_histogram_name);
+ DCHECK(j_histogram_key);
+ HistogramBase* histogram = FindLocked(j_histogram_key);
+ if (histogram) {
+ DCHECK(histogram->HasConstructionArguments(histogram_min, histogram_max,
+ histogram_num_buckets));
+ return histogram;
+ }
+
+ std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name);
+ histogram = Histogram::FactoryGet(histogram_name, histogram_min,
+ histogram_max, histogram_num_buckets,
+ HistogramBase::kUmaTargetedHistogramFlag);
+ return InsertLocked(j_histogram_key, histogram);
+ }
+
HistogramBase* CustomTimesHistogram(JNIEnv* env,
jstring j_histogram_name,
jint j_histogram_key,
@@ -133,6 +158,18 @@ void RecordEnumeratedHistogram(JNIEnv* env,
->Add(sample);
}
+void RecordCountHistogram(JNIEnv* env,
+ jclass clazz,
+ jstring j_histogram_name,
+ jint j_histogram_key,
+ jint j_sample) {
+ int sample = static_cast<int>(j_sample);
+
+ g_histograms.Get()
+ .CountHistogram(env, j_histogram_name, j_histogram_key)
+ ->Add(sample);
+}
+
void RecordCustomTimesHistogramMilliseconds(JNIEnv* env,
jclass clazz,
jstring j_histogram_name,
« no previous file with comments | « base/android/jni_android.cc ('k') | base/base.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698