OLD | NEW |
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; | 5 package org.chromium.base; |
6 | 6 |
7 import android.support.annotation.UiThread; | 7 import android.support.annotation.UiThread; |
8 | 8 |
9 import org.chromium.base.ThreadUtils; | |
10 import org.chromium.base.annotations.CalledByNative; | 9 import org.chromium.base.annotations.CalledByNative; |
11 import org.chromium.base.annotations.JNINamespace; | 10 import org.chromium.base.annotations.JNINamespace; |
| 11 import org.chromium.base.annotations.MainDex; |
12 | 12 |
13 /** | 13 /** |
14 * This UncaughtExceptionHandler will create a breakpad minidump when there is a
n uncaught | 14 * This UncaughtExceptionHandler will create a breakpad minidump when there is a
n uncaught |
15 * exception. | 15 * exception. |
16 * | 16 * |
17 * The exception's stack trace will be added to the minidump's data. This allows
us to report | 17 * The exception's stack trace will be added to the minidump's data. This allows
java-only crashes |
18 * java-only crashes in the same way that we report all other Chrome crashes. | 18 * to be reported in the same way as other native crashes. |
19 */ | 19 */ |
20 @JNINamespace("chrome::android") | 20 @JNINamespace("base::android") |
| 21 @MainDex |
21 public class JavaExceptionReporter implements Thread.UncaughtExceptionHandler { | 22 public class JavaExceptionReporter implements Thread.UncaughtExceptionHandler { |
22 private Thread.UncaughtExceptionHandler mParent; | 23 private Thread.UncaughtExceptionHandler mParent; |
23 private boolean mHandlingException; | 24 private boolean mHandlingException; |
24 | 25 |
25 JavaExceptionReporter(Thread.UncaughtExceptionHandler parent) { | 26 private JavaExceptionReporter(Thread.UncaughtExceptionHandler parent) { |
26 mParent = parent; | 27 mParent = parent; |
27 } | 28 } |
28 | 29 |
29 @Override | 30 @Override |
30 public void uncaughtException(Thread t, Throwable e) { | 31 public void uncaughtException(Thread t, Throwable e) { |
31 if (!mHandlingException) { | 32 if (!mHandlingException) { |
32 mHandlingException = true; | 33 mHandlingException = true; |
33 nativeReportJavaException(e); | 34 nativeReportJavaException(e); |
34 } | 35 } |
35 if (mParent != null) { | 36 if (mParent != null) { |
(...skipping 16 matching lines...) Expand all Loading... |
52 | 53 |
53 @CalledByNative | 54 @CalledByNative |
54 private static void installHandler() { | 55 private static void installHandler() { |
55 Thread.setDefaultUncaughtExceptionHandler( | 56 Thread.setDefaultUncaughtExceptionHandler( |
56 new JavaExceptionReporter(Thread.getDefaultUncaughtExceptionHand
ler())); | 57 new JavaExceptionReporter(Thread.getDefaultUncaughtExceptionHand
ler())); |
57 } | 58 } |
58 | 59 |
59 private static native void nativeReportJavaException(Throwable e); | 60 private static native void nativeReportJavaException(Throwable e); |
60 private static native void nativeReportJavaStackTrace(String stackTrace); | 61 private static native void nativeReportJavaStackTrace(String stackTrace); |
61 } | 62 } |
OLD | NEW |