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

Unified Diff: content/browser/renderer_host/java/java_bound_object.h

Issue 11802002: [Android] Fix leak in Java Bridge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: joth comments Created 7 years, 11 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 | content/browser/renderer_host/java/java_bound_object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/java/java_bound_object.h
diff --git a/content/browser/renderer_host/java/java_bound_object.h b/content/browser/renderer_host/java/java_bound_object.h
index c383f114362f5be393354ce1595172acf3ce4478..56cce29e52e612653ddaf77022511fb5619aa0b2 100644
--- a/content/browser/renderer_host/java/java_bound_object.h
+++ b/content/browser/renderer_host/java/java_bound_object.h
@@ -9,6 +9,7 @@
#include <map>
#include <string>
+#include "base/android/jni_helper.h"
#include "base/android/scoped_java_ref.h"
#include "base/memory/linked_ptr.h"
#include "content/browser/renderer_host/java/java_method.h"
@@ -37,10 +38,11 @@ class JavaBoundObject {
virtual ~JavaBoundObject();
- // Gets a global ref to the underlying JavaObject from a JavaBoundObject
- // wrapped as an NPObject. Ownership of the global ref is retained by the
- // JavaBoundObject: the caller must NOT release it.
- static jobject GetJavaObject(NPObject* object);
+ // Gets a local ref to the underlying JavaObject from a JavaBoundObject
+ // wrapped as an NPObject. May return null if the underlying object has
+ // been garbage collected.
+ static base::android::ScopedJavaLocalRef<jobject> GetJavaObject(
+ NPObject* object);
// Methods to implement the NPObject callbacks.
bool HasMethod(const std::string& name) const;
@@ -54,10 +56,9 @@ class JavaBoundObject {
void EnsureMethodsAreSetUp() const;
- // The global ref to the underlying Java object that this JavaBoundObject
+ // The weak ref to the underlying Java object that this JavaBoundObject
// instance represents.
- base::android::ScopedJavaGlobalRef<jobject> java_object_;
-
+ JavaObjectWeakGlobalRef java_object_;
// Map of public methods, from method name to Method instance. Multiple
// entries will be present for overloaded methods. Note that we can't use
// scoped_ptr in STL containers as we can't copy it.
« no previous file with comments | « no previous file | content/browser/renderer_host/java/java_bound_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698