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 #ifndef BASE_ANDROID_JNI_ANDROID_H_ | 5 #ifndef BASE_ANDROID_JNI_ANDROID_H_ |
6 #define BASE_ANDROID_JNI_ANDROID_H_ | 6 #define BASE_ANDROID_JNI_ANDROID_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #define JNI_LINK_SAVED_FRAME_POINTER | 47 #define JNI_LINK_SAVED_FRAME_POINTER |
48 | 48 |
49 #endif // HAVE_TRACE_STACK_FRAME_POINTERS | 49 #endif // HAVE_TRACE_STACK_FRAME_POINTERS |
50 | 50 |
51 namespace base { | 51 namespace base { |
52 namespace android { | 52 namespace android { |
53 | 53 |
54 // Used to mark symbols to be exported in a shared library's symbol table. | 54 // Used to mark symbols to be exported in a shared library's symbol table. |
55 #define JNI_EXPORT __attribute__ ((visibility("default"))) | 55 #define JNI_EXPORT __attribute__ ((visibility("default"))) |
56 | 56 |
57 // Used to disable manual JNI registration in binaries that prefer to use native | 57 // The level of JNI registration required for the current process. |
58 // JNI exports for startup performance. This is not compatible with the crazy | 58 enum JniRegistrationType { |
59 // linker and so defaults to off. Call DisableManualJniRegistration at the very | 59 // Register all native methods. |
60 // beginning of JNI_OnLoad to use this. | 60 ALL_JNI_REGISTRATION, |
61 BASE_EXPORT bool IsManualJniRegistrationDisabled(); | 61 // Register some native methods, as controlled by the jni_generator. |
62 BASE_EXPORT void DisableManualJniRegistration(); | 62 SELECTIVE_JNI_REGISTRATION, |
| 63 // Do not register any native methods. |
| 64 NO_JNI_REGISTRATION, |
| 65 }; |
| 66 |
| 67 BASE_EXPORT JniRegistrationType GetJniRegistrationType(); |
| 68 |
| 69 // Set the JniRegistrationType for this process (defaults to |
| 70 // ALL_JNI_REGISTRATION). This should be called in the JNI_OnLoad function |
| 71 // which is called when the native library is first loaded. |
| 72 BASE_EXPORT void SetJniRegistrationType( |
| 73 JniRegistrationType jni_registration_type); |
63 | 74 |
64 // Contains the registration method information for initializing JNI bindings. | 75 // Contains the registration method information for initializing JNI bindings. |
65 struct RegistrationMethod { | 76 struct RegistrationMethod { |
66 const char* name; | 77 const char* name; |
67 bool (*func)(JNIEnv* env); | 78 bool (*func)(JNIEnv* env); |
68 }; | 79 }; |
69 | 80 |
70 // Attaches the current thread to the VM (if necessary) and return the JNIEnv*. | 81 // Attaches the current thread to the VM (if necessary) and return the JNIEnv*. |
71 BASE_EXPORT JNIEnv* AttachCurrentThread(); | 82 BASE_EXPORT JNIEnv* AttachCurrentThread(); |
72 | 83 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 181 |
171 DISALLOW_COPY_AND_ASSIGN(JNIStackFrameSaver); | 182 DISALLOW_COPY_AND_ASSIGN(JNIStackFrameSaver); |
172 }; | 183 }; |
173 | 184 |
174 #endif // HAVE_TRACE_STACK_FRAME_POINTERS | 185 #endif // HAVE_TRACE_STACK_FRAME_POINTERS |
175 | 186 |
176 } // namespace android | 187 } // namespace android |
177 } // namespace base | 188 } // namespace base |
178 | 189 |
179 #endif // BASE_ANDROID_JNI_ANDROID_H_ | 190 #endif // BASE_ANDROID_JNI_ANDROID_H_ |
OLD | NEW |