Commit be376349 authored by Peter E Conn's avatar Peter E Conn Committed by Commit Bot

🤝 Use CachedHistogram for BrowserServicesMetrics.

Bug: 896201
Change-Id: I107f2ec40f1bd0ed2e33799afb4f33707caa86f4
Reviewed-on: https://chromium-review.googlesource.com/c/1286654
Commit-Queue: Peter Conn <peconn@chromium.org>
Reviewed-by: default avatarMichael van Ouwerkerk <mvanouwerkerk@chromium.org>
Reviewed-by: default avataragrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600413}
parent 53a6e84a
...@@ -158,7 +158,7 @@ public class CachedMetrics { ...@@ -158,7 +158,7 @@ public class CachedMetrics {
/** Caches a set of times histogram samples. */ /** Caches a set of times histogram samples. */
public static class TimesHistogramSample extends CachedMetric { public static class TimesHistogramSample extends CachedMetric {
private final List<Long> mSamples = new ArrayList<Long>(); private final List<Long> mSamples = new ArrayList<Long>();
private final TimeUnit mTimeUnit; protected final TimeUnit mTimeUnit;
public TimesHistogramSample(String histogramName, TimeUnit timeUnit) { public TimesHistogramSample(String histogramName, TimeUnit timeUnit) {
super(histogramName); super(histogramName);
...@@ -177,7 +177,7 @@ public class CachedMetrics { ...@@ -177,7 +177,7 @@ public class CachedMetrics {
} }
} }
private void recordWithNative(long sample) { protected void recordWithNative(long sample) {
RecordHistogram.recordTimesHistogram(mName, sample, mTimeUnit); RecordHistogram.recordTimesHistogram(mName, sample, mTimeUnit);
} }
...@@ -190,6 +190,21 @@ public class CachedMetrics { ...@@ -190,6 +190,21 @@ public class CachedMetrics {
} }
} }
/**
* Caches a set of times histogram samples, calls
* {@link RecordHistogram#recordMediumTimesHistogram(String, long, TimeUnit)}.
*/
public static class MediumTimesHistogramSample extends TimesHistogramSample {
public MediumTimesHistogramSample(String histogramName, TimeUnit timeUnit) {
super(histogramName, timeUnit);
}
@Override
protected void recordWithNative(long sample) {
RecordHistogram.recordMediumTimesHistogram(mName, sample, mTimeUnit);
}
}
/** Caches a set of boolean histogram samples. */ /** Caches a set of boolean histogram samples. */
public static class BooleanHistogramSample extends CachedMetric { public static class BooleanHistogramSample extends CachedMetric {
private final List<Boolean> mSamples = new ArrayList<Boolean>(); private final List<Boolean> mSamples = new ArrayList<Boolean>();
......
...@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.browserservices; ...@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.browserservices;
import android.os.SystemClock; import android.os.SystemClock;
import android.support.annotation.IntDef; import android.support.annotation.IntDef;
import org.chromium.base.metrics.CachedMetrics;
import org.chromium.base.metrics.RecordHistogram; import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.metrics.RecordUserAction;
...@@ -93,8 +94,9 @@ public class BrowserServicesMetrics { ...@@ -93,8 +94,9 @@ public class BrowserServicesMetrics {
@Override @Override
public void close() { public void close() {
RecordHistogram.recordMediumTimesHistogram( // Use {@link CachedMetrics} so this can be called before native is loaded.
mMetric, now() - mStart, TimeUnit.MILLISECONDS); new CachedMetrics.MediumTimesHistogramSample(mMetric, TimeUnit.MILLISECONDS)
.record(now() - mStart);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment