Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.chrome.browser.metrics; | 5 package org.chromium.chrome.browser.metrics; |
| 6 | 6 |
| 7 import android.util.Pair; | 7 import android.util.Pair; |
| 8 | 8 |
| 9 import org.chromium.base.annotations.JNINamespace; | 9 import org.chromium.base.annotations.JNINamespace; |
| 10 import org.chromium.base.metrics.RecordHistogram; | 10 import org.chromium.base.metrics.RecordHistogram; |
| 11 import org.chromium.base.metrics.RecordUserAction; | |
| 11 import org.chromium.content_public.browser.WebContents; | 12 import org.chromium.content_public.browser.WebContents; |
| 12 | 13 |
| 13 import java.util.ArrayList; | 14 import java.util.ArrayList; |
| 14 import java.util.List; | 15 import java.util.List; |
| 15 import java.util.concurrent.TimeUnit; | 16 import java.util.concurrent.TimeUnit; |
| 16 | 17 |
| 17 /** | 18 /** |
| 18 * Used for recording metrics about Chrome launches that need to be recorded bef ore the native | 19 * Used for recording metrics about Chrome launches that need to be recorded bef ore the native |
| 19 * library may have been loaded. Metrics are cached until the library is known to be loaded, then | 20 * library may have been loaded. Metrics are cached until the library is known to be loaded, then |
| 20 * committed to the MetricsService all at once. | 21 * committed to the MetricsService all at once. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 36 */ | 37 */ |
| 37 protected CachedHistogram(String histogramName) { | 38 protected CachedHistogram(String histogramName) { |
| 38 mHistogramName = histogramName; | 39 mHistogramName = histogramName; |
| 39 sEvents.add(this); | 40 sEvents.add(this); |
| 40 } | 41 } |
| 41 | 42 |
| 42 /** Commits the histogram. Expects the native library to be loaded. */ | 43 /** Commits the histogram. Expects the native library to be loaded. */ |
| 43 protected abstract void commitAndClear(); | 44 protected abstract void commitAndClear(); |
| 44 } | 45 } |
| 45 | 46 |
| 47 /** | |
| 48 * Caches an action that will be recorded after native side is loaded. | |
| 49 */ | |
| 50 public static class ActionEvent extends CachedHistogram { | |
| 51 | |
|
gone
2016/04/27 00:30:09
private boolean mNeedsToBeRecorded = true;
prote
Ian Wen
2016/04/27 00:39:44
Done.
| |
| 52 public ActionEvent(String actionName) { | |
| 53 super(actionName); | |
| 54 } | |
| 55 | |
| 56 @Override | |
| 57 protected void commitAndClear() { | |
| 58 RecordUserAction.record(mHistogramName); | |
| 59 } | |
| 60 } | |
| 61 | |
| 46 /** Caches whether an event happened. */ | 62 /** Caches whether an event happened. */ |
| 47 public static class BooleanEvent extends CachedHistogram { | 63 public static class BooleanEvent extends CachedHistogram { |
| 48 private boolean mIsHit; | 64 private boolean mIsHit; |
| 49 | 65 |
| 50 public BooleanEvent(String histogramName) { | 66 public BooleanEvent(String histogramName) { |
| 51 super(histogramName); | 67 super(histogramName); |
| 52 } | 68 } |
| 53 | 69 |
| 54 /** Records that the histogram condition occurred. */ | 70 /** Records that the histogram condition occurred. */ |
| 55 public void recordHit() { | 71 public void recordHit() { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 } | 183 } |
| 168 sWebappHistogramTimes.clear(); | 184 sWebappHistogramTimes.clear(); |
| 169 | 185 |
| 170 // Record generic cached events. | 186 // Record generic cached events. |
| 171 for (CachedHistogram event : CachedHistogram.sEvents) event.commitAndCle ar(); | 187 for (CachedHistogram event : CachedHistogram.sEvents) event.commitAndCle ar(); |
| 172 } | 188 } |
| 173 | 189 |
| 174 private static native void nativeRecordLaunch( | 190 private static native void nativeRecordLaunch( |
| 175 boolean standalone, String url, int source, WebContents webContents) ; | 191 boolean standalone, String url, int source, WebContents webContents) ; |
| 176 } | 192 } |
| OLD | NEW |