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

Unified Diff: base/android/scoped_java_ref.h

Issue 9358028: Upstream Android JNI code, allowing us to use more ScopedJava references. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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
Index: base/android/scoped_java_ref.h
diff --git a/base/android/scoped_java_ref.h b/base/android/scoped_java_ref.h
index a74cef7687f29ef350c564662b556ce0dc5b80ee..52899810e0ede5195b1f1ee7d0b5bdab03debd26 100644
--- a/base/android/scoped_java_ref.h
+++ b/base/android/scoped_java_ref.h
@@ -8,7 +8,7 @@
#include <jni.h>
#include <stddef.h>
-#include "base/logging.h"
+#include "base/basictypes.h"
namespace base {
namespace android {
@@ -25,6 +25,8 @@ class JavaRef<jobject> {
JNIEnv* env() const { return env_; }
jobject obj() const { return obj_; }
+ bool is_null() const { return obj_ == NULL; }
+
protected:
// Initializes a NULL reference.
JavaRef();
@@ -39,6 +41,8 @@ class JavaRef<jobject> {
// use by the sub-classes.
void SetNewLocalRef(JNIEnv* env, jobject obj);
void SetNewGlobalRef(JNIEnv* env, jobject obj);
+ void ResetLocalRef();
+ void ResetGlobalRef();
jobject ReleaseInternal();
private:
@@ -104,7 +108,7 @@ class ScopedJavaLocalRef : public JavaRef<T> {
}
void Reset() {
- this->SetNewLocalRef(NULL, NULL);
+ this->ResetLocalRef();
}
template<typename U>
@@ -148,7 +152,7 @@ class ScopedJavaGlobalRef : public JavaRef<T> {
}
void Reset() {
- this->SetNewGlobalRef(NULL, NULL);
+ this->ResetGlobalRef();
}
template<typename U>

Powered by Google App Engine
This is Rietveld 408576698