Chromium Code Reviews| Index: base/android/record_histogram.cc |
| diff --git a/base/android/record_histogram.cc b/base/android/record_histogram.cc |
| index 1a207a18dc42b5d7fb91dd4cff45130017bc6c4c..aa2d2a56f7ddd41cc7cf095937a805a8a9403dca 100644 |
| --- a/base/android/record_histogram.cc |
| +++ b/base/android/record_histogram.cc |
| @@ -315,6 +315,21 @@ 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; |
| + } |
| + |
| + std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); |
| + return samples->TotalCount(); |
|
Xi Han
2017/06/14 14:51:06
Please remove |samples| and return histogram->Snap
|
| +} |
| + |
| bool RegisterRecordHistogram(JNIEnv* env) { |
| return RegisterNativesImpl(env); |
| } |