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

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

Issue 2737263006: [Android Crash Reporting] Allow uploading minidumps via the JobScheduler (Closed)
Patch Set: Assert that job scheduled successfully Created 3 years, 9 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.content.Context; 7 import android.content.Context;
8 import android.os.Build; 8 import android.os.Build;
9 import android.util.Patterns; 9 import android.util.Patterns;
10 10
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 * @param context The application context for accessing the cache directory and firing intents. 116 * @param context The application context for accessing the cache directory and firing intents.
117 * @param minidump The minidump file that needs logcat output to be attached . 117 * @param minidump The minidump file that needs logcat output to be attached .
118 */ 118 */
119 public LogcatExtractionRunnable(Context context, File minidump) { 119 public LogcatExtractionRunnable(Context context, File minidump) {
120 mContext = context; 120 mContext = context;
121 mMinidumpFile = minidump; 121 mMinidumpFile = minidump;
122 } 122 }
123 123
124 @Override 124 @Override
125 public void run() { 125 public void run() {
126 Log.i(TAG, "Trying to extract logcat for minidump " + mMinidumpFile.getN ame()); 126 Log.i(TAG, "Trying to extract logcat for minidump %s.", mMinidumpFile.ge tName());
127 CrashFileManager fileManager = new CrashFileManager(mContext.getCacheDir ()); 127 CrashFileManager fileManager = new CrashFileManager(mContext.getCacheDir ());
128 File fileToUpload = mMinidumpFile; 128 File fileToUpload = mMinidumpFile;
129 try { 129 try {
130 List<String> logcat = getElidedLogcat(); 130 List<String> logcat = getElidedLogcat();
131 fileToUpload = new MinidumpLogcatPrepender(fileManager, mMinidumpFil e, logcat).run(); 131 fileToUpload = new MinidumpLogcatPrepender(fileManager, mMinidumpFil e, logcat).run();
132 Log.i(TAG, "Succeeded extracting logcat to %s.", fileToUpload.getNam e());
132 } catch (IOException | InterruptedException e) { 133 } catch (IOException | InterruptedException e) {
133 Log.w(TAG, e.toString()); 134 Log.w(TAG, e.toString());
134 } 135 }
135 136
136 // Regardless of success, initiate the upload. That way, even if there a re errors augmenting 137 // Regardless of success, initiate the upload. That way, even if there a re errors augmenting
137 // the minidump with logcat data, the service can still upload the unaug mented minidump. 138 // the minidump with logcat data, the service can still upload the unaug mented minidump.
138 try { 139 if (MinidumpUploadService.shouldUseJobSchedulerForUploads()) {
139 MinidumpUploadService.tryUploadCrashDump(mContext, fileToUpload); 140 MinidumpUploadService.scheduleUploadJob(mContext);
140 } catch (SecurityException e) { 141 } else {
141 // For KitKat and below, there was a framework bug which causes us t o not be able to 142 try {
142 // find our own crash uploading service. Ignore a SecurityException here on older 143 MinidumpUploadService.tryUploadCrashDump(mContext, fileToUpload) ;
143 // OS versions since the crash will eventually get uploaded on next start. 144 } catch (SecurityException e) {
144 // crbug/542533 145 // For KitKat and below, there was a framework bug which causes us to not be able to
145 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 146 // find our own crash uploading service. Ignore a SecurityExcept ion here on older
146 throw e; 147 // OS versions since the crash will eventually get uploaded on n ext start.
148 // crbug/542533
149 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
150 throw e;
151 }
147 } 152 }
148 } 153 }
149 } 154 }
150 155
151 private List<String> getElidedLogcat() throws IOException, InterruptedExcept ion { 156 private List<String> getElidedLogcat() throws IOException, InterruptedExcept ion {
152 List<String> rawLogcat = getLogcat(); 157 List<String> rawLogcat = getLogcat();
153 return Collections.unmodifiableList(elideLogcat(rawLogcat)); 158 return Collections.unmodifiableList(elideLogcat(rawLogcat));
154 } 159 }
155 160
156 @VisibleForTesting 161 @VisibleForTesting
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 * {@link #CONSOLE_ELISION}. 331 * {@link #CONSOLE_ELISION}.
327 * 332 *
328 * @param original String potentially containing console messages. 333 * @param original String potentially containing console messages.
329 * @return String with elided console messages. 334 * @return String with elided console messages.
330 */ 335 */
331 @VisibleForTesting 336 @VisibleForTesting
332 protected static String elideConsole(String original) { 337 protected static String elideConsole(String original) {
333 return CONSOLE_MSG.matcher(original).replaceAll(CONSOLE_ELISION); 338 return CONSOLE_MSG.matcher(original).replaceAll(CONSOLE_ELISION);
334 } 339 }
335 } 340 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698