Index: base/android/record_histogram.cc |
diff --git a/base/android/record_histogram.cc b/base/android/record_histogram.cc |
index 1a207a18dc42b5d7fb91dd4cff45130017bc6c4c..05619866b5f02aa0ee36fa0df91e04b3d5942960 100644 |
--- a/base/android/record_histogram.cc |
+++ b/base/android/record_histogram.cc |
@@ -315,6 +315,20 @@ jint GetHistogramValueCountForTesting( |
return samples->GetCount(static_cast<int>(sample)); |
} |
+jint GetHistogramTotalCountForTesting( |
+ JNIEnv* env, |
+ const JavaParamRef<jclass>& clazz, |
+ const JavaParamRef<jstring>& histogram_name) { |
+ HistogramBase* histogram = StatisticsRecorder::FindHistogram( |
+ android::ConvertJavaStringToUTF8(env, histogram_name)); |
+ if (histogram == nullptr) { |
+ // No samples have been recorded for this histogram. |
+ return 0; |
+ } |
+ |
+ return histogram->SnapshotSamples()->TotalCount(); |
+} |
+ |
bool RegisterRecordHistogram(JNIEnv* env) { |
return RegisterNativesImpl(env); |
} |