Index: content/browser/loader/async_resource_handler.cc |
diff --git a/content/browser/loader/async_resource_handler.cc b/content/browser/loader/async_resource_handler.cc |
index f007a417fb8ffe997e20c439506d9f8a6834c367..34d77f24b290282920eddf3440bd0caa692718d4 100644 |
--- a/content/browser/loader/async_resource_handler.cc |
+++ b/content/browser/loader/async_resource_handler.cc |
@@ -137,8 +137,9 @@ bool AsyncResourceHandler::OnUploadProgress(int request_id, |
uint64 size) { |
const ResourceRequestInfoImpl* info = |
ResourceRequestInfoImpl::ForRequest(request_); |
+ // Cancel the request if the renderer is gone unless it's detachable. |
if (!info->filter()) |
- return false; |
+ return info->is_detached(); |
return info->filter()->Send( |
new ResourceMsg_UploadProgress(request_id, position, size)); |
} |
@@ -149,8 +150,9 @@ bool AsyncResourceHandler::OnRequestRedirected(int request_id, |
bool* defer) { |
const ResourceRequestInfoImpl* info = |
ResourceRequestInfoImpl::ForRequest(request_); |
+ // Cancel the request if the renderer is gone unless it's detached. |
if (!info->filter()) |
- return false; |
+ return info->is_detached(); |
*defer = did_defer_ = true; |
@@ -177,8 +179,9 @@ bool AsyncResourceHandler::OnResponseStarted(int request_id, |
const ResourceRequestInfoImpl* info = |
ResourceRequestInfoImpl::ForRequest(request_); |
+ // Cancel the request if the renderer is gone unless it's detachable. |
if (!info->filter()) |
- return false; |
+ return info->is_detached(); |
if (rdh_->delegate()) { |
rdh_->delegate()->OnResponseStarted( |
@@ -249,8 +252,18 @@ bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read, |
const ResourceRequestInfoImpl* info = |
ResourceRequestInfoImpl::ForRequest(request_); |
- if (!info->filter()) |
+ |
+ // Don't send any data if the resource is detached from the renderer. |
+ if (info->is_detached()) { |
+ buffer_->RecycleLeastRecentlyAllocated(); |
+ return true; |
+ } |
+ |
+ // Cancel the request if the renderer is gone. |
+ if (!info->filter()) { |
+ DCHECK(!info->is_detachable()); |
return false; |
+ } |
buffer_->ShrinkLastAllocation(bytes_read); |
@@ -311,8 +324,9 @@ bool AsyncResourceHandler::OnResponseCompleted( |
const std::string& security_info) { |
const ResourceRequestInfoImpl* info = |
ResourceRequestInfoImpl::ForRequest(request_); |
+ // Cancel the request if the renderer is gone unless it's detachable. |
if (!info->filter()) |
- return false; |
+ return info->is_detachable(); |
// If we crash here, figure out what URL the renderer was requesting. |
// http://crbug.com/107692 |