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

Unified Diff: base/android/record_histogram.cc

Issue 1309143004: Add UMA metrics to record the size of internal memory available on a user's device when the Update … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix indent Created 5 years, 4 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
Index: base/android/record_histogram.cc
diff --git a/base/android/record_histogram.cc b/base/android/record_histogram.cc
index 9a68deca54f420aa2136608dc9b097b2f08fb27a..0688e4f4ba799f928aa7699fa4cb9aa014398b26 100644
--- a/base/android/record_histogram.cc
+++ b/base/android/record_histogram.cc
@@ -85,6 +85,30 @@ class HistogramCache {
return InsertLocked(j_histogram_key, histogram);
}
+ HistogramBase* LinearCountHistogram(JNIEnv* env,
+ jstring j_histogram_name,
+ jint j_histogram_key,
+ jint j_min,
+ jint j_max,
+ jint j_num_buckets) {
+ DCHECK(j_histogram_name);
+ DCHECK(j_histogram_key);
+ int64 min = static_cast<int64>(j_min);
+ int64 max = static_cast<int64>(j_max);
+ int num_buckets = static_cast<int>(j_num_buckets);
+ HistogramBase* histogram = FindLocked(j_histogram_key);
+ if (histogram) {
+ DCHECK(histogram->HasConstructionArguments(min, max, num_buckets));
+ return histogram;
+ }
+
+ std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name);
+ histogram =
+ LinearHistogram::FactoryGet(histogram_name, min, max, num_buckets,
+ HistogramBase::kUmaTargetedHistogramFlag);
+ return InsertLocked(j_histogram_key, histogram);
+ }
+
HistogramBase* SparseHistogram(JNIEnv* env,
jstring j_histogram_name,
jint j_histogram_key) {
@@ -189,6 +213,22 @@ void RecordCustomCountHistogram(JNIEnv* env,
->Add(sample);
}
+void RecordLinearCountHistogram(JNIEnv* env,
+ jclass clazz,
+ jstring j_histogram_name,
+ jint j_histogram_key,
+ jint j_sample,
+ jint j_min,
+ jint j_max,
+ jint j_num_buckets) {
+ int sample = static_cast<int>(j_sample);
+
+ g_histograms.Get()
+ .LinearCountHistogram(env, j_histogram_name, j_histogram_key, j_min,
+ j_max, j_num_buckets)
+ ->Add(sample);
+}
+
void RecordSparseHistogram(JNIEnv* env,
jclass clazz,
jstring j_histogram_name,

Powered by Google App Engine
This is Rietveld 408576698