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

Unified Diff: base/android/jni_android.cc

Issue 8509019: Add JavaBoundObject (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use mutable Created 9 years, 1 month 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') | content/browser/renderer_host/java/java_bound_object.h » ('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 1dc02afb3b0543fce35b14fcf1fb4401109a4db9..c59b981a7710ef56f12994353d9df459fc59a882 100644
--- a/base/android/jni_android.cc
+++ b/base/android/jni_android.cc
@@ -4,6 +4,7 @@
#include "base/android/jni_android.h"
+#include "base/android/scoped_java_ref.h"
#include "base/logging.h"
namespace {
@@ -17,7 +18,6 @@ namespace android {
JNIEnv* AttachCurrentThread() {
if (!g_jvm)
return NULL;
-
JNIEnv* env = NULL;
jint ret = g_jvm->AttachCurrentThread(&env, NULL);
DCHECK_EQ(ret, JNI_OK);
@@ -46,6 +46,12 @@ jobject GetApplicationContext() {
return g_application_context;
}
+MethodID::MethodID(JNIEnv* env, const char* class_name, const char* method,
+ const char* jni_signature) {
+ ScopedJavaLocalRef<jclass> clazz(env, env->FindClass(class_name));
+ id_ = GetMethodID(env, clazz.obj(), method, jni_signature);
+}
+
jmethodID GetMethodID(JNIEnv* env,
jclass clazz,
const char* const method,
@@ -66,6 +72,16 @@ jmethodID GetStaticMethodID(JNIEnv* env,
return id;
}
+jfieldID GetFieldID(JNIEnv* env,
+ jclass clazz,
+ const char* field,
+ const char* jni_signature) {
+ jfieldID id = env->GetFieldID(clazz, field, jni_signature);
+ DCHECK(id) << field;
+ CheckException(env);
+ return id;
+}
+
bool CheckException(JNIEnv* env) {
if (env->ExceptionCheck() == JNI_FALSE)
return false;
« no previous file with comments | « base/android/jni_android.h ('k') | content/browser/renderer_host/java/java_bound_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698