Commit eda43b13 authored by Dan Harrington's avatar Dan Harrington Committed by Commit Bot

Fix crash in reportCompleteNotificationAction

reportCompleteNotificationAction can be called without native, which resulted
in crashes. Changed to use CachedMetrics to only report when native is loaded.

I manually tested that this no longer crashes by killing the chrome process
before triggering the intent. Note that if Chrome is killed before native
is loaded, the metric won't be reported.

Bug: 930307
Change-Id: I88728029ae1c09a9197de9c1eb3c6d71086b99d6
Reviewed-on: https://chromium-review.googlesource.com/c/1461332Reviewed-by: default avatarCarlos Knippschild <carlosk@chromium.org>
Commit-Queue: Dan H <harringtond@google.com>
Cr-Commit-Position: refs/heads/master@{#630541}
parent 4ee19dd3
......@@ -19,6 +19,7 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.metrics.CachedMetrics.EnumeratedHistogramSample;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.IntentHandler;
......@@ -340,9 +341,11 @@ public class AutoFetchNotifier {
}
private static void reportCompleteNotificationAction(@NotificationAction int action) {
RecordHistogram.recordEnumeratedHistogram(
"OfflinePages.AutoFetch.CompleteNotificationAction", action,
NotificationAction.NUM_ENTRIES);
// Native may or may not be running, so use CachedMetrics.EnumeratedHistogramSample.
EnumeratedHistogramSample sample =
new EnumeratedHistogramSample("OfflinePages.AutoFetch.CompleteNotificationAction",
NotificationAction.NUM_ENTRIES);
sample.record(action);
}
private static boolean isShowingInProgressNotification() {
......
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