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

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: test to ShouldOverrideUrlLoading Created 6 years, 1 month 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 d2964150cc89a0fc601ddcbdaba3f4b4ce63e73e..37aad23306bdd6098201359fecfe1dfce0f1b772 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;
@@ -889,8 +890,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();
+ new Handler().post(new Runnable() {
+ @Override
+ public void run() {
+ destroyNatives();
+ }
+ });
}
/**
@@ -899,11 +911,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;
@@ -924,12 +931,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