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

Side by Side Diff: base/android/java/src/org/chromium/base/metrics/RecordHistogram.java

Issue 2548013002: Remove redundant field initialization in Java code. (Closed)
Patch Set: rebase Created 4 years 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 package org.chromium.base.metrics; 5 package org.chromium.base.metrics;
6 6
7 import org.chromium.base.VisibleForTesting; 7 import org.chromium.base.VisibleForTesting;
8 import org.chromium.base.annotations.JNINamespace; 8 import org.chromium.base.annotations.JNINamespace;
9 9
10 import java.util.Collections; 10 import java.util.Collections;
11 import java.util.HashMap; 11 import java.util.HashMap;
12 import java.util.Map; 12 import java.util.Map;
13 import java.util.concurrent.TimeUnit; 13 import java.util.concurrent.TimeUnit;
14 14
15 /** 15 /**
16 * Java API for recording UMA histograms. 16 * Java API for recording UMA histograms.
17 * 17 *
18 * Internally, histograms objects are cached on the Java side by their pointer 18 * Internally, histograms objects are cached on the Java side by their pointer
19 * values (converted to long). This is safe to do because C++ Histogram objects 19 * values (converted to long). This is safe to do because C++ Histogram objects
20 * are never freed. Caching them on the Java side prevents needing to do costly 20 * are never freed. Caching them on the Java side prevents needing to do costly
21 * Java String to C++ string conversions on the C++ side during lookup. 21 * Java String to C++ string conversions on the C++ side during lookup.
22 * 22 *
23 * Note: the JNI calls are relatively costly - avoid calling these methods in pe rformance-critical 23 * Note: the JNI calls are relatively costly - avoid calling these methods in pe rformance-critical
24 * code. 24 * code.
25 */ 25 */
26 @JNINamespace("base::android") 26 @JNINamespace("base::android")
27 public class RecordHistogram { 27 public class RecordHistogram {
28 private static boolean sIsDisabledForTests = false; 28 private static boolean sIsDisabledForTests;
29 private static Map<String, Long> sCache = 29 private static Map<String, Long> sCache =
30 Collections.synchronizedMap(new HashMap<String, Long>()); 30 Collections.synchronizedMap(new HashMap<String, Long>());
31 31
32 /** 32 /**
33 * Tests may not have native initialized, so they may need to disable metric s. 33 * Tests may not have native initialized, so they may need to disable metric s.
34 */ 34 */
35 @VisibleForTesting 35 @VisibleForTesting
36 public static void disableForTests() { 36 public static void disableForTests() {
37 sIsDisabledForTests = true; 37 sIsDisabledForTests = true;
38 } 38 }
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 String name, long key, int sample, int boundary); 278 String name, long key, int sample, int boundary);
279 private static native long nativeRecordCustomCountHistogram( 279 private static native long nativeRecordCustomCountHistogram(
280 String name, long key, int sample, int min, int max, int numBuckets) ; 280 String name, long key, int sample, int min, int max, int numBuckets) ;
281 private static native long nativeRecordLinearCountHistogram( 281 private static native long nativeRecordLinearCountHistogram(
282 String name, long key, int sample, int min, int max, int numBuckets) ; 282 String name, long key, int sample, int min, int max, int numBuckets) ;
283 private static native long nativeRecordSparseHistogram(String name, long key , int sample); 283 private static native long nativeRecordSparseHistogram(String name, long key , int sample);
284 284
285 private static native int nativeGetHistogramValueCountForTesting(String name , int sample); 285 private static native int nativeGetHistogramValueCountForTesting(String name , int sample);
286 private static native void nativeInitialize(); 286 private static native void nativeInitialize();
287 } 287 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698