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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 690553002: aw: Destroy ContentViewCore and WebContents together (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use Handler Created 6 years, 2 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: android_webview/java/src/org/chromium/android_webview/AwContents.java
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 cb996fa2002677f431d198bf7989e9a65589d556..6150908b5702cde4a29832622275b92fe64aa617 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -20,6 +20,7 @@ import android.net.http.SslCertificate;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
+import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
@@ -177,6 +178,7 @@ public class AwContents {
}
}
+ private final Handler mHandler;
private long mNativeAwContents;
private final AwBrowserContext mBrowserContext;
private ViewGroup mContainerView;
@@ -567,6 +569,7 @@ public class AwContents {
InternalAccessDelegate internalAccessAdapter, NativeGLDelegate nativeGLDelegate,
AwContentsClient contentsClient, AwSettings settings,
DependencyFactory dependencyFactory) {
+ mHandler = new Handler();
benm (inactive) 2014/10/31 13:53:29 does this need to be a member? destroy should come
boliu 2014/10/31 23:15:24 I wasn't concerned about threading issues as much
mBrowserContext = browserContext;
mContainerView = containerView;
mContext = context;
@@ -878,8 +881,19 @@ public class AwContents {
* Destroys this object and deletes its native counterpart.
*/
public void destroy() {
+ if (isDestroyed()) return;
+ // If we are attached, we have to call native detach to clean up
+ // hardware resources.
+ if (mIsAttachedToWindow) {
+ nativeOnDetachedFromWindow(mNativeAwContents);
+ }
mIsDestroyed = true;
- destroyNatives();
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ destroyNatives();
+ }
+ });
}
/**
@@ -888,11 +902,6 @@ public class AwContents {
private void destroyNatives() {
if (mCleanupReference != null) {
assert mNativeAwContents != 0;
- // If we are attached, we have to call native detach to clean up
- // hardware resources.
- if (mIsAttachedToWindow) {
- nativeOnDetachedFromWindow(mNativeAwContents);
- }
mWebContentsObserver.detachFromWebContents();
mWebContentsObserver = null;
@@ -913,12 +922,7 @@ public class AwContents {
}
private boolean isDestroyed() {
- if (mIsDestroyed) {
- assert mContentViewCore == null;
- assert mWebContents == null;
- assert mNavigationController == null;
- assert mNativeAwContents == 0;
- } else {
+ if (!mIsDestroyed) {
assert mContentViewCore != null;
assert mWebContents != null;
assert mNavigationController != null;

Powered by Google App Engine
This is Rietveld 408576698