| 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 "android_webview/native/aw_debug.h" | |
| 6 | |
| 7 #include "android_webview/common/crash_reporter/aw_microdump_crash_reporter.h" | |
| 8 #include "android_webview/common/crash_reporter/crash_keys.h" | |
| 9 #include "base/android/jni_android.h" | |
| 10 #include "base/android/jni_string.h" | |
| 11 #include "base/debug/crash_logging.h" | |
| 12 #include "base/debug/dump_without_crashing.h" | |
| 13 #include "base/files/file.h" | |
| 14 #include "base/files/file_path.h" | |
| 15 #include "base/threading/thread_restrictions.h" | |
| 16 #include "jni/AwDebug_jni.h" | |
| 17 | |
| 18 using base::android::ConvertJavaStringToUTF16; | |
| 19 using base::android::ConvertUTF8ToJavaString; | |
| 20 using base::android::JavaParamRef; | |
| 21 using base::android::ScopedJavaLocalRef; | |
| 22 | |
| 23 namespace android_webview { | |
| 24 | |
| 25 static jboolean DumpWithoutCrashing(JNIEnv* env, | |
| 26 const JavaParamRef<jclass>& clazz, | |
| 27 const JavaParamRef<jstring>& dump_path) { | |
| 28 // This may be called from any thread, and we might be in a state | |
| 29 // where it is impossible to post tasks, so we have to be prepared | |
| 30 // to do IO from this thread. | |
| 31 base::ThreadRestrictions::ScopedAllowIO allow_io; | |
| 32 base::File target(base::FilePath(ConvertJavaStringToUTF8(env, dump_path)), | |
| 33 base::File::FLAG_OPEN_TRUNCATED | base::File::FLAG_READ | | |
| 34 base::File::FLAG_WRITE); | |
| 35 if (!target.IsValid()) | |
| 36 return false; | |
| 37 // breakpad_linux::HandleCrashDump will close this fd once it is done. | |
| 38 return crash_reporter::DumpWithoutCrashingToFd(target.TakePlatformFile()); | |
| 39 } | |
| 40 | |
| 41 static void InitCrashKeysForWebViewTesting(JNIEnv* env, | |
| 42 const JavaParamRef<jclass>& clazz) { | |
| 43 crash_keys::InitCrashKeysForWebViewTesting(); | |
| 44 } | |
| 45 | |
| 46 static void SetCrashKeyValue(JNIEnv* env, | |
| 47 const JavaParamRef<jclass>& clazz, | |
| 48 const JavaParamRef<jstring>& key, | |
| 49 const JavaParamRef<jstring>& value) { | |
| 50 base::debug::SetCrashKeyValue(ConvertJavaStringToUTF8(env, key), | |
| 51 ConvertJavaStringToUTF8(env, value)); | |
| 52 } | |
| 53 | |
| 54 bool RegisterAwDebug(JNIEnv* env) { | |
| 55 return RegisterNativesImpl(env); | |
| 56 } | |
| 57 | |
| 58 } // namespace android_webview | |
| OLD | NEW |