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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 const JavaRef<jclass>& clazz, | 64 const JavaRef<jclass>& clazz, |
| 65 const char* method_name, | 65 const char* method_name, |
| 66 const char* jni_signature); | 66 const char* jni_signature); |
| 67 | 67 |
| 68 // Similar to GetMethodID, but takes a raw jclass. | 68 // Similar to GetMethodID, but takes a raw jclass. |
| 69 jmethodID GetMethodID(JNIEnv* env, | 69 jmethodID GetMethodID(JNIEnv* env, |
| 70 jclass clazz, | 70 jclass clazz, |
| 71 const char* method_name, | 71 const char* method_name, |
| 72 const char* jni_signature); | 72 const char* jni_signature); |
| 73 | 73 |
| 74 // Unlike GetMethodID, returns NULL if the method could not be found. | |
| 75 jmethodID GetMethodIDOrNULL(JNIEnv* env, | |
|
Sami
2012/10/01 11:32:15
Nit: GetMethodIDOrNull would be more consistent wi
bulach
2012/10/01 15:08:37
Done.
| |
| 76 jclass clazz, | |
| 77 const char* method_name, | |
| 78 const char* jni_signature); | |
| 79 | |
| 74 // Returns the method ID for the static method with the specified name and | 80 // Returns the method ID for the static method with the specified name and |
| 75 // signature. | 81 // signature. |
| 76 // This method triggers a fatal assertion if the method could not be found. | 82 // This method triggers a fatal assertion if the method could not be found. |
| 77 // Use HasMethod if you need to check whether a method exists. | 83 // Use HasMethod if you need to check whether a method exists. |
| 78 jmethodID GetStaticMethodID(JNIEnv* env, | 84 jmethodID GetStaticMethodID(JNIEnv* env, |
| 79 const JavaRef<jclass>& clazz, | 85 const JavaRef<jclass>& clazz, |
| 80 const char* method_name, | 86 const char* method_name, |
| 81 const char* jni_signature); | 87 const char* jni_signature); |
| 82 | 88 |
| 83 // Similar to the GetStaticMethodID, but takes a raw jclass. | 89 // Similar to the GetStaticMethodID, but takes a raw jclass. |
| 84 jmethodID GetStaticMethodID(JNIEnv* env, | 90 jmethodID GetStaticMethodID(JNIEnv* env, |
| 85 jclass clazz, | 91 jclass clazz, |
| 86 const char* method_name, | 92 const char* method_name, |
| 87 const char* jni_signature); | 93 const char* jni_signature); |
| 88 | 94 |
| 95 // Unlike GetStaticMethodID, returns NULL if the method could not be found. | |
| 96 jmethodID GetStaticMethodIDOrNULL(JNIEnv* env, | |
| 97 jclass clazz, | |
| 98 const char* method_name, | |
| 99 const char* jni_signature); | |
| 100 | |
| 89 | 101 |
| 90 // Returns true iff |clazz| has a method with the specified name and signature. | 102 // Returns true iff |clazz| has a method with the specified name and signature. |
| 91 bool HasMethod(JNIEnv* env, | 103 bool HasMethod(JNIEnv* env, |
| 92 const JavaRef<jclass>& clazz, | 104 const JavaRef<jclass>& clazz, |
| 93 const char* method_name, | 105 const char* method_name, |
| 94 const char* jni_signature); | 106 const char* jni_signature); |
| 95 | 107 |
| 96 // Gets the method ID from the class name. Clears the pending Java exception | 108 // Gets the method ID from the class name. Clears the pending Java exception |
| 97 // and returns NULL if the method is not found. Caches results. Note that | 109 // and returns NULL if the method is not found. Caches results. Note that |
| 98 // GetMethodID() below avoids a class lookup, but does not cache results. | 110 // GetMethodID() below avoids a class lookup, but does not cache results. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 133 // and returns true. | 145 // and returns true. |
| 134 bool ClearException(JNIEnv* env); | 146 bool ClearException(JNIEnv* env); |
| 135 | 147 |
| 136 // This function will call CHECK() macro if there's any pending exception. | 148 // This function will call CHECK() macro if there's any pending exception. |
| 137 void CheckException(JNIEnv* env); | 149 void CheckException(JNIEnv* env); |
| 138 | 150 |
| 139 } // namespace android | 151 } // namespace android |
| 140 } // namespace base | 152 } // namespace base |
| 141 | 153 |
| 142 #endif // BASE_ANDROID_JNI_ANDROID_H_ | 154 #endif // BASE_ANDROID_JNI_ANDROID_H_ |
| OLD | NEW |