| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 case SPARSE_HISTOGRAM: | 46 case SPARSE_HISTOGRAM: |
| 47 break; | 47 break; |
| 48 } | 48 } |
| 49 return params_str; | 49 return params_str; |
| 50 } | 50 } |
| 51 | 51 |
| 52 void CheckHistogramArgs(JNIEnv* env, | 52 void CheckHistogramArgs(JNIEnv* env, |
| 53 jstring j_histogram_name, | 53 jstring j_histogram_name, |
| 54 int32_t expected_min, | 54 int32_t expected_min, |
| 55 int32_t expected_max, | 55 int32_t expected_max, |
| 56 int32_t expected_bucket_count, | 56 uint32_t expected_bucket_count, |
| 57 HistogramBase* histogram) { | 57 HistogramBase* histogram) { |
| 58 std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name); |
| 59 bool valid_arguments = Histogram::InspectConstructionArguments( |
| 60 histogram_name, &expected_min, &expected_max, &expected_bucket_count); |
| 61 DCHECK(valid_arguments); |
| 58 DCHECK(histogram->HasConstructionArguments(expected_min, expected_max, | 62 DCHECK(histogram->HasConstructionArguments(expected_min, expected_max, |
| 59 expected_bucket_count)) | 63 expected_bucket_count)) |
| 60 << ConvertJavaStringToUTF8(env, j_histogram_name) << "/" << expected_min | 64 << histogram_name << "/" << expected_min << "/" << expected_max << "/" |
| 61 << "/" << expected_max << "/" << expected_bucket_count << " vs. " | 65 << expected_bucket_count << " vs. " |
| 62 << HistogramConstructionParamsToString(histogram); | 66 << HistogramConstructionParamsToString(histogram); |
| 63 } | 67 } |
| 64 | 68 |
| 65 HistogramBase* BooleanHistogram(JNIEnv* env, | 69 HistogramBase* BooleanHistogram(JNIEnv* env, |
| 66 jstring j_histogram_name, | 70 jstring j_histogram_name, |
| 67 jlong j_histogram_key) { | 71 jlong j_histogram_key) { |
| 68 DCHECK(j_histogram_name); | 72 DCHECK(j_histogram_name); |
| 69 HistogramBase* histogram = HistogramFromKey(j_histogram_key); | 73 HistogramBase* histogram = HistogramFromKey(j_histogram_key); |
| 70 if (histogram) | 74 if (histogram) |
| 71 return histogram; | 75 return histogram; |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); | 314 std::unique_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); |
| 311 return samples->GetCount(static_cast<int>(sample)); | 315 return samples->GetCount(static_cast<int>(sample)); |
| 312 } | 316 } |
| 313 | 317 |
| 314 bool RegisterRecordHistogram(JNIEnv* env) { | 318 bool RegisterRecordHistogram(JNIEnv* env) { |
| 315 return RegisterNativesImpl(env); | 319 return RegisterNativesImpl(env); |
| 316 } | 320 } |
| 317 | 321 |
| 318 } // namespace android | 322 } // namespace android |
| 319 } // namespace base | 323 } // namespace base |
| OLD | NEW |