Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/crash/ChromeMinidumpUploadDelegate.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/crash/ChromeMinidumpUploadDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/crash/ChromeMinidumpUploadDelegate.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..35f4dcb57e05b6078a522ee44d7841a9ba3d7714 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/crash/ChromeMinidumpUploadDelegate.java |
| @@ -0,0 +1,73 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.crash; |
| + |
| +import android.content.Context; |
| + |
| +import org.chromium.base.metrics.RecordHistogram; |
| +import org.chromium.chrome.browser.preferences.ChromePreferenceManager; |
| +import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager; |
| +import org.chromium.components.minidump_uploader.util.CrashReportingPermissionManager; |
| +import org.chromium.components.minidump_uploader.util.MinidumpUploadDelegate; |
| + |
| +/** |
| + * Chrome-specific implementation of the MinidumpUploadDelegate - providing control over different |
| + * parts of the Minidump Uploading process. |
| + */ |
| +public class ChromeMinidumpUploadDelegate implements MinidumpUploadDelegate { |
| + private static final String TAG = "ChromeMinidumpUploadDelegate"; |
| + /** |
| + * Histogram related constants. |
| + */ |
| + private static final String HISTOGRAM_NAME_PREFIX = "Tab.AndroidCrashUpload_"; |
| + private static final int HISTOGRAM_MAX = 2; |
| + private static final int FAILURE = 0; |
| + private static final int SUCCESS = 1; |
| + |
| + @Override |
| + public void onSuccessfulUpload(Context context, String fileName) { |
| + // Increment the count of success by 1 and distinguish between different types of |
|
Ilya Sherman
2016/10/21 00:27:27
nit: Please remove the extra space before "Increme
gsennton
2016/10/21 13:43:32
Done.
|
| + // crashes by looking into the file. |
| + ChromePreferenceManager.getInstance(context).incrementCrashSuccessUploadCount( |
| + MinidumpUploadService.getCrashType(fileName)); |
| + } |
| + |
| + @Override |
| + public void onMaxedOutUploadFailures(Context context, String fileName) { |
| + // Increment the count of failure by 1 and distinguish between different types of |
| + // crashes by looking into the file. |
| + ChromePreferenceManager.getInstance(context).incrementCrashFailureUploadCount( |
| + MinidumpUploadService.getCrashType(fileName)); |
| + } |
| + |
| + @Override |
| + public CrashReportingPermissionManager getCrashReportingPermissionManager() { |
| + return PrivacyPreferencesManager.getInstance(); |
| + } |
| + |
| + /** |
| + * Stores the successes and failures from uploading crash to UMA, |
| + */ |
| + public static void storeBreakpadUploadStatsInUma(ChromePreferenceManager pref) { |
| + for (String type : MinidumpUploadService.CRASH_TYPES) { |
| + for (int success = pref.getCrashSuccessUploadCount(type); success > 0; success--) { |
| + RecordHistogram.recordEnumeratedHistogram( |
| + HISTOGRAM_NAME_PREFIX + type, |
| + SUCCESS, |
| + HISTOGRAM_MAX); |
| + } |
| + for (int fail = pref.getCrashFailureUploadCount(type); fail > 0; fail--) { |
| + RecordHistogram.recordEnumeratedHistogram( |
| + HISTOGRAM_NAME_PREFIX + type, |
| + FAILURE, |
| + HISTOGRAM_MAX); |
| + } |
| + |
| + pref.setCrashSuccessUploadCount(type, 0); |
| + pref.setCrashFailureUploadCount(type, 0); |
| + } |
| + } |
| +} |
| + |