summaryrefslogtreecommitdiffstats
path: root/android_webview
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 18:06:24 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 18:06:24 +0000
commit6270ac9740f599ecf63fd4ebb6c9dd1ed619fcfc (patch)
tree6d3f29f70be4732e4f0e803ccca71d809d81e411 /android_webview
parent462c09ecd24bcd00655a9c8e95b263563d8be2a3 (diff)
downloadchromium_src-6270ac9740f599ecf63fd4ebb6c9dd1ed619fcfc.zip
chromium_src-6270ac9740f599ecf63fd4ebb6c9dd1ed619fcfc.tar.gz
chromium_src-6270ac9740f599ecf63fd4ebb6c9dd1ed619fcfc.tar.bz2
Make AwContents.destroy() idempotent
Follow-up to crrev.com/206516 As mCleanupReference is nulled out in destroy() it now must be null-checked to allow repeat calls to destroy(). BUG= Review URL: https://chromiumcodereview.appspot.com/17301002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207035 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContents.java2
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java22
2 files changed, 13 insertions, 11 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 49fb2d0..8cd9520 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -462,7 +462,7 @@ public class AwContents {
// methods are called on it after it's been destroyed, and other
// code relies on AwContents.mContentViewCore to be non-null.
- mCleanupReference.cleanupNow();
+ if (mCleanupReference != null) mCleanupReference.cleanupNow();
mNativeAwContents = 0;
mCleanupReference = null;
}
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
index 7b29de8..30cfc0c 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
@@ -111,6 +111,18 @@ public class AwContentsTest extends AwTestBase {
createAwTestContainerView(mContentsClient).getAwContents().destroy();
}
+ @SmallTest
+ @Feature({"AndroidWebView"})
+ public void testCreateLoadPageDestroy() throws Throwable {
+ AwTestContainerView awTestContainerView =
+ createAwTestContainerViewOnMainSync(mContentsClient);
+ loadUrlSync(awTestContainerView.getAwContents(),
+ mContentsClient.getOnPageFinishedHelper(), CommonResources.ABOUT_HTML);
+ destroyAwContentsOnMainSync(awTestContainerView.getAwContents());
+ // It should be safe to call destroy multiple times.
+ destroyAwContentsOnMainSync(awTestContainerView.getAwContents());
+ }
+
/*
* @LargeTest
* @Feature({"AndroidWebView"})
@@ -347,14 +359,4 @@ public class AwContentsTest extends AwTestBase {
if (webServer != null) webServer.shutdown();
}
}
-
- @SmallTest
- @Feature({"AndroidWebView"})
- public void testCreateLoadPageDestroy() throws Throwable {
- AwTestContainerView awTestContainerView =
- createAwTestContainerViewOnMainSync(mContentsClient);
- loadUrlSync(awTestContainerView.getAwContents(),
- mContentsClient.getOnPageFinishedHelper(), CommonResources.ABOUT_HTML);
- awTestContainerView.destroy();
- }
}