| Index: chrome/android/java/src/org/chromium/chrome/browser/crash/MinidumpUploadService.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/crash/MinidumpUploadService.java b/chrome/android/java/src/org/chromium/chrome/browser/crash/MinidumpUploadService.java
|
| index 72178f656d1a22448f067591e36f08b6b4caec98..a239ea943f5564eb6d89392f198e6272043e1e85 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/crash/MinidumpUploadService.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/crash/MinidumpUploadService.java
|
| @@ -13,9 +13,7 @@ import org.chromium.base.Log;
|
| import org.chromium.base.StreamUtil;
|
| import org.chromium.base.VisibleForTesting;
|
| import org.chromium.base.annotations.CalledByNative;
|
| -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.MinidumpUploadDelegate;
|
|
|
| import java.io.BufferedReader;
|
| import java.io.File;
|
| @@ -25,7 +23,7 @@ import java.io.IOException;
|
| /**
|
| * Service that is responsible for uploading crash minidumps to the Google crash server.
|
| */
|
| -public class MinidumpUploadService extends IntentService {
|
| +public abstract class MinidumpUploadService extends IntentService {
|
| private static final String TAG = "MinidmpUploadService";
|
| // Intent actions
|
| private static final String ACTION_FIND_LAST =
|
| @@ -54,14 +52,6 @@ public class MinidumpUploadService extends IntentService {
|
| @VisibleForTesting
|
| static final int MAX_TRIES_ALLOWED = 3;
|
|
|
| - /**
|
| - * 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;
|
| -
|
| @StringDef({BROWSER, RENDERER, GPU, OTHER})
|
| public @interface ProcessType {}
|
| static final String BROWSER = "Browser";
|
| @@ -69,7 +59,7 @@ public class MinidumpUploadService extends IntentService {
|
| static final String GPU = "GPU";
|
| static final String OTHER = "Other";
|
|
|
| - static final String[] TYPES = {BROWSER, RENDERER, GPU, OTHER};
|
| + static final String[] CRASH_TYPES = {BROWSER, RENDERER, GPU, OTHER};
|
|
|
| public MinidumpUploadService() {
|
| super(TAG);
|
| @@ -128,29 +118,6 @@ public class MinidumpUploadService extends IntentService {
|
| return intent;
|
| }
|
|
|
| - /**
|
| - * Stores the successes and failures from uploading crash to UMA,
|
| - */
|
| - public static void storeBreakpadUploadStatsInUma(ChromePreferenceManager pref) {
|
| - for (String type : 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);
|
| - }
|
| - }
|
| -
|
| private void handleFindAndUploadLastCrash(Intent intent) {
|
| CrashFileManager fileManager = new CrashFileManager(getApplicationContext().getCacheDir());
|
| File[] minidumpFiles = fileManager.getAllMinidumpFiles(MAX_TRIES_ALLOWED);
|
| @@ -242,7 +209,7 @@ public class MinidumpUploadService extends IntentService {
|
|
|
| if (uploadStatus == MinidumpUploadCallable.UPLOAD_SUCCESS) {
|
| // Only update UMA stats if an intended and successful upload.
|
| - incrementCrashSuccessUploadCount(getNewNameAfterSuccessfulUpload(minidumpFileName));
|
| + getMinidumpUploadDelegate().onSuccessfulUpload(this, minidumpFileName);
|
| } else if (uploadStatus == MinidumpUploadCallable.UPLOAD_FAILURE) {
|
| // Unable to upload minidump. Incrementing try number and restarting.
|
|
|
| @@ -255,7 +222,7 @@ public class MinidumpUploadService extends IntentService {
|
| MinidumpUploadRetry.scheduleRetry(getApplicationContext());
|
| } else {
|
| // Only record failure to UMA after we have maxed out the allotted tries.
|
| - incrementCrashFailureUploadCount(newName);
|
| + getMinidumpUploadDelegate().onMaxedOutUploadFailures(this, newName);
|
| Log.d(TAG, "Giving up on trying to upload " + minidumpFileName + "after "
|
| + tries + " number of tries.");
|
| }
|
| @@ -310,21 +277,6 @@ public class MinidumpUploadService extends IntentService {
|
| }
|
|
|
| /**
|
| - * Increment the count of success/failure by 1 and distinguish between different types of
|
| - * crashes by looking into the file.
|
| - * @param fileName is the name of a minidump file that contains the type of crash.
|
| - */
|
| - private void incrementCrashSuccessUploadCount(String fileName) {
|
| - ChromePreferenceManager.getInstance(this)
|
| - .incrementCrashSuccessUploadCount(getCrashType(fileName));
|
| - }
|
| -
|
| - private void incrementCrashFailureUploadCount(String fileName) {
|
| - ChromePreferenceManager.getInstance(this)
|
| - .incrementCrashFailureUploadCount(getCrashType(fileName));
|
| - }
|
| -
|
| - /**
|
| * Factory method for creating minidump callables.
|
| *
|
| * This may be overridden for tests.
|
| @@ -335,8 +287,8 @@ public class MinidumpUploadService extends IntentService {
|
| */
|
| @VisibleForTesting
|
| MinidumpUploadCallable createMinidumpUploadCallable(File minidumpFile, File logfile) {
|
| - return new MinidumpUploadCallable(
|
| - minidumpFile, logfile, PrivacyPreferencesManager.getInstance());
|
| + return new MinidumpUploadCallable(minidumpFile, logfile,
|
| + getMinidumpUploadDelegate().getCrashReportingPermissionManager());
|
| }
|
|
|
| /**
|
| @@ -403,4 +355,9 @@ public class MinidumpUploadService extends IntentService {
|
| uploadIntent.putExtra(FINISHED_LOGCAT_EXTRACTION_KEY, true);
|
| startService(uploadIntent);
|
| }
|
| +
|
| + /**
|
| + * Returns the client-specific delegate implementation needed by this Service.
|
| + */
|
| + protected abstract MinidumpUploadDelegate getMinidumpUploadDelegate();
|
| }
|
|
|