| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "android_webview/native/aw_debug.h" | 5 #include "android_webview/native/aw_debug.h" |
| 6 | 6 |
| 7 #include "android_webview/common/crash_reporter/aw_microdump_crash_reporter.h" | 7 #include "android_webview/common/crash_reporter/aw_microdump_crash_reporter.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/debug/crash_logging.h" |
| 10 #include "base/debug/dump_without_crashing.h" | 11 #include "base/debug/dump_without_crashing.h" |
| 11 #include "base/files/file.h" | 12 #include "base/files/file.h" |
| 12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 13 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
| 15 #include "components/crash/content/app/breakpad_linux.h" |
| 14 #include "jni/AwDebug_jni.h" | 16 #include "jni/AwDebug_jni.h" |
| 15 | 17 |
| 16 using base::android::ConvertJavaStringToUTF16; | 18 using base::android::ConvertJavaStringToUTF16; |
| 17 using base::android::ConvertUTF8ToJavaString; | 19 using base::android::ConvertUTF8ToJavaString; |
| 18 using base::android::JavaParamRef; | 20 using base::android::JavaParamRef; |
| 19 using base::android::ScopedJavaLocalRef; | 21 using base::android::ScopedJavaLocalRef; |
| 20 | 22 |
| 21 namespace android_webview { | 23 namespace android_webview { |
| 22 | 24 |
| 23 static jboolean DumpWithoutCrashing(JNIEnv* env, | 25 static jboolean DumpWithoutCrashing(JNIEnv* env, |
| 24 const JavaParamRef<jclass>& clazz, | 26 const JavaParamRef<jclass>& clazz, |
| 25 const JavaParamRef<jstring>& dump_path) { | 27 const JavaParamRef<jstring>& dump_path) { |
| 28 // TODO InitCrashReporter must be called from the right thread. |
| 29 // breakpad::InitCrashReporter(""); |
| 30 // TODO add a jni-method that SetCrashKeyValue (so we can call it from |
| 31 // AwDebugtest). |
| 32 base::debug::SetCrashKeyValue("AW_DEBUG_KEY", "AW_DEBUG_VALUE"); |
| 26 // This may be called from any thread, and we might be in a state | 33 // This may be called from any thread, and we might be in a state |
| 27 // where it is impossible to post tasks, so we have to be prepared | 34 // where it is impossible to post tasks, so we have to be prepared |
| 28 // to do IO from this thread. | 35 // to do IO from this thread. |
| 29 base::ThreadRestrictions::ScopedAllowIO allow_io; | 36 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 30 base::File target(base::FilePath(ConvertJavaStringToUTF8(env, dump_path)), | 37 base::File target(base::FilePath(ConvertJavaStringToUTF8(env, dump_path)), |
| 31 base::File::FLAG_OPEN_TRUNCATED | base::File::FLAG_READ | | 38 base::File::FLAG_OPEN_TRUNCATED | base::File::FLAG_READ | |
| 32 base::File::FLAG_WRITE); | 39 base::File::FLAG_WRITE); |
| 33 if (!target.IsValid()) | 40 if (!target.IsValid()) |
| 34 return false; | 41 return false; |
| 35 // breakpad_linux::HandleCrashDump will close this fd once it is done. | 42 // breakpad_linux::HandleCrashDump will close this fd once it is done. |
| 36 return crash_reporter::DumpWithoutCrashingToFd(target.TakePlatformFile()); | 43 return crash_reporter::DumpWithoutCrashingToFd(target.TakePlatformFile()); |
| 37 } | 44 } |
| 38 | 45 |
| 39 bool RegisterAwDebug(JNIEnv* env) { | 46 bool RegisterAwDebug(JNIEnv* env) { |
| 40 return RegisterNativesImpl(env); | 47 return RegisterNativesImpl(env); |
| 41 } | 48 } |
| 42 | 49 |
| 43 } // namespace android_webview | 50 } // namespace android_webview |
| OLD | NEW |