Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2335)

Unified Diff: base/android/jni_android.cc

Issue 9599010: JNI Bindings on Chrome for Android: unfork. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mark's comment Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/android/jni_android.h ('k') | base/base.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/jni_android.cc
diff --git a/base/android/jni_android.cc b/base/android/jni_android.cc
index 69399ad480f3b3090dc105161fa155f64a34e66d..1b7c72c82fa7baa830bb7a8a95896140fb7f0774 100644
--- a/base/android/jni_android.cc
+++ b/base/android/jni_android.cc
@@ -86,9 +86,13 @@ const jobject GetApplicationContext() {
}
ScopedJavaLocalRef<jclass> GetClass(JNIEnv* env, const char* class_name) {
+ return ScopedJavaLocalRef<jclass>(env, GetUnscopedClass(env, class_name));
+}
+
+jclass GetUnscopedClass(JNIEnv* env, const char* class_name) {
jclass clazz = env->FindClass(class_name);
CHECK(clazz && !ClearException(env)) << "Failed to find class " << class_name;
- return ScopedJavaLocalRef<jclass>(env, clazz);
+ return clazz;
}
bool HasClass(JNIEnv* env, const char* class_name) {
@@ -106,8 +110,16 @@ jmethodID GetMethodID(JNIEnv* env,
const JavaRef<jclass>& clazz,
const char* method_name,
const char* jni_signature) {
+ // We can't use clazz.env() as that may be from a different thread.
+ return GetMethodID(env, clazz.obj(), method_name, jni_signature);
+}
+
+jmethodID GetMethodID(JNIEnv* env,
+ jclass clazz,
+ const char* method_name,
+ const char* jni_signature) {
jmethodID method_id =
- env->GetMethodID(clazz.obj(), method_name, jni_signature);
+ env->GetMethodID(clazz, method_name, jni_signature);
CHECK(method_id && !ClearException(env)) << "Failed to find method " <<
method_name << " " << jni_signature;
return method_id;
@@ -117,8 +129,16 @@ jmethodID GetStaticMethodID(JNIEnv* env,
const JavaRef<jclass>& clazz,
const char* method_name,
const char* jni_signature) {
+ return GetStaticMethodID(env, clazz.obj(), method_name,
+ jni_signature);
+}
+
+jmethodID GetStaticMethodID(JNIEnv* env,
+ jclass clazz,
+ const char* method_name,
+ const char* jni_signature) {
jmethodID method_id =
- env->GetStaticMethodID(clazz.obj(), method_name, jni_signature);
+ env->GetStaticMethodID(clazz, method_name, jni_signature);
CHECK(method_id && !ClearException(env)) << "Failed to find static method " <<
method_name << " " << jni_signature;
return method_id;
« no previous file with comments | « base/android/jni_android.h ('k') | base/base.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698