Chromium Code Reviews| 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 // The level of JNI registration required for the current process. | |
| 58 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.base | |
| 59 enum JniRegistrationType { | |
| 60 // Indicates the JNI registration type hasn't yet been set. | |
| 61 UNINITIALIZED_JNI_REGISTRATION, | |
| 62 // Register all native methods. | |
| 63 ALL_JNI_REGISTRATION, | |
| 64 // Register some native methods, as controlled by the jni_generator. | |
| 65 SELECTIVE_JNI_REGISTRATION, | |
| 66 // Do not register any native methods. | |
| 67 NO_JNI_REGISTRATION, | |
| 68 }; | |
| 69 | |
| 57 // Used to disable manual JNI registration in binaries that prefer to use native | 70 // Used to disable manual JNI registration in binaries that prefer to use native |
| 58 // JNI exports for startup performance. This is not compatible with the crazy | 71 // JNI exports for startup performance. Call DisableManualJniRegistration at |
| 59 // linker and so defaults to off. Call DisableManualJniRegistration at the very | 72 // the very beginning of JNI_OnLoad to use this. |
| 60 // beginning of JNI_OnLoad to use this. | |
| 61 BASE_EXPORT bool IsManualJniRegistrationDisabled(); | |
| 62 BASE_EXPORT void DisableManualJniRegistration(); | 73 BASE_EXPORT void DisableManualJniRegistration(); |
|
Torne
2017/01/30 12:29:56
So with this change we do all registration by defa
estevenson
2017/01/30 19:19:27
We could remove JniRegistrationType from the Java
| |
| 63 | 74 |
| 75 // Gets the JniRegistrationType from Java and caches it on the native side. | |
| 76 BASE_EXPORT JniRegistrationType FetchJniRegistrationType(); | |
| 77 | |
| 64 // Contains the registration method information for initializing JNI bindings. | 78 // Contains the registration method information for initializing JNI bindings. |
| 65 struct RegistrationMethod { | 79 struct RegistrationMethod { |
| 66 const char* name; | 80 const char* name; |
| 67 bool (*func)(JNIEnv* env); | 81 bool (*func)(JNIEnv* env); |
| 68 }; | 82 }; |
| 69 | 83 |
| 70 // Attaches the current thread to the VM (if necessary) and return the JNIEnv*. | 84 // Attaches the current thread to the VM (if necessary) and return the JNIEnv*. |
| 71 BASE_EXPORT JNIEnv* AttachCurrentThread(); | 85 BASE_EXPORT JNIEnv* AttachCurrentThread(); |
| 72 | 86 |
| 73 // Same to AttachCurrentThread except that thread name will be set to | 87 // Same to AttachCurrentThread except that thread name will be set to |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 | 184 |
| 171 DISALLOW_COPY_AND_ASSIGN(JNIStackFrameSaver); | 185 DISALLOW_COPY_AND_ASSIGN(JNIStackFrameSaver); |
| 172 }; | 186 }; |
| 173 | 187 |
| 174 #endif // HAVE_TRACE_STACK_FRAME_POINTERS | 188 #endif // HAVE_TRACE_STACK_FRAME_POINTERS |
| 175 | 189 |
| 176 } // namespace android | 190 } // namespace android |
| 177 } // namespace base | 191 } // namespace base |
| 178 | 192 |
| 179 #endif // BASE_ANDROID_JNI_ANDROID_H_ | 193 #endif // BASE_ANDROID_JNI_ANDROID_H_ |
| OLD | NEW |