Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: base/android/record_histogram.cc

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/android/jni_android.cc ('k') | base/base.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 return histogram; 53 return histogram;
54 } 54 }
55 55
56 std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name); 56 std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name);
57 histogram = 57 histogram =
58 LinearHistogram::FactoryGet(histogram_name, 1, boundary, boundary + 1, 58 LinearHistogram::FactoryGet(histogram_name, 1, boundary, boundary + 1,
59 HistogramBase::kUmaTargetedHistogramFlag); 59 HistogramBase::kUmaTargetedHistogramFlag);
60 return InsertLocked(j_histogram_key, histogram); 60 return InsertLocked(j_histogram_key, histogram);
61 } 61 }
62 62
63 HistogramBase* CountHistogram(JNIEnv* env,
64 jstring j_histogram_name,
65 jint j_histogram_key) {
66 // These values are based on the hard-coded constants in the
67 // UMA_HISTOGRAM_COUNTS macro from base/metrics/histogram_macros.h.
68 const int histogram_min = 1;
69 const int histogram_max = 1000000;
70 const int histogram_num_buckets = 50;
71
72 DCHECK(j_histogram_name);
73 DCHECK(j_histogram_key);
74 HistogramBase* histogram = FindLocked(j_histogram_key);
75 if (histogram) {
76 DCHECK(histogram->HasConstructionArguments(histogram_min, histogram_max,
77 histogram_num_buckets));
78 return histogram;
79 }
80
81 std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name);
82 histogram = Histogram::FactoryGet(histogram_name, histogram_min,
83 histogram_max, histogram_num_buckets,
84 HistogramBase::kUmaTargetedHistogramFlag);
85 return InsertLocked(j_histogram_key, histogram);
86 }
87
63 HistogramBase* CustomTimesHistogram(JNIEnv* env, 88 HistogramBase* CustomTimesHistogram(JNIEnv* env,
64 jstring j_histogram_name, 89 jstring j_histogram_name,
65 jint j_histogram_key, 90 jint j_histogram_key,
66 jlong j_min, 91 jlong j_min,
67 jlong j_max, 92 jlong j_max,
68 jint j_bucket_count) { 93 jint j_bucket_count) {
69 DCHECK(j_histogram_name); 94 DCHECK(j_histogram_name);
70 DCHECK(j_histogram_key); 95 DCHECK(j_histogram_key);
71 HistogramBase* histogram = FindLocked(j_histogram_key); 96 HistogramBase* histogram = FindLocked(j_histogram_key);
72 int64 min = static_cast<int64>(j_min); 97 int64 min = static_cast<int64>(j_min);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 jint j_histogram_key, 151 jint j_histogram_key,
127 jint j_sample, 152 jint j_sample,
128 jint j_boundary) { 153 jint j_boundary) {
129 int sample = static_cast<int>(j_sample); 154 int sample = static_cast<int>(j_sample);
130 155
131 g_histograms.Get() 156 g_histograms.Get()
132 .EnumeratedHistogram(env, j_histogram_name, j_histogram_key, j_boundary) 157 .EnumeratedHistogram(env, j_histogram_name, j_histogram_key, j_boundary)
133 ->Add(sample); 158 ->Add(sample);
134 } 159 }
135 160
161 void RecordCountHistogram(JNIEnv* env,
162 jclass clazz,
163 jstring j_histogram_name,
164 jint j_histogram_key,
165 jint j_sample) {
166 int sample = static_cast<int>(j_sample);
167
168 g_histograms.Get()
169 .CountHistogram(env, j_histogram_name, j_histogram_key)
170 ->Add(sample);
171 }
172
136 void RecordCustomTimesHistogramMilliseconds(JNIEnv* env, 173 void RecordCustomTimesHistogramMilliseconds(JNIEnv* env,
137 jclass clazz, 174 jclass clazz,
138 jstring j_histogram_name, 175 jstring j_histogram_name,
139 jint j_histogram_key, 176 jint j_histogram_key,
140 jlong j_duration, 177 jlong j_duration,
141 jlong j_min, 178 jlong j_min,
142 jlong j_max, 179 jlong j_max,
143 jint j_num_buckets) { 180 jint j_num_buckets) {
144 g_histograms.Get() 181 g_histograms.Get()
145 .CustomTimesHistogram(env, j_histogram_name, j_histogram_key, j_min, 182 .CustomTimesHistogram(env, j_histogram_name, j_histogram_key, j_min,
(...skipping 23 matching lines...) Expand all
169 scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); 206 scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
170 return samples->GetCount(static_cast<int>(sample)); 207 return samples->GetCount(static_cast<int>(sample));
171 } 208 }
172 209
173 bool RegisterRecordHistogram(JNIEnv* env) { 210 bool RegisterRecordHistogram(JNIEnv* env) {
174 return RegisterNativesImpl(env); 211 return RegisterNativesImpl(env);
175 } 212 }
176 213
177 } // namespace android 214 } // namespace android
178 } // namespace base 215 } // namespace base
OLDNEW
« no previous file with comments | « base/android/jni_android.cc ('k') | base/base.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698