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 <map> | 7 #include <map> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 return histogram; | 78 return histogram; |
79 } | 79 } |
80 | 80 |
81 std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name); | 81 std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name); |
82 histogram = | 82 histogram = |
83 Histogram::FactoryGet(histogram_name, min, max, num_buckets, | 83 Histogram::FactoryGet(histogram_name, min, max, num_buckets, |
84 HistogramBase::kUmaTargetedHistogramFlag); | 84 HistogramBase::kUmaTargetedHistogramFlag); |
85 return InsertLocked(j_histogram_key, histogram); | 85 return InsertLocked(j_histogram_key, histogram); |
86 } | 86 } |
87 | 87 |
88 HistogramBase* LinearCountHistogram(JNIEnv* env, | |
89 jstring j_histogram_name, | |
Yaron
2015/08/31 13:53:21
nit: fix indentation
| |
90 jint j_histogram_key, | |
91 jint j_min, | |
92 jint j_max, | |
93 jint j_num_buckets) { | |
94 DCHECK(j_histogram_name); | |
95 DCHECK(j_histogram_key); | |
96 int64 min = static_cast<int64>(j_min); | |
97 int64 max = static_cast<int64>(j_max); | |
98 int num_buckets = static_cast<int>(j_num_buckets); | |
99 HistogramBase* histogram = FindLocked(j_histogram_key); | |
100 if (histogram) { | |
101 DCHECK(histogram->HasConstructionArguments(min, max, num_buckets)); | |
102 return histogram; | |
103 } | |
104 std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name ); | |
Yaron
2015/08/31 13:53:21
80 cols
| |
105 histogram = | |
106 LinearHistogram::FactoryGet(histogram_name, min, max, num_buckets, | |
107 HistogramBase::kUmaTargetedHistogramFlag); | |
Yaron
2015/08/31 13:53:21
nit: indentation
| |
108 return InsertLocked(j_histogram_key, histogram); | |
109 } | |
110 | |
88 HistogramBase* SparseHistogram(JNIEnv* env, | 111 HistogramBase* SparseHistogram(JNIEnv* env, |
89 jstring j_histogram_name, | 112 jstring j_histogram_name, |
90 jint j_histogram_key) { | 113 jint j_histogram_key) { |
91 DCHECK(j_histogram_name); | 114 DCHECK(j_histogram_name); |
92 DCHECK(j_histogram_key); | 115 DCHECK(j_histogram_key); |
93 HistogramBase* histogram = FindLocked(j_histogram_key); | 116 HistogramBase* histogram = FindLocked(j_histogram_key); |
94 if (histogram) | 117 if (histogram) |
95 return histogram; | 118 return histogram; |
96 | 119 |
97 std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name); | 120 std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 jint j_max, | 205 jint j_max, |
183 jint j_num_buckets) { | 206 jint j_num_buckets) { |
184 int sample = static_cast<int>(j_sample); | 207 int sample = static_cast<int>(j_sample); |
185 | 208 |
186 g_histograms.Get() | 209 g_histograms.Get() |
187 .CustomCountHistogram(env, j_histogram_name, j_histogram_key, j_min, | 210 .CustomCountHistogram(env, j_histogram_name, j_histogram_key, j_min, |
188 j_max, j_num_buckets) | 211 j_max, j_num_buckets) |
189 ->Add(sample); | 212 ->Add(sample); |
190 } | 213 } |
191 | 214 |
215 void RecordLinearCountHistogram(JNIEnv* env, | |
216 jclass clazz, | |
217 jstring j_histogram_name, | |
218 jint j_histogram_key, | |
219 jint j_sample, | |
220 jint j_min, | |
221 jint j_max, | |
222 jint j_num_buckets) { | |
223 int sample = static_cast<int>(j_sample); | |
224 | |
225 g_histograms.Get() | |
226 .LinearCountHistogram(env, j_histogram_name, j_histogram_key, j_min, | |
227 j_max, j_num_buckets) | |
228 ->Add(sample); | |
229 } | |
230 | |
192 void RecordSparseHistogram(JNIEnv* env, | 231 void RecordSparseHistogram(JNIEnv* env, |
193 jclass clazz, | 232 jclass clazz, |
194 jstring j_histogram_name, | 233 jstring j_histogram_name, |
195 jint j_histogram_key, | 234 jint j_histogram_key, |
196 jint j_sample) { | 235 jint j_sample) { |
197 int sample = static_cast<int>(j_sample); | 236 int sample = static_cast<int>(j_sample); |
198 g_histograms.Get() | 237 g_histograms.Get() |
199 .SparseHistogram(env, j_histogram_name, j_histogram_key) | 238 .SparseHistogram(env, j_histogram_name, j_histogram_key) |
200 ->Add(sample); | 239 ->Add(sample); |
201 } | 240 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); | 275 scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); |
237 return samples->GetCount(static_cast<int>(sample)); | 276 return samples->GetCount(static_cast<int>(sample)); |
238 } | 277 } |
239 | 278 |
240 bool RegisterRecordHistogram(JNIEnv* env) { | 279 bool RegisterRecordHistogram(JNIEnv* env) { |
241 return RegisterNativesImpl(env); | 280 return RegisterNativesImpl(env); |
242 } | 281 } |
243 | 282 |
244 } // namespace android | 283 } // namespace android |
245 } // namespace base | 284 } // namespace base |
OLD | NEW |