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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 int32_t min = static_cast<int32_t>(j_min); | 106 int32_t min = static_cast<int32_t>(j_min); |
107 int32_t max = static_cast<int32_t>(j_max); | 107 int32_t max = static_cast<int32_t>(j_max); |
108 int32_t num_buckets = static_cast<int32_t>(j_num_buckets); | 108 int32_t num_buckets = static_cast<int32_t>(j_num_buckets); |
109 HistogramBase* histogram = HistogramFromKey(j_histogram_key); | 109 HistogramBase* histogram = HistogramFromKey(j_histogram_key); |
110 if (histogram) { | 110 if (histogram) { |
111 CheckHistogramArgs(env, j_histogram_name, min, max, num_buckets, | 111 CheckHistogramArgs(env, j_histogram_name, min, max, num_buckets, |
112 histogram); | 112 histogram); |
113 return histogram; | 113 return histogram; |
114 } | 114 } |
115 | 115 |
| 116 DCHECK_GE(min, 1) << "The min expected sample must be >= 1"; |
| 117 |
116 std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name); | 118 std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name); |
117 histogram = | 119 histogram = |
118 Histogram::FactoryGet(histogram_name, min, max, num_buckets, | 120 Histogram::FactoryGet(histogram_name, min, max, num_buckets, |
119 HistogramBase::kUmaTargetedHistogramFlag); | 121 HistogramBase::kUmaTargetedHistogramFlag); |
120 return histogram; | 122 return histogram; |
121 } | 123 } |
122 | 124 |
123 HistogramBase* LinearCountHistogram(JNIEnv* env, | 125 HistogramBase* LinearCountHistogram(JNIEnv* env, |
124 jstring j_histogram_name, | 126 jstring j_histogram_name, |
125 jlong j_histogram_key, | 127 jlong j_histogram_key, |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); | 310 std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); |
309 return samples->GetCount(static_cast<int>(sample)); | 311 return samples->GetCount(static_cast<int>(sample)); |
310 } | 312 } |
311 | 313 |
312 bool RegisterRecordHistogram(JNIEnv* env) { | 314 bool RegisterRecordHistogram(JNIEnv* env) { |
313 return RegisterNativesImpl(env); | 315 return RegisterNativesImpl(env); |
314 } | 316 } |
315 | 317 |
316 } // namespace android | 318 } // namespace android |
317 } // namespace base | 319 } // namespace base |
OLD | NEW |