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/debug/debugging_flags.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/threading/thread_local.h" | 17 #include "base/threading/thread_local.h" |
18 | 18 |
19 namespace { | 19 namespace { |
20 using base::android::GetClass; | 20 using base::android::GetClass; |
21 using base::android::MethodID; | 21 using base::android::MethodID; |
22 using base::android::ScopedJavaLocalRef; | 22 using base::android::ScopedJavaLocalRef; |
23 | 23 |
24 bool g_disable_manual_jni_registration = false; | 24 base::android::JniRegistrationType g_jni_registration_type = |
| 25 base::android::ALL_JNI_REGISTRATION; |
25 | 26 |
26 JavaVM* g_jvm = NULL; | 27 JavaVM* g_jvm = NULL; |
27 base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject> >::Leaky | 28 base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject> >::Leaky |
28 g_class_loader = LAZY_INSTANCE_INITIALIZER; | 29 g_class_loader = LAZY_INSTANCE_INITIALIZER; |
29 jmethodID g_class_loader_load_class_method_id = 0; | 30 jmethodID g_class_loader_load_class_method_id = 0; |
30 | 31 |
31 #if BUILDFLAG(ENABLE_PROFILING) && HAVE_TRACE_STACK_FRAME_POINTERS | 32 #if BUILDFLAG(ENABLE_PROFILING) && HAVE_TRACE_STACK_FRAME_POINTERS |
32 base::LazyInstance<base::ThreadLocalPointer<void>>::Leaky | 33 base::LazyInstance<base::ThreadLocalPointer<void>>::Leaky |
33 g_stack_frame_pointer = LAZY_INSTANCE_INITIALIZER; | 34 g_stack_frame_pointer = LAZY_INSTANCE_INITIALIZER; |
34 #endif | 35 #endif |
35 | 36 |
36 } // namespace | 37 } // namespace |
37 | 38 |
38 namespace base { | 39 namespace base { |
39 namespace android { | 40 namespace android { |
40 | 41 |
41 bool IsManualJniRegistrationDisabled() { | 42 JniRegistrationType GetJniRegistrationType() { |
42 return g_disable_manual_jni_registration; | 43 return g_jni_registration_type; |
43 } | 44 } |
44 | 45 |
45 void DisableManualJniRegistration() { | 46 void SetJniRegistrationType(JniRegistrationType jni_registration_type) { |
46 DCHECK(!g_disable_manual_jni_registration); | 47 g_jni_registration_type = jni_registration_type; |
47 g_disable_manual_jni_registration = true; | |
48 } | 48 } |
49 | 49 |
50 JNIEnv* AttachCurrentThread() { | 50 JNIEnv* AttachCurrentThread() { |
51 DCHECK(g_jvm); | 51 DCHECK(g_jvm); |
52 JNIEnv* env = NULL; | 52 JNIEnv* env = NULL; |
53 jint ret = g_jvm->AttachCurrentThread(&env, NULL); | 53 jint ret = g_jvm->AttachCurrentThread(&env, NULL); |
54 DCHECK_EQ(JNI_OK, ret); | 54 DCHECK_EQ(JNI_OK, ret); |
55 return env; | 55 return env; |
56 } | 56 } |
57 | 57 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 301 } |
302 | 302 |
303 void* JNIStackFrameSaver::SavedFrame() { | 303 void* JNIStackFrameSaver::SavedFrame() { |
304 return g_stack_frame_pointer.Pointer()->Get(); | 304 return g_stack_frame_pointer.Pointer()->Get(); |
305 } | 305 } |
306 | 306 |
307 #endif // ENABLE_PROFILING && HAVE_TRACE_STACK_FRAME_POINTERS | 307 #endif // ENABLE_PROFILING && HAVE_TRACE_STACK_FRAME_POINTERS |
308 | 308 |
309 } // namespace android | 309 } // namespace android |
310 } // namespace base | 310 } // namespace base |
OLD | NEW |