java_exception_reporter.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #ifndef BASE_ANDROID_JAVA_EXCEPTION_REPORTER_H_
  5. #define BASE_ANDROID_JAVA_EXCEPTION_REPORTER_H_
  6. #include <jni.h>
  7. #include "base/android/scoped_java_ref.h"
  8. #include "base/base_export.h"
  9. #include "base/callback_forward.h"
  10. namespace base {
  11. namespace android {
  12. // Install the exception handler. This should only be called once per process.
  13. BASE_EXPORT void InitJavaExceptionReporter();
  14. // Same as above except the handler ensures child process exists immediately
  15. // after an unhandled exception. This is used for child processes because
  16. // DumpWithoutCrashing does not work for child processes on Android.
  17. BASE_EXPORT void InitJavaExceptionReporterForChildProcess();
  18. // Sets a callback to be called with the contents of a Java exception, which may
  19. // be nullptr.
  20. BASE_EXPORT void SetJavaExceptionCallback(void (*)(const char* exception));
  21. // Calls the Java exception callback, if any, with exception.
  22. void SetJavaException(const char* exception);
  23. // Sets a filter that determines whether a java exception should cause a crash
  24. // report. |java_exception_filter| should return true if a crash report should
  25. // be generated.
  26. BASE_EXPORT void SetJavaExceptionFilter(
  27. base::RepeatingCallback<bool(const JavaRef<jthrowable>&)>
  28. java_exception_filter);
  29. } // namespace android
  30. } // namespace base
  31. #endif // BASE_ANDROID_JAVA_EXCEPTION_REPORTER_H_