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

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: Created a detached state. Data is sent to renderer until detached. Fixed up tests. 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
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

Powered by Google App Engine
This is Rietveld 408576698