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

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

Issue 1309143004: Add UMA metrics to record the size of internal memory available on a user's device when the Update … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix indent Created 5 years, 3 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
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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,
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
105 std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name);
106 histogram =
107 LinearHistogram::FactoryGet(histogram_name, min, max, num_buckets,
108 HistogramBase::kUmaTargetedHistogramFlag);
109 return InsertLocked(j_histogram_key, histogram);
110 }
111
88 HistogramBase* SparseHistogram(JNIEnv* env, 112 HistogramBase* SparseHistogram(JNIEnv* env,
89 jstring j_histogram_name, 113 jstring j_histogram_name,
90 jint j_histogram_key) { 114 jint j_histogram_key) {
91 DCHECK(j_histogram_name); 115 DCHECK(j_histogram_name);
92 DCHECK(j_histogram_key); 116 DCHECK(j_histogram_key);
93 HistogramBase* histogram = FindLocked(j_histogram_key); 117 HistogramBase* histogram = FindLocked(j_histogram_key);
94 if (histogram) 118 if (histogram)
95 return histogram; 119 return histogram;
96 120
97 std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name); 121 std::string histogram_name = ConvertJavaStringToUTF8(env, j_histogram_name);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 jint j_max, 206 jint j_max,
183 jint j_num_buckets) { 207 jint j_num_buckets) {
184 int sample = static_cast<int>(j_sample); 208 int sample = static_cast<int>(j_sample);
185 209
186 g_histograms.Get() 210 g_histograms.Get()
187 .CustomCountHistogram(env, j_histogram_name, j_histogram_key, j_min, 211 .CustomCountHistogram(env, j_histogram_name, j_histogram_key, j_min,
188 j_max, j_num_buckets) 212 j_max, j_num_buckets)
189 ->Add(sample); 213 ->Add(sample);
190 } 214 }
191 215
216 void RecordLinearCountHistogram(JNIEnv* env,
217 jclass clazz,
218 jstring j_histogram_name,
219 jint j_histogram_key,
220 jint j_sample,
221 jint j_min,
222 jint j_max,
223 jint j_num_buckets) {
224 int sample = static_cast<int>(j_sample);
225
226 g_histograms.Get()
227 .LinearCountHistogram(env, j_histogram_name, j_histogram_key, j_min,
228 j_max, j_num_buckets)
229 ->Add(sample);
230 }
231
192 void RecordSparseHistogram(JNIEnv* env, 232 void RecordSparseHistogram(JNIEnv* env,
193 jclass clazz, 233 jclass clazz,
194 jstring j_histogram_name, 234 jstring j_histogram_name,
195 jint j_histogram_key, 235 jint j_histogram_key,
196 jint j_sample) { 236 jint j_sample) {
197 int sample = static_cast<int>(j_sample); 237 int sample = static_cast<int>(j_sample);
198 g_histograms.Get() 238 g_histograms.Get()
199 .SparseHistogram(env, j_histogram_name, j_histogram_key) 239 .SparseHistogram(env, j_histogram_name, j_histogram_key)
200 ->Add(sample); 240 ->Add(sample);
201 } 241 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples(); 276 scoped_ptr<HistogramSamples> samples = histogram->SnapshotSamples();
237 return samples->GetCount(static_cast<int>(sample)); 277 return samples->GetCount(static_cast<int>(sample));
238 } 278 }
239 279
240 bool RegisterRecordHistogram(JNIEnv* env) { 280 bool RegisterRecordHistogram(JNIEnv* env) {
241 return RegisterNativesImpl(env); 281 return RegisterNativesImpl(env);
242 } 282 }
243 283
244 } // namespace android 284 } // namespace android
245 } // namespace base 285 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698