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

Unified Diff: android/scoped_java_ref.h

Issue 2045303002: Update to Chromium //base at Chromium commit 3e81715e6d3a4324362635aea46ce1f1a163cca1. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/domokit/base@master
Patch Set: Created 4 years, 6 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 | « android/record_histogram.cc ('k') | android/scoped_java_ref.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
}
« no previous file with comments | « android/record_histogram.cc ('k') | android/scoped_java_ref.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698