Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/crash/MinidumpUploadService.java

Issue 2780933002: [Crash Reporting] Enable the JobScheduler API by default for Android M+. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.crash; 5 package org.chromium.chrome.browser.crash;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.app.IntentService; 8 import android.app.IntentService;
9 import android.app.job.JobInfo; 9 import android.app.job.JobInfo;
10 import android.content.ComponentName; 10 import android.content.ComponentName;
11 import android.content.Context; 11 import android.content.Context;
12 import android.content.Intent; 12 import android.content.Intent;
13 import android.os.Build; 13 import android.os.Build;
14 import android.os.PersistableBundle; 14 import android.os.PersistableBundle;
15 import android.support.annotation.StringDef; 15 import android.support.annotation.StringDef;
16 16
17 import org.chromium.base.Log; 17 import org.chromium.base.Log;
18 import org.chromium.base.StreamUtil; 18 import org.chromium.base.StreamUtil;
19 import org.chromium.base.VisibleForTesting; 19 import org.chromium.base.VisibleForTesting;
20 import org.chromium.base.annotations.CalledByNative; 20 import org.chromium.base.annotations.CalledByNative;
21 import org.chromium.base.metrics.RecordHistogram; 21 import org.chromium.base.metrics.RecordHistogram;
22 import org.chromium.chrome.browser.ChromeFeatureList;
23 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; 22 import org.chromium.chrome.browser.preferences.ChromePreferenceManager;
24 import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager ; 23 import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager ;
25 import org.chromium.components.background_task_scheduler.TaskIds; 24 import org.chromium.components.background_task_scheduler.TaskIds;
26 import org.chromium.components.minidump_uploader.CrashFileManager; 25 import org.chromium.components.minidump_uploader.CrashFileManager;
27 import org.chromium.components.minidump_uploader.MinidumpUploadCallable; 26 import org.chromium.components.minidump_uploader.MinidumpUploadCallable;
28 import org.chromium.components.minidump_uploader.MinidumpUploadJobService; 27 import org.chromium.components.minidump_uploader.MinidumpUploadJobService;
29 import org.chromium.components.minidump_uploader.util.CrashReportingPermissionMa nager; 28 import org.chromium.components.minidump_uploader.util.CrashReportingPermissionMa nager;
30 29
31 import java.io.BufferedReader; 30 import java.io.BufferedReader;
32 import java.io.File; 31 import java.io.File;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 public MinidumpUploadService() { 72 public MinidumpUploadService() {
74 super(TAG); 73 super(TAG);
75 setIntentRedelivery(true); 74 setIntentRedelivery(true);
76 } 75 }
77 76
78 /** 77 /**
79 * @return Whether to use the JobSchduler API to upload crash reports, rathe r than directly 78 * @return Whether to use the JobSchduler API to upload crash reports, rathe r than directly
80 * creating a service for uploading. 79 * creating a service for uploading.
81 */ 80 */
82 public static boolean shouldUseJobSchedulerForUploads() { 81 public static boolean shouldUseJobSchedulerForUploads() {
83 // The JobScheduler API is only available as of Android M. 82 // The JobScheduler API is only usable as of Android M.
84 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return false; 83 return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
85
86 return ChromeFeatureList.isEnabled(
87 ChromeFeatureList.UPLOAD_CRASH_REPORTS_USING_JOB_SCHEDULER);
88 } 84 }
89 85
90 /** 86 /**
91 * Schedules uploading of all pending minidumps, using the JobScheduler API. 87 * Schedules uploading of all pending minidumps, using the JobScheduler API.
92 */ 88 */
93 @SuppressLint("NewApi") 89 @SuppressLint("NewApi")
94 public static void scheduleUploadJob(Context context) { 90 public static void scheduleUploadJob(Context context) {
95 assert shouldUseJobSchedulerForUploads(); 91 assert shouldUseJobSchedulerForUploads();
96 92
97 CrashReportingPermissionManager permissionManager = PrivacyPreferencesMa nager.getInstance(); 93 CrashReportingPermissionManager permissionManager = PrivacyPreferencesMa nager.getInstance();
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 return; 357 return;
362 } 358 }
363 359
364 if (shouldUseJobSchedulerForUploads()) { 360 if (shouldUseJobSchedulerForUploads()) {
365 scheduleUploadJob(context); 361 scheduleUploadJob(context);
366 } else { 362 } else {
367 tryUploadCrashDump(context, renamedMinidumpFile); 363 tryUploadCrashDump(context, renamedMinidumpFile);
368 } 364 }
369 } 365 }
370 } 366 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698