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

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

Issue 2727573004: [Android Crash Reporting] Simplify crash report upload code. (Closed)
Patch Set: Fix up a comment 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
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.crash;
6
7 import android.app.IntentService;
8 import android.content.Context;
9 import android.content.Intent;
10
11 import org.chromium.base.Log;
12 import org.chromium.components.minidump_uploader.CrashFileManager;
13
14 import java.io.File;
15 import java.util.concurrent.Callable;
16
17 /**
18 * Prepares the minidump for first upload attempt by combining both the
19 * minidump file and the logcat file.
20 */
21 public class MinidumpPreparationService extends IntentService {
22 private static final String TAG = "DumpPrepService";
23 private static final String LOGCAT_FILE_KEY = "logcat";
24 private static final String MINIDUMP_FILE_KEY = "minidump";
25 private static final String REDIRECT_INTENT_KEY = "redirect_intent";
26
27 public static Intent createMinidumpPreparationIntent(
28 Context context, File minidumpFile, File logcatFile, Intent redirect Intent) {
29 Intent intent = new Intent(context, MinidumpPreparationService.class);
30 if (minidumpFile != null) {
31 intent.putExtra(MINIDUMP_FILE_KEY, minidumpFile.getName());
32 }
33 if (logcatFile != null) {
34 intent.putExtra(LOGCAT_FILE_KEY, logcatFile.getName());
35 }
36 if (redirectIntent != null) {
37 intent.putExtra(REDIRECT_INTENT_KEY, redirectIntent);
38 }
39 return intent;
40 }
41
42 public MinidumpPreparationService() {
43 super(TAG);
44 setIntentRedelivery(true);
45 }
46
47 private Callable<Boolean> createMinidumpPreparationCallable(Context context, Intent intent) {
48 String minidumpFilePath = intent.getStringExtra(MINIDUMP_FILE_KEY);
49 String logcatFilePath = intent.getStringExtra(LOGCAT_FILE_KEY);
50 CrashFileManager fileManager = new CrashFileManager(context.getCacheDir( ));
51 File minidumpFile = fileManager.getCrashFile(minidumpFilePath);
52 File logcatFile = fileManager.getCrashFile(logcatFilePath);
53 Intent redirectIntent = intent.getParcelableExtra(REDIRECT_INTENT_KEY);
54 return new MinidumpPreparationCallable(
55 getApplicationContext(), minidumpFile, logcatFile, redirectInten t);
56 }
57
58 private void handleMinidumpPreparationRequest(Intent intent) {
59 try {
60 if (!createMinidumpPreparationCallable(getApplicationContext(), inte nt).call()) {
61 Log.w(TAG, "Fail to prepare minidump with logcat!");
62 }
63 } catch (Exception e) {
64 Log.w(TAG, e.toString());
65 }
66 }
67
68 @Override
69 protected void onHandleIntent(Intent intent) {
70 handleMinidumpPreparationRequest(intent);
71 }
72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698