Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Add GetFieldID functing to jni_help in the content for XWalk.
Browse files Browse the repository at this point in the history
Introduced by src@225471
  • Loading branch information
junmin-zhu authored and Maksim Sisov committed Aug 16, 2016
1 parent 5260365 commit 4f969c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions content/browser/android/java/jni_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ base::LazyInstance<MethodIDMap> g_method_id_map = LAZY_INSTANCE_INITIALIZER;

} // namespace

jfieldID GetFieldID(JNIEnv* env,
const base::android::JavaRef<jclass>& clazz,
const char* field_name,
const char* jni_signature) {
jfieldID field_id = env->GetFieldID(clazz.obj(), field_name, jni_signature);
CHECK(!base::android::ClearException(env) && field_id) <<
"Failed to find field " << field_name << " " << jni_signature;
return field_id;
}

jmethodID GetMethodIDFromClassName(JNIEnv* env,
const char* class_name,
const char* method,
Expand Down
8 changes: 8 additions & 0 deletions content/browser/android/java/jni_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <jni.h>

#include "base/android/scoped_java_ref.h"
#include "content/common/content_export.h"

namespace content {
Expand All @@ -22,6 +23,13 @@ CONTENT_EXPORT jmethodID GetMethodIDFromClassName(JNIEnv* env,
const char* method,
const char* jni_signature);

// Gets the field ID for a class field.
// This method triggers a fatal assertion if the field could not be found.
CONTENT_EXPORT jfieldID GetFieldID(JNIEnv* env,
const base::android::JavaRef<jclass>& clazz,
const char* field_name,
const char* jni_signature);

} // namespace content

#endif // CONTENT_BROWSER_ANDROID_JAVA_JNI_HELPER_H_

0 comments on commit 4f969c0

Please sign in to comment.