OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/android/record_histogram.h" | 5 #include "base/android/record_histogram.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 android::ConvertJavaStringToUTF8(env, histogram_name)); | 308 android::ConvertJavaStringToUTF8(env, histogram_name)); |
309 if (histogram == nullptr) { | 309 if (histogram == nullptr) { |
310 // No samples have been recorded for this histogram (yet?). | 310 // No samples have been recorded for this histogram (yet?). |
311 return 0; | 311 return 0; |
312 } | 312 } |
313 | 313 |
314 std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); | 314 std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); |
315 return samples->GetCount(static_cast<int>(sample)); | 315 return samples->GetCount(static_cast<int>(sample)); |
316 } | 316 } |
317 | 317 |
318 jint GetHistogramTotalCountForTesting( | |
319 JNIEnv* env, | |
320 const JavaParamRef<jclass>& clazz, | |
321 const JavaParamRef<jstring>& histogram_name) { | |
322 HistogramBase* histogram = StatisticsRecorder::FindHistogram( | |
323 android::ConvertJavaStringToUTF8(env, histogram_name)); | |
324 if (histogram == nullptr) { | |
325 // No samples have been recorded for this histogram. | |
326 return 0; | |
327 } | |
328 | |
329 std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); | |
330 return samples->TotalCount(); | |
Xi Han
2017/06/14 14:51:06
Please remove |samples| and return histogram->Snap
| |
331 } | |
332 | |
318 bool RegisterRecordHistogram(JNIEnv* env) { | 333 bool RegisterRecordHistogram(JNIEnv* env) { |
319 return RegisterNativesImpl(env); | 334 return RegisterNativesImpl(env); |
320 } | 335 } |
321 | 336 |
322 } // namespace android | 337 } // namespace android |
323 } // namespace base | 338 } // namespace base |
OLD | NEW |