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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 10846004: Upstream CleanupReference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit fixes Created 8 years, 5 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: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 6365569e2f3dbfa1bc62fec12aebfe06b3fcb947..06c035fdd36b83bdf2345152d36b4b7e43eaf8bc 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -22,6 +22,7 @@ import org.chromium.base.WeakContext;
import org.chromium.content.browser.ContentViewGestureHandler;
import org.chromium.content.browser.TouchPoint;
import org.chromium.content.browser.ZoomManager;
+import org.chromium.content.common.CleanupReference;
import org.chromium.content.common.TraceEvent;
import org.chromium.content.browser.ContentViewGestureHandler.MotionEventDelegate;
@@ -119,6 +120,19 @@ public class ContentViewCore implements MotionEventDelegate {
boolean super_awakenScrollBars(int startDelay, boolean invalidate);
}
+ private static final class DestroyRunnable implements Runnable {
+ private int mNativeContentViewCore;
+ private DestroyRunnable(int nativeContentViewCore) {
+ mNativeContentViewCore = nativeContentViewCore;
+ }
+ @Override
+ public void run() {
+ nativeDestroy(mNativeContentViewCore);
+ }
+ }
+
+ private CleanupReference mCleanupReference;
+
private Context mContext;
private ViewGroup mContainerView;
private InternalAccessDelegate mContainerViewInternals;
@@ -241,6 +255,7 @@ public class ContentViewCore implements MotionEventDelegate {
// TODO(jrg): incomplete; upstream the rest of this method.
private void initialize(Context context, int nativeWebContents, int personality) {
mNativeContentViewCore = nativeInit(nativeWebContents);
+ mCleanupReference = new CleanupReference(this, new DestroyRunnable(mNativeContentViewCore));
mPersonality = personality;
mContentSettings = new ContentSettings(this, mNativeContentViewCore);
@@ -282,14 +297,11 @@ public class ContentViewCore implements MotionEventDelegate {
*/
public void destroy() {
hidePopupDialog();
- if (mNativeContentViewCore != 0) {
- nativeDestroy(mNativeContentViewCore);
- mNativeContentViewCore = 0;
- }
- if (mContentSettings != null) {
- mContentSettings.destroy();
- mContentSettings = null;
- }
+ mCleanupReference.cleanupNow();
+ mNativeContentViewCore = 0;
+ // Do not propagate the destroy() to settings, as the client may still hold a reference to
+ // that and could still be using it.
+ mContentSettings = null;
}
/**
@@ -1013,7 +1025,7 @@ public class ContentViewCore implements MotionEventDelegate {
*/
private native int nativeInit(int webContentsPtr);
- private native void nativeDestroy(int nativeContentViewCoreImpl);
+ private static native void nativeDestroy(int nativeContentViewCoreImpl);
private native void nativeLoadUrlWithoutUrlSanitization(int nativeContentViewCoreImpl,
String url, int pageTransition);

Powered by Google App Engine
This is Rietveld 408576698