diff options
author | boliu <boliu@chromium.org> | 2015-03-25 07:49:10 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-25 14:49:45 +0000 |
commit | f1c913e8c18946c07d1a64f118b2d36e1bbe170f (patch) | |
tree | 1784e2cde81864b67a3cb52ec53e0cb549418688 /android_webview | |
parent | 01af0d183734ce7a0a39d489289df1c2d1be8ef8 (diff) | |
download | chromium_src-f1c913e8c18946c07d1a64f118b2d36e1bbe170f.zip chromium_src-f1c913e8c18946c07d1a64f118b2d36e1bbe170f.tar.gz chromium_src-f1c913e8c18946c07d1a64f118b2d36e1bbe170f.tar.bz2 |
Fix WindowAndroid leak in Android WebView
WebView creates a WindowAndroid class per AwContents, but never calls
destroy on it, so the native WindowAndroid leaks. Do this in
CleanupReference of AwContents.
Also make native WindowAndroid hold a strong reference, so removes
the requirement to null check the ref, which are mostly missing anyway.
Notes:
* This adds the requirement that WindowAndroid cannot hold strong ref
that would prevent AwContents/ContentViewCore from being gc-ed,
which currently is the case.
* This does not address the issue that WindowAndroid should be
per-activity, not per ContentViewCore.
BUG=469803
Review URL: https://codereview.chromium.org/1034593002
Cr-Commit-Position: refs/heads/master@{#322159}
Diffstat (limited to 'android_webview')
-rw-r--r-- | android_webview/java/src/org/chromium/android_webview/AwContents.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java index 0f8974a..40a277d 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java @@ -286,12 +286,16 @@ public class AwContents implements SmartClipProvider, private static final class DestroyRunnable implements Runnable { private final long mNativeAwContents; - private DestroyRunnable(long nativeAwContents) { + private final WindowAndroid mWindowAndroid; + + private DestroyRunnable(long nativeAwContents, WindowAndroid windowAndroid) { mNativeAwContents = nativeAwContents; + mWindowAndroid = windowAndroid; } @Override public void run() { nativeDestroy(mNativeAwContents); + mWindowAndroid.destroy(); } } @@ -863,10 +867,6 @@ public class AwContents implements SmartClipProvider, // each other, we should update |mBrowserContext| according to the newly received native // WebContent's browser context. - // The native side object has been bound to this java instance, so now is the time to - // bind all the native->java relationships. - mCleanupReference = new CleanupReference(this, new DestroyRunnable(mNativeAwContents)); - WebContents webContents = nativeGetWebContents(mNativeAwContents); Activity activity = ContentViewCore.activityFromContext(mContext); @@ -884,6 +884,11 @@ public class AwContents implements SmartClipProvider, mSettings.setWebContents(webContents); nativeSetDipScale(mNativeAwContents, (float) mDIPScale); mContentViewCore.onShow(); + + // The native side object has been bound to this java instance, so now is the time to + // bind all the native->java relationships. + mCleanupReference = + new CleanupReference(this, new DestroyRunnable(mNativeAwContents, mWindowAndroid)); } private void installWebContentsObserver() { |