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

Unified Diff: base/android/jni_android.h

Issue 8769005: Don't use Singleton to cache JNI method IDs in Java Bridge (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename test file, fix comments Created 9 years 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 | « no previous file | base/android/jni_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/jni_android.h
diff --git a/base/android/jni_android.h b/base/android/jni_android.h
index 462173f85d38cf48b62e466ebeb97e1b0a6ea006..08e4b6dc96dec4a45479305c92a5e82005967c31 100644
--- a/base/android/jni_android.h
+++ b/base/android/jni_android.h
@@ -30,19 +30,17 @@ void InitApplicationContext(jobject context);
// Returns the application context assigned by InitApplicationContext().
jobject GetApplicationContext();
-// Wraps a method ID.
-class MethodID {
- public:
- jmethodID id() { return id_; }
- protected:
- // Gets the method ID from the class name. Clears the pending Java exception
- // and returns NULL if the method is not found. Note that GetMethodID() below
- // avoids a class lookup, so should be used in preference when possible.
- MethodID(JNIEnv* env, const char* class_name, const char* method,
- const char* jni_signature);
- private:
- jmethodID id_;
-};
+// Gets the method ID from the class name. Clears the pending Java exception
+// and returns NULL if the method is not found. Caches results. Note that
+// GetMethodID() below avoids a class lookup, but does not cache results.
+// Strings passed to this function are held in the cache and MUST remain valid
+// beyond the duration of all future calls to this function, across all
+// threads. In practice, this means that the function should only be used with
+// string constants.
+jmethodID GetMethodIDFromClassName(JNIEnv* env,
+ const char* class_name,
+ const char* method,
+ const char* jni_signature);
// Get the method ID for a method. Will clear the pending Java
// exception and return 0 if the method is not found.
« no previous file with comments | « no previous file | base/android/jni_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698