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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentSettings.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
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/ContentSettings.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentSettings.java b/content/public/android/java/src/org/chromium/content/browser/ContentSettings.java
index 0a14cb4139b5c2dd693a804c4bfe1281a2a3b5c4..6ab2feef89acf3bd0e76c78326922f32ee1d17db 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentSettings.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentSettings.java
@@ -12,6 +12,7 @@ import android.webkit.WebView;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.base.ThreadUtils;
+import org.chromium.content.common.CleanupReference;
/**
* Manages settings state for a ContentView. A ContentSettings instance is obtained
@@ -31,6 +32,19 @@ public class ContentSettings {
private ContentViewCore mContentViewCore;
+ private static final class DestroyRunnable implements Runnable {
+ private int mNativeContentSettings;
+ private DestroyRunnable(int nativeContentSettings) {
+ mNativeContentSettings = nativeContentSettings;
+ }
+ @Override
+ public void run() {
+ nativeDestroy(mNativeContentSettings);
+ }
+ }
+
+ private final CleanupReference mCleanupReference;
+
// When ContentView is used in PERSONALITY_CHROME mode, settings can't
// be modified through the ContentSettings instance.
private boolean mCanModifySettings;
@@ -147,6 +161,8 @@ public class ContentSettings {
mCanModifySettings = mContentViewCore.isPersonalityView();
mNativeContentSettings = nativeInit(nativeContentView, mCanModifySettings);
assert mNativeContentSettings != 0;
+ mCleanupReference = new CleanupReference(this,
+ new DestroyRunnable(mNativeContentSettings));
mEventHandler = new EventHandler();
if (mCanModifySettings) {
@@ -170,7 +186,7 @@ public class ContentSettings {
* when related ContentView is destroyed.
*/
void destroy() {
- nativeDestroy(mNativeContentSettings);
+ mCleanupReference.cleanupNow();
mNativeContentSettings = 0;
}
@@ -691,7 +707,7 @@ public class ContentSettings {
// Initialize the ContentSettings native side.
private native int nativeInit(int contentViewPtr, boolean isMasterMode);
- private native void nativeDestroy(int nativeContentSettings);
+ private static native void nativeDestroy(int nativeContentSettings);
private static native String nativeGetDefaultUserAgent();
« no previous file with comments | « no previous file | content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698