blob: 56baef7586e5f89e5b8e80eda7227d9c0e0cceb4 [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2015 The Chromium Authors
boliu9b51b512017-02-03 15:35:052// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef BASE_ANDROID_JAVA_EXCEPTION_REPORTER_H_
6#define BASE_ANDROID_JAVA_EXCEPTION_REPORTER_H_
7
8#include <jni.h>
9
Tobias Sargeant5e78771d2019-09-21 13:49:2310#include "base/android/scoped_java_ref.h"
boliu9b51b512017-02-03 15:35:0511#include "base/base_export.h"
Hans Wennborg9f3bb63d2020-04-21 11:12:3812#include "base/callback_forward.h"
boliu9b51b512017-02-03 15:35:0513
14namespace base {
15namespace android {
16
17// Install the exception handler. This should only be called once per process.
18BASE_EXPORT void InitJavaExceptionReporter();
19
boliu328eda132017-02-10 16:39:5720// Same as above except the handler ensures child process exists immediately
21// after an unhandled exception. This is used for child processes because
22// DumpWithoutCrashing does not work for child processes on Android.
23BASE_EXPORT void InitJavaExceptionReporterForChildProcess();
24
Joshua Peraza7814da22018-07-10 21:37:5025// Sets a callback to be called with the contents of a Java exception, which may
26// be nullptr.
27BASE_EXPORT void SetJavaExceptionCallback(void (*)(const char* exception));
28
29// Calls the Java exception callback, if any, with exception.
30void SetJavaException(const char* exception);
31
Tobias Sargeant5e78771d2019-09-21 13:49:2332// Sets a filter that determines whether a java exception should cause a crash
33// report. |java_exception_filter| should return true if a crash report should
34// be generated.
Tobias Sargeante3608f82019-09-30 14:10:3235BASE_EXPORT void SetJavaExceptionFilter(
Tobias Sargeant5e78771d2019-09-21 13:49:2336 base::RepeatingCallback<bool(const JavaRef<jthrowable>&)>
37 java_exception_filter);
38
boliu9b51b512017-02-03 15:35:0539} // namespace android
40} // namespace base
41
42#endif // BASE_ANDROID_JAVA_EXCEPTION_REPORTER_H_