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. |
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 // Indicates the JNI registration type hasn't yet been set. |
60 // beginning of JNI_OnLoad to use this. | 60 UNINITIALIZED_JNI_REGISTRATION, |
61 BASE_EXPORT bool IsManualJniRegistrationDisabled(); | 61 // Register all native functions. |
62 BASE_EXPORT void DisableManualJniRegistration(); | 62 ALL_JNI_REGISTRATION, |
| 63 // Register some native functions, as controlled by the jni_generator. |
| 64 SELECTIVE_JNI_REGISTRATION, |
| 65 // Do not register any native functions. |
| 66 NO_JNI_REGISTRATION, |
| 67 }; |
| 68 |
| 69 // Determine the type of JNI registration to complete. |
| 70 BASE_EXPORT void InitJniRegistrationType(JNIEnv* env, bool force_registration); |
| 71 |
| 72 BASE_EXPORT JniRegistrationType GetJniRegistrationType(); |
63 | 73 |
64 // Contains the registration method information for initializing JNI bindings. | 74 // Contains the registration method information for initializing JNI bindings. |
65 struct RegistrationMethod { | 75 struct RegistrationMethod { |
66 const char* name; | 76 const char* name; |
67 bool (*func)(JNIEnv* env); | 77 bool (*func)(JNIEnv* env); |
68 }; | 78 }; |
69 | 79 |
70 // Attaches the current thread to the VM (if necessary) and return the JNIEnv*. | 80 // Attaches the current thread to the VM (if necessary) and return the JNIEnv*. |
71 BASE_EXPORT JNIEnv* AttachCurrentThread(); | 81 BASE_EXPORT JNIEnv* AttachCurrentThread(); |
72 | 82 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 180 |
171 DISALLOW_COPY_AND_ASSIGN(JNIStackFrameSaver); | 181 DISALLOW_COPY_AND_ASSIGN(JNIStackFrameSaver); |
172 }; | 182 }; |
173 | 183 |
174 #endif // HAVE_TRACE_STACK_FRAME_POINTERS | 184 #endif // HAVE_TRACE_STACK_FRAME_POINTERS |
175 | 185 |
176 } // namespace android | 186 } // namespace android |
177 } // namespace base | 187 } // namespace base |
178 | 188 |
179 #endif // BASE_ANDROID_JNI_ANDROID_H_ | 189 #endif // BASE_ANDROID_JNI_ANDROID_H_ |
OLD | NEW |