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

Unified Diff: content/browser/loader/async_resource_handler.cc

Issue 25772002: Allows prefetch requests to live beyond the renderer by delaying (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 7 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
« no previous file with comments | « no previous file | content/browser/loader/resource_dispatcher_host_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b9729f3d9aabcd95e9c01613bd06cce41c8e72bf..2e7cca55b2e7fc7bf03089e69b1b17245dff7212 100644
--- a/content/browser/loader/async_resource_handler.cc
+++ b/content/browser/loader/async_resource_handler.cc
@@ -135,10 +135,11 @@ void AsyncResourceHandler::OnDataReceivedACK(int request_id) {
bool AsyncResourceHandler::OnUploadProgress(int request_id,
uint64 position,
uint64 size) {
- ResourceMessageFilter* filter = GetFilter();
- if (!filter)
- return false;
- return filter->Send(
+ const ResourceRequestInfoImpl* info = GetRequestInfo();
+ // Cancel the request if the renderer is gone unless it's detachable.
+ if (!info->filter())
+ return info->is_detached();
+ return info->filter()->Send(
new ResourceMsg_UploadProgress(request_id, position, size));
}
@@ -147,8 +148,9 @@ bool AsyncResourceHandler::OnRequestRedirected(int request_id,
ResourceResponse* response,
bool* defer) {
const ResourceRequestInfoImpl* info = GetRequestInfo();
+ // 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;
@@ -172,10 +174,11 @@ bool AsyncResourceHandler::OnResponseStarted(int request_id,
// renderer will be able to set these precisely at the time the
// request commits, avoiding the possibility of e.g. zooming the old content
// or of having to layout the new content twice.
-
const ResourceRequestInfoImpl* info = GetRequestInfo();
+
+ // 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(
@@ -248,9 +251,19 @@ bool AsyncResourceHandler::OnReadCompleted(int request_id, int bytes_read,
if (!bytes_read)
return true;
+ const ResourceRequestInfoImpl* info = GetRequestInfo();
+ // Don't send any data if the resource is detached from the renderer.
+ if (info->is_detached()) {
+ buffer_->RecycleLeastRecentlyAllocated();
+ return true;
+ }
+
ResourceMessageFilter* filter = GetFilter();
- if (!filter)
+ // Cancel the request if the renderer is gone.
+ if (!filter) {
+ DCHECK(!info->is_detachable());
return false;
+ }
buffer_->ShrinkLastAllocation(bytes_read);
@@ -309,8 +322,10 @@ bool AsyncResourceHandler::OnResponseCompleted(
const net::URLRequestStatus& status,
const std::string& security_info) {
const ResourceRequestInfoImpl* info = GetRequestInfo();
+
+ // 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
« no previous file with comments | « no previous file | content/browser/loader/resource_dispatcher_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698