| OLD | NEW |
| (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 #include "chrome/browser/android/java_exception_reporter.h" | |
| 6 | |
| 7 #include "base/android/build_info.h" | |
| 8 #include "base/android/jni_android.h" | |
| 9 #include "base/android/jni_string.h" | |
| 10 #include "base/debug/dump_without_crashing.h" | |
| 11 #include "jni/JavaExceptionReporter_jni.h" | |
| 12 | |
| 13 using base::android::JavaParamRef; | |
| 14 | |
| 15 namespace chrome { | |
| 16 namespace android { | |
| 17 | |
| 18 void InitJavaExceptionReporter() { | |
| 19 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 20 Java_JavaExceptionReporter_installHandler(env); | |
| 21 } | |
| 22 | |
| 23 void ReportJavaException(JNIEnv* env, | |
| 24 const JavaParamRef<jclass>& jcaller, | |
| 25 const JavaParamRef<jthrowable>& e) { | |
| 26 // Set the exception_string in BuildInfo so that breakpad can read it. | |
| 27 base::android::BuildInfo::GetInstance()->SetJavaExceptionInfo( | |
| 28 base::android::GetJavaExceptionInfo(env, e)); | |
| 29 base::debug::DumpWithoutCrashing(); | |
| 30 base::android::BuildInfo::GetInstance()->ClearJavaExceptionInfo(); | |
| 31 } | |
| 32 | |
| 33 void ReportJavaStackTrace(JNIEnv* env, | |
| 34 const JavaParamRef<jclass>& jcaller, | |
| 35 const JavaParamRef<jstring>& stackTrace) { | |
| 36 base::android::BuildInfo::GetInstance()->SetJavaExceptionInfo( | |
| 37 ConvertJavaStringToUTF8(stackTrace)); | |
| 38 base::debug::DumpWithoutCrashing(); | |
| 39 base::android::BuildInfo::GetInstance()->ClearJavaExceptionInfo(); | |
| 40 } | |
| 41 | |
| 42 bool RegisterJavaExceptionReporterJni(JNIEnv* env) { | |
| 43 return RegisterNativesImpl(env); | |
| 44 } | |
| 45 | |
| 46 | |
| 47 } // namespace android | |
| 48 } // namespace chrome | |
| 49 | |
| 50 | |
| OLD | NEW |