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

Unified Diff: base/android/scoped_java_ref.h

Issue 225283008: base: Add ScopedJavaLocalFrame class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing BASE_EXPORT Created 6 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 | « no previous file | base/android/scoped_java_ref.cc » ('j') | base/android/scoped_java_ref.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/scoped_java_ref.h
diff --git a/base/android/scoped_java_ref.h b/base/android/scoped_java_ref.h
index a5d71e2d23b9b8d7ad0447ed7c9c2b54e905c83b..08893006c1569e0f89d03ab5f631358986d92ad7 100644
--- a/base/android/scoped_java_ref.h
+++ b/base/android/scoped_java_ref.h
@@ -148,6 +148,23 @@ class ScopedJavaLocalRef : public JavaRef<T> {
JNIEnv* env_;
};
+// Creates a new local reference frame, in which at least a given number of
+// local references can be created. Note that local references already created
+// in previous local frames are still valid in the current local frame.
+class BASE_EXPORT ScopedJavaLocalFrame {
bulach 2014/04/07 15:51:29 nit: may I ask to move this one either as the firs
reveman 2014/04/07 17:38:29 Done.
+ public:
+ explicit ScopedJavaLocalFrame(JNIEnv* env);
+ ScopedJavaLocalFrame(JNIEnv* env, int capacity);
+ ~ScopedJavaLocalFrame();
+
+ private:
+ // This class is only good for use on the thread it was created on so
+ // it's safe to cache the non-threadsafe JNIEnv* inside this object.
+ JNIEnv* env_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedJavaLocalFrame);
+};
+
// Holds a global reference to a Java object. The global reference is scoped
// to the lifetime of this object. This class does not hold onto any JNIEnv*
// passed to it, hence it is safe to use across threads (within the constraints
« no previous file with comments | « no previous file | base/android/scoped_java_ref.cc » ('j') | base/android/scoped_java_ref.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698