Commit 9b51b518 authored by boliu's avatar boliu Committed by Commit bot

android: Move JavaExceptionReporter to base

So that it can be used in other processes as well.
There as some comment changes, and added @MainDex. But otherwise
a straightforward move.

BUG=680775

Review-Url: https://codereview.chromium.org/2667263002
Cr-Commit-Position: refs/heads/master@{#448000}
parent 9f800ec0
......@@ -184,6 +184,8 @@ component("base") {
"android/field_trial_list.h",
"android/important_file_writer_android.cc",
"android/important_file_writer_android.h",
"android/java_exception_reporter.cc",
"android/java_exception_reporter.h",
"android/java_handler_thread.cc",
"android/java_handler_thread.h",
"android/java_message_handler_factory.h",
......@@ -2380,6 +2382,7 @@ if (is_android) {
"android/java/src/org/chromium/base/FieldTrialList.java",
"android/java/src/org/chromium/base/ImportantFileWriterAndroid.java",
"android/java/src/org/chromium/base/JNIUtils.java",
"android/java/src/org/chromium/base/JavaExceptionReporter.java",
"android/java/src/org/chromium/base/JavaHandlerThread.java",
"android/java/src/org/chromium/base/LocaleUtils.java",
"android/java/src/org/chromium/base/MemoryPressureListener.java",
......@@ -2446,6 +2449,7 @@ if (is_android) {
"android/java/src/org/chromium/base/FileUtils.java",
"android/java/src/org/chromium/base/ImportantFileWriterAndroid.java",
"android/java/src/org/chromium/base/JNIUtils.java",
"android/java/src/org/chromium/base/JavaExceptionReporter.java",
"android/java/src/org/chromium/base/JavaHandlerThread.java",
"android/java/src/org/chromium/base/LocaleUtils.java",
"android/java/src/org/chromium/base/Log.java",
......
......@@ -12,6 +12,7 @@
#include "base/android/early_trace_event_binding.h"
#include "base/android/field_trial_list.h"
#include "base/android/important_file_writer_android.h"
#include "base/android/java_exception_reporter.h"
#include "base/android/java_handler_thread.h"
#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
......@@ -44,6 +45,7 @@ static RegistrationMethod kBaseRegisteredMethods[] = {
base::android::RegisterImportantFileWriterAndroid},
{"MemoryPressureListenerAndroid",
base::android::MemoryPressureListenerAndroid::Register},
{"JavaExceptionReporter", base::android::RegisterJavaExceptionReporterJni},
{"JavaHandlerThread", base::android::JavaHandlerThread::RegisterBindings},
{"PathService", base::android::RegisterPathService},
{"PowerMonitor", base::RegisterPowerMonitor},
......
......@@ -2,27 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser;
package org.chromium.base;
import android.support.annotation.UiThread;
import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.MainDex;
/**
* This UncaughtExceptionHandler will create a breakpad minidump when there is an uncaught
* exception.
*
* The exception's stack trace will be added to the minidump's data. This allows us to report
* java-only crashes in the same way that we report all other Chrome crashes.
* The exception's stack trace will be added to the minidump's data. This allows java-only crashes
* to be reported in the same way as other native crashes.
*/
@JNINamespace("chrome::android")
@JNINamespace("base::android")
@MainDex
public class JavaExceptionReporter implements Thread.UncaughtExceptionHandler {
private Thread.UncaughtExceptionHandler mParent;
private boolean mHandlingException;
JavaExceptionReporter(Thread.UncaughtExceptionHandler parent) {
private JavaExceptionReporter(Thread.UncaughtExceptionHandler parent) {
mParent = parent;
}
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/android/java_exception_reporter.h"
#include "base/android/java_exception_reporter.h"
#include "base/android/build_info.h"
#include "base/android/jni_android.h"
......@@ -12,7 +12,7 @@
using base::android::JavaParamRef;
namespace chrome {
namespace base {
namespace android {
void InitJavaExceptionReporter() {
......@@ -43,8 +43,5 @@ bool RegisterJavaExceptionReporterJni(JNIEnv* env) {
return RegisterNativesImpl(env);
}
} // namespace android
} // namespace chrome
} // namespace base
......@@ -2,18 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ANDROID_JAVA_EXCEPTION_REPORTER_H_
#define CHROME_BROWSER_ANDROID_JAVA_EXCEPTION_REPORTER_H_
#ifndef BASE_ANDROID_JAVA_EXCEPTION_REPORTER_H_
#define BASE_ANDROID_JAVA_EXCEPTION_REPORTER_H_
#include <jni.h>
namespace chrome {
#include "base/base_export.h"
namespace base {
namespace android {
void InitJavaExceptionReporter();
// Install the exception handler. This should only be called once per process.
BASE_EXPORT void InitJavaExceptionReporter();
bool RegisterJavaExceptionReporterJni(JNIEnv* env);
} // namespace android
} // namespace chrome
} // namespace base
#endif // CHROME_BROWSER_ANDROID_JAVA_EXCEPTION_REPORTER_H_
#endif // BASE_ANDROID_JAVA_EXCEPTION_REPORTER_H_
......@@ -13,6 +13,7 @@ import android.support.annotation.UiThread;
import org.chromium.base.BuildConfig;
import org.chromium.base.CommandLine;
import org.chromium.base.JavaExceptionReporter;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.SuppressFBWarnings;
......
......@@ -38,7 +38,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/IntentHandler.java",
"java/src/org/chromium/chrome/browser/IntentHelper.java",
"java/src/org/chromium/chrome/browser/ItemChooserDialog.java",
"java/src/org/chromium/chrome/browser/JavaExceptionReporter.java",
"java/src/org/chromium/chrome/browser/JavascriptAppModalDialog.java",
"java/src/org/chromium/chrome/browser/KeyboardShortcuts.java",
"java/src/org/chromium/chrome/browser/DelayedScreenLockIntentHandler.java",
......
......@@ -103,7 +103,7 @@
#endif
#if defined(OS_ANDROID)
#include "chrome/browser/android/java_exception_reporter.h"
#include "base/android/java_exception_reporter.h"
#include "chrome/common/descriptors_android.h"
#else
// Diagnostics is only available on non-android platforms.
......@@ -890,7 +890,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
#if defined(OS_ANDROID)
if (process_type.empty()) {
breakpad::InitCrashReporter(process_type);
chrome::android::InitJavaExceptionReporter();
base::android::InitJavaExceptionReporter();
} else {
breakpad::InitNonBrowserCrashReporterForAndroid(process_type);
}
......
......@@ -2694,8 +2694,6 @@ split_static_library("browser") {
"android/instantapps/instant_apps_settings.h",
"android/intent_helper.cc",
"android/intent_helper.h",
"android/java_exception_reporter.cc",
"android/java_exception_reporter.h",
"android/large_icon_bridge.cc",
"android/large_icon_bridge.h",
"android/locale/special_locale_handler.cc",
......@@ -3898,7 +3896,6 @@ if (is_android) {
"../android/java/src/org/chromium/chrome/browser/ChromeHttpAuthHandler.java",
"../android/java/src/org/chromium/chrome/browser/DevToolsServer.java",
"../android/java/src/org/chromium/chrome/browser/IntentHelper.java",
"../android/java/src/org/chromium/chrome/browser/JavaExceptionReporter.java",
"../android/java/src/org/chromium/chrome/browser/JavascriptAppModalDialog.java",
"../android/java/src/org/chromium/chrome/browser/PasswordUIView.java",
"../android/java/src/org/chromium/chrome/browser/SSLClientCertificateRequest.java",
......
......@@ -54,7 +54,6 @@
#include "chrome/browser/android/history_report/history_report_jni_bridge.h"
#include "chrome/browser/android/instantapps/instant_apps_infobar_delegate.h"
#include "chrome/browser/android/instantapps/instant_apps_settings.h"
#include "chrome/browser/android/java_exception_reporter.h"
#include "chrome/browser/android/large_icon_bridge.h"
#include "chrome/browser/android/locale/special_locale_handler.h"
#include "chrome/browser/android/logo_bridge.h"
......@@ -307,8 +306,6 @@ static base::android::RegistrationMethod kChromeRegisteredMethods[] = {
invalidation::InvalidationServiceFactoryAndroid::Register},
{"SimpleConfirmInfoBarBuilder", RegisterSimpleConfirmInfoBarBuilder},
{"ShortcutHelper", ShortcutHelper::RegisterShortcutHelper},
{"JavaExceptionReporter",
chrome::android::RegisterJavaExceptionReporterJni},
{"JavascriptAppModalDialog",
JavascriptAppModalDialogAndroid::RegisterJavascriptAppModalDialog},
{"LargeIconBridge", LargeIconBridge::RegisterLargeIconBridge},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment