OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/android/jni_android.h" | 5 #include "base/android/jni_android.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/android/build_info.h" | 11 #include "base/android/build_info.h" |
12 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
13 #include "base/android/jni_utils.h" | 13 #include "base/android/jni_utils.h" |
| 14 #include "base/debug/debugging_flags.h" |
14 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/threading/thread_local.h" |
16 | 18 |
17 namespace { | 19 namespace { |
18 using base::android::GetClass; | 20 using base::android::GetClass; |
19 using base::android::MethodID; | 21 using base::android::MethodID; |
20 using base::android::ScopedJavaLocalRef; | 22 using base::android::ScopedJavaLocalRef; |
21 | 23 |
22 bool g_disable_manual_jni_registration = false; | 24 bool g_disable_manual_jni_registration = false; |
23 | 25 |
24 JavaVM* g_jvm = NULL; | 26 JavaVM* g_jvm = NULL; |
25 base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject> >::Leaky | 27 base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject> >::Leaky |
26 g_class_loader = LAZY_INSTANCE_INITIALIZER; | 28 g_class_loader = LAZY_INSTANCE_INITIALIZER; |
27 jmethodID g_class_loader_load_class_method_id = 0; | 29 jmethodID g_class_loader_load_class_method_id = 0; |
28 | 30 |
| 31 #if BUILDFLAG(ENABLE_PROFILING) && HAVE_TRACE_STACK_FRAME_POINTERS |
| 32 base::LazyInstance<base::ThreadLocalPointer<void>>::Leaky |
| 33 g_stack_frame_pointer = LAZY_INSTANCE_INITIALIZER; |
| 34 #endif |
| 35 |
29 } // namespace | 36 } // namespace |
30 | 37 |
31 namespace base { | 38 namespace base { |
32 namespace android { | 39 namespace android { |
33 | 40 |
34 bool IsManualJniRegistrationDisabled() { | 41 bool IsManualJniRegistrationDisabled() { |
35 return g_disable_manual_jni_registration; | 42 return g_disable_manual_jni_registration; |
36 } | 43 } |
37 | 44 |
38 void DisableManualJniRegistration() { | 45 void DisableManualJniRegistration() { |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 282 |
276 // Call ByteArrayOutputStream.toString() | 283 // Call ByteArrayOutputStream.toString() |
277 ScopedJavaLocalRef<jstring> exception_string( | 284 ScopedJavaLocalRef<jstring> exception_string( |
278 env, static_cast<jstring>( | 285 env, static_cast<jstring>( |
279 env->CallObjectMethod(bytearray_output_stream.obj(), | 286 env->CallObjectMethod(bytearray_output_stream.obj(), |
280 bytearray_output_stream_tostring))); | 287 bytearray_output_stream_tostring))); |
281 | 288 |
282 return ConvertJavaStringToUTF8(exception_string); | 289 return ConvertJavaStringToUTF8(exception_string); |
283 } | 290 } |
284 | 291 |
| 292 #if BUILDFLAG(ENABLE_PROFILING) && HAVE_TRACE_STACK_FRAME_POINTERS |
| 293 |
| 294 JNIStackFrameSaver::JNIStackFrameSaver(void* current_fp) { |
| 295 previous_fp_ = g_stack_frame_pointer.Pointer()->Get(); |
| 296 g_stack_frame_pointer.Pointer()->Set(current_fp); |
| 297 } |
| 298 |
| 299 JNIStackFrameSaver::~JNIStackFrameSaver() { |
| 300 g_stack_frame_pointer.Pointer()->Set(previous_fp_); |
| 301 } |
| 302 |
| 303 void* JNIStackFrameSaver::SavedFrame() { |
| 304 return g_stack_frame_pointer.Pointer()->Get(); |
| 305 } |
| 306 |
| 307 #endif // ENABLE_PROFILING && HAVE_TRACE_STACK_FRAME_POINTERS |
285 | 308 |
286 } // namespace android | 309 } // namespace android |
287 } // namespace base | 310 } // namespace base |
OLD | NEW |