Index: android/scoped_java_ref.h |
diff --git a/android/scoped_java_ref.h b/android/scoped_java_ref.h |
index 8047ee8c16725ab0470acc1b71dfb77f5594e439..37e7fd3507ca480ee29209df24d3e7e2cf2b7472 100644 |
--- a/android/scoped_java_ref.h |
+++ b/android/scoped_java_ref.h |
@@ -10,6 +10,7 @@ |
#include "base/base_export.h" |
#include "base/basictypes.h" |
+#include "base/logging.h" |
namespace base { |
namespace android { |
@@ -45,14 +46,21 @@ class BASE_EXPORT JavaRef<jobject> { |
bool is_null() const { return obj_ == NULL; } |
protected: |
- // Initializes a NULL reference. |
- JavaRef(); |
+ // Initializes a NULL reference. Don't add anything else here; it's inlined. |
+ JavaRef() : obj_(NULL) {} |
// Takes ownership of the |obj| reference passed; requires it to be a local |
// reference type. |
+#if DCHECK_IS_ON() |
+ // Implementation contains a DCHECK; implement out-of-line when DCHECK_IS_ON. |
JavaRef(JNIEnv* env, jobject obj); |
+#else |
+ // Don't add anything else here; it's inlined. |
+ JavaRef(JNIEnv* env, jobject obj) : obj_(obj) {} |
+#endif |
- ~JavaRef(); |
+ // Don't add anything else here; it's inlined. |
+ ~JavaRef() {} |
// The following are implementation detail convenience methods, for |
// use by the sub-classes. |
@@ -154,7 +162,8 @@ class ScopedJavaLocalRef : public JavaRef<T> { |
} |
// Releases the local reference to the caller. The caller *must* delete the |
- // local reference when it is done with it. |
+ // local reference when it is done with it. Note that calling a Java method |
+ // is *not* a transfer of ownership and Release() should not be used. |
T Release() { |
return static_cast<T>(this->ReleaseInternal()); |
} |
@@ -205,7 +214,8 @@ class ScopedJavaGlobalRef : public JavaRef<T> { |
} |
// Releases the global reference to the caller. The caller *must* delete the |
- // global reference when it is done with it. |
+ // global reference when it is done with it. Note that calling a Java method |
+ // is *not* a transfer of ownership and Release() should not be used. |
T Release() { |
return static_cast<T>(this->ReleaseInternal()); |
} |