| Index: android_webview/native/aw_contents.cc
|
| diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc
|
| index f949da08442c00b993d22b23376396b90c8c73fb..ccb0c521307edb8e797dddd70f40a15e8dd433b1 100644
|
| --- a/android_webview/native/aw_contents.cc
|
| +++ b/android_webview/native/aw_contents.cc
|
| @@ -189,7 +189,6 @@ AwContents::AwContents(scoped_ptr<WebContents> web_contents)
|
| new AwContentsUserData(this));
|
| render_view_host_ext_.reset(
|
| new AwRenderViewHostExt(this, web_contents_.get()));
|
| - AwContentsIoThreadClientImpl::RegisterPendingContents(web_contents_.get());
|
|
|
| AwAutofillManagerDelegate* autofill_manager_delegate =
|
| AwAutofillManagerDelegate::FromWebContents(web_contents_.get());
|
| @@ -222,14 +221,16 @@ void AwContents::SetJavaPeers(JNIEnv* env,
|
|
|
| AwContentsIoThreadClientImpl::Associate(
|
| web_contents_.get(), ScopedJavaLocalRef<jobject>(env, io_thread_client));
|
| - int child_id = web_contents_->GetRenderProcessHost()->GetID();
|
| - int route_id = web_contents_->GetRoutingID();
|
| - AwResourceDispatcherHostDelegate::OnIoThreadClientReady(child_id, route_id);
|
|
|
| InterceptNavigationDelegate::Associate(
|
| web_contents_.get(),
|
| make_scoped_ptr(new InterceptNavigationDelegate(
|
| env, intercept_navigation_delegate)));
|
| +
|
| + // Finally, having setup the associations, release any deferred requests
|
| + int child_id = web_contents_->GetRenderProcessHost()->GetID();
|
| + int route_id = web_contents_->GetRoutingID();
|
| + AwResourceDispatcherHostDelegate::OnIoThreadClientReady(child_id, route_id);
|
| }
|
|
|
| void AwContents::SetSaveFormData(bool enabled) {
|
| @@ -300,6 +301,13 @@ AwContents::~AwContents() {
|
| if (icon_helper_.get())
|
| icon_helper_->SetListener(NULL);
|
| base::subtle::NoBarrier_AtomicIncrement(&g_instance_count, -1);
|
| + // When the last WebView is destroyed free all discardable memory allocated by
|
| + // Chromium, because the app process may continue to run for a long time
|
| + // without ever using another WebView.
|
| + if (base::subtle::NoBarrier_Load(&g_instance_count) == 0) {
|
| + base::MemoryPressureListener::NotifyMemoryPressure(
|
| + base::MemoryPressureListener::MEMORY_PRESSURE_CRITICAL);
|
| + }
|
| }
|
|
|
| jint AwContents::GetWebContents(JNIEnv* env, jobject obj) {
|
| @@ -309,16 +317,11 @@ jint AwContents::GetWebContents(JNIEnv* env, jobject obj) {
|
| }
|
|
|
| void AwContents::Destroy(JNIEnv* env, jobject obj) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - delete this;
|
| -
|
| - // When the last WebView is destroyed free all discardable memory allocated by
|
| - // Chromium, because the app process may continue to run for a long time
|
| - // without ever using another WebView.
|
| - if (base::subtle::NoBarrier_Load(&g_instance_count) == 0) {
|
| - base::MemoryPressureListener::NotifyMemoryPressure(
|
| - base::MemoryPressureListener::MEMORY_PRESSURE_CRITICAL);
|
| - }
|
| + java_ref_.reset();
|
| + // We do not delete AwContents immediately. Some applications try to delete
|
| + // Webview in ShouldOverrideUrlLoading callback, which is a sync IPC from
|
| + // Webkit.
|
| + BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, this);
|
| }
|
|
|
| static jlong Init(JNIEnv* env, jclass, jobject browser_context) {
|
|
|