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 #include "base/android/jni_android.h" | 5 #include "base/android/jni_android.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 const char* method_name, | 158 const char* method_name, |
| 159 const char* jni_signature) { | 159 const char* jni_signature) { |
| 160 // clazz.env() can not be used as that may be from a different thread. | 160 // clazz.env() can not be used as that may be from a different thread. |
| 161 return GetMethodID(env, clazz.obj(), method_name, jni_signature); | 161 return GetMethodID(env, clazz.obj(), method_name, jni_signature); |
| 162 } | 162 } |
| 163 | 163 |
| 164 jmethodID GetMethodID(JNIEnv* env, | 164 jmethodID GetMethodID(JNIEnv* env, |
| 165 jclass clazz, | 165 jclass clazz, |
| 166 const char* method_name, | 166 const char* method_name, |
| 167 const char* jni_signature) { | 167 const char* jni_signature) { |
| 168 jmethodID method_id = | 168 jmethodID method_id = GetMethodIDOrNULL( |
| 169 env->GetMethodID(clazz, method_name, jni_signature); | 169 env, clazz, method_name, jni_signature); |
| 170 CHECK(method_id && !ClearException(env)) << "Failed to find method " << | 170 CHECK(method_id) << "Failed to find method " << |
| 171 method_name << " " << jni_signature; | 171 method_name << " " << jni_signature; |
| 172 return method_id; | 172 return method_id; |
| 173 } | 173 } |
| 174 | 174 |
| 175 jmethodID GetMethodIDOrNULL(JNIEnv* env, | |
| 176 jclass clazz, | |
| 177 const char* method_name, | |
| 178 const char* jni_signature) { | |
| 179 jmethodID method_id = | |
| 180 env->GetMethodID(clazz, method_name, jni_signature); | |
| 181 ClearException(env); | |
|
Sami
2012/10/01 11:32:15
This causes some log spam which could be misleadin
bulach
2012/10/01 15:08:37
good point! done..
| |
| 182 return method_id; | |
| 183 } | |
| 184 | |
| 175 jmethodID GetStaticMethodID(JNIEnv* env, | 185 jmethodID GetStaticMethodID(JNIEnv* env, |
| 176 const JavaRef<jclass>& clazz, | 186 const JavaRef<jclass>& clazz, |
| 177 const char* method_name, | 187 const char* method_name, |
| 178 const char* jni_signature) { | 188 const char* jni_signature) { |
| 179 return GetStaticMethodID(env, clazz.obj(), method_name, | 189 return GetStaticMethodID(env, clazz.obj(), method_name, |
| 180 jni_signature); | 190 jni_signature); |
| 181 } | 191 } |
| 182 | 192 |
| 183 jmethodID GetStaticMethodID(JNIEnv* env, | 193 jmethodID GetStaticMethodID(JNIEnv* env, |
| 184 jclass clazz, | 194 jclass clazz, |
| 185 const char* method_name, | 195 const char* method_name, |
| 186 const char* jni_signature) { | 196 const char* jni_signature) { |
| 187 jmethodID method_id = | 197 jmethodID method_id = GetStaticMethodIDOrNULL( |
| 188 env->GetStaticMethodID(clazz, method_name, jni_signature); | 198 env, clazz, method_name, jni_signature); |
| 189 CHECK(method_id && !ClearException(env)) << "Failed to find static method " << | 199 CHECK(method_id) << "Failed to find static method " << |
| 190 method_name << " " << jni_signature; | 200 method_name << " " << jni_signature; |
| 191 return method_id; | 201 return method_id; |
| 192 } | 202 } |
| 193 | 203 |
| 204 jmethodID GetStaticMethodIDOrNULL(JNIEnv* env, | |
| 205 jclass clazz, | |
| 206 const char* method_name, | |
| 207 const char* jni_signature) { | |
| 208 jmethodID method_id = | |
| 209 env->GetStaticMethodID(clazz, method_name, jni_signature); | |
| 210 ClearException(env); | |
| 211 return method_id; | |
| 212 } | |
| 213 | |
| 194 bool HasMethod(JNIEnv* env, | 214 bool HasMethod(JNIEnv* env, |
| 195 const JavaRef<jclass>& clazz, | 215 const JavaRef<jclass>& clazz, |
| 196 const char* method_name, | 216 const char* method_name, |
| 197 const char* jni_signature) { | 217 const char* jni_signature) { |
| 198 jmethodID method_id = | 218 jmethodID method_id = |
| 199 env->GetMethodID(clazz.obj(), method_name, jni_signature); | 219 env->GetMethodID(clazz.obj(), method_name, jni_signature); |
| 200 if (!method_id) { | 220 if (!method_id) { |
| 201 ClearException(env); | 221 ClearException(env); |
| 202 return false; | 222 return false; |
| 203 } | 223 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 // RVO should avoid any extra copies of the exception string. | 339 // RVO should avoid any extra copies of the exception string. |
| 320 base::android::BuildInfo::GetInstance()->set_java_exception_info( | 340 base::android::BuildInfo::GetInstance()->set_java_exception_info( |
| 321 GetJavaExceptionInfo(env, java_throwable)); | 341 GetJavaExceptionInfo(env, java_throwable)); |
| 322 | 342 |
| 323 // Now, feel good about it and die. | 343 // Now, feel good about it and die. |
| 324 CHECK(false); | 344 CHECK(false); |
| 325 } | 345 } |
| 326 | 346 |
| 327 } // namespace android | 347 } // namespace android |
| 328 } // namespace base | 348 } // namespace base |
| OLD | NEW |