summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortobiasjs <tobiasjs@chromium.org>2016-03-17 02:43:40 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-17 09:44:44 +0000
commit81a813fcee09c1ed0f299aba3b589e3705238875 (patch)
tree16dce1aa0a0df4b58cc0694df723f2e0a187fa55
parent24eb1ea44b83c09bc3d6435073d692009b2fc6fb (diff)
downloadchromium_src-81a813fcee09c1ed0f299aba3b589e3705238875.zip
chromium_src-81a813fcee09c1ed0f299aba3b589e3705238875.tar.gz
chromium_src-81a813fcee09c1ed0f299aba3b589e3705238875.tar.bz2
Ensure that native WindowAndroid outlives native AwContents.
ContentViewCore holds a window pointer that is used during destruction of native AwContents to remove observers. However the current CleanupReference based finalization scheme does not enforce an ordering on the destruction of native WindowAndroid and AwContents instances. Satisfaction of the constraint that AwContents is destroyed before WindowAndroid is therefore dependent on the CleanupReference implementation, and possibly the implementation of the JVM as well. Making the AwContents DestroyRunnable strongly reference the associated WindowAndroidWrapper enforces the correct ordering. BUG=595336 Review URL: https://codereview.chromium.org/1809643002 Cr-Commit-Position: refs/heads/master@{#381675}
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContents.java8
1 files changed, 6 insertions, 2 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 7ec965f..046ccfc 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -316,9 +316,13 @@ public class AwContents implements SmartClipProvider,
private static final class DestroyRunnable implements Runnable {
private final long mNativeAwContents;
+ // Hold onto a reference to the window (via its wrapper), so that it is not destroyed
+ // until we are done here.
+ private final WindowAndroidWrapper mWindowAndroid;
- private DestroyRunnable(long nativeAwContents) {
+ private DestroyRunnable(long nativeAwContents, WindowAndroidWrapper windowAndroid) {
mNativeAwContents = nativeAwContents;
+ mWindowAndroid = windowAndroid;
}
@Override
public void run() {
@@ -991,7 +995,7 @@ public class AwContents implements SmartClipProvider,
// 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));
+ new CleanupReference(this, new DestroyRunnable(mNativeAwContents, mWindowAndroid));
}
private void installWebContentsObserver() {