Index: content/browser/loader/resource_dispatcher_host_impl.cc |
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc |
index 839678e30ce5cc01c6e57f60d725d6ef6e196d1b..5c8adb8ff00779097074643577020be8364fa1db 100644 |
--- a/content/browser/loader/resource_dispatcher_host_impl.cc |
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc |
@@ -32,6 +32,7 @@ |
#include "content/browser/fileapi/chrome_blob_storage_context.h" |
#include "content/browser/loader/async_resource_handler.h" |
#include "content/browser/loader/buffered_resource_handler.h" |
+#include "content/browser/loader/detached_resource_handler.h" |
#include "content/browser/loader/cross_site_resource_handler.h" |
#include "content/browser/loader/power_save_block_resource_throttle.h" |
#include "content/browser/loader/redirect_to_file_resource_handler.h" |
@@ -406,12 +407,14 @@ void ResourceDispatcherHostImpl::CancelRequestsForContext( |
for (LoaderList::iterator i = loaders_to_cancel.begin(); |
i != loaders_to_cancel.end(); ++i) { |
// There is no strict requirement that this be the case, but currently |
- // downloads, streams and transferred requests are the only requests that |
- // aren't cancelled when the associated processes go away. It may be OK for |
- // this invariant to change in the future, but if this assertion fires |
- // without the invariant changing, then it's indicative of a leak. |
+ // downloads, streams, prefetches, and transferred requests are the only |
+ // requests that aren't cancelled when the associated processes go away. It |
+ // may be OK for this invariant to change in the future, but if this |
+ // assertion fires without the invariant changing, then it's indicative of a |
+ // leak. |
DCHECK((*i)->GetRequestInfo()->is_download() || |
(*i)->GetRequestInfo()->is_stream() || |
+ DetachableType((*i)->GetRequestInfo()->GetResourceType()) || |
(*i)->is_transferring()); |
} |
#endif |
@@ -694,6 +697,12 @@ void ResourceDispatcherHostImpl::DidReceiveRedirect(ResourceLoader* loader, |
void ResourceDispatcherHostImpl::DidReceiveResponse(ResourceLoader* loader) { |
ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
+ |
+ // Exit early in case of detachable types as they may not have a policy after |
+ // the renderer is canceled. |
+ if (DetachableType(info->GetResourceType())) |
+ return; |
mmenke
2013/10/11 16:39:07
Should this only protect against messing with the
jkarlin2
2013/10/11 18:37:04
Done.
|
+ |
// There should be an entry in the map created when we dispatched the |
// request. |
OfflineMap::iterator policy_it( |
@@ -1099,6 +1108,9 @@ void ResourceDispatcherHostImpl::BeginRequest( |
scoped_ptr<ResourceHandler> handler; |
if (sync_result) { |
handler.reset(new SyncResourceHandler(request, sync_result, this)); |
+ } else if (DetachableType(request_data.resource_type)) { |
+ // put in detached handler |
+ handler.reset(new DetachedResourceHandler(request, this)); |
} else { |
handler.reset(new AsyncResourceHandler(request, this)); |
} |
@@ -1146,6 +1158,16 @@ void ResourceDispatcherHostImpl::BeginRequest( |
BeginRequestInternal(new_request.Pass(), handler.Pass()); |
} |
+bool ResourceDispatcherHostImpl::DetachableType( |
mmenke
2013/10/11 16:39:07
Suggest IsDetachableResouceType, or maybe IsResouc
mmenke
2013/10/11 16:39:07
Since this is only used in this file and doesn't d
jkarlin2
2013/10/11 18:37:04
Done.
jkarlin2
2013/10/11 18:37:04
Done.
|
+ const ResourceType::Type type) const { |
+ switch (type) { |
+ case ResourceType::PREFETCH: |
+ return true; |
+ default: |
+ return false; |
+ } |
+} |
+ |
void ResourceDispatcherHostImpl::OnReleaseDownloadedFile(int request_id) { |
UnregisterDownloadedTempFile(filter_->child_id(), request_id); |
} |
@@ -1315,8 +1337,8 @@ void ResourceDispatcherHostImpl::ResumeDeferredNavigation( |
} |
// The object died, so cancel and detach all requests associated with it except |
-// for downloads, which belong to the browser process even if initiated via a |
-// renderer. |
+// for downloads and prefetches, which belong to the browser process even if |
+// initiated via a renderer. |
void ResourceDispatcherHostImpl::CancelRequestsForProcess(int child_id) { |
CancelRequestsForRoute(child_id, -1 /* cancel all */); |
registered_temp_files_.erase(child_id); |
@@ -1341,12 +1363,11 @@ void ResourceDispatcherHostImpl::CancelRequestsForRoute(int child_id, |
GlobalRequestID id(child_id, i->first.request_id); |
DCHECK(id == i->first); |
- |
- // Don't cancel navigations that are transferring to another process, |
- // since they belong to another process now. |
+ // Don't cancel navigations that are expected to live beyond this process. |
if (IsTransferredNavigation(id)) |
any_requests_transferring = true; |
if (!info->is_download() && !info->is_stream() && |
+ !DetachableType(info->GetResourceType()) && |
!IsTransferredNavigation(id) && |
(route_id == -1 || route_id == info->GetRouteID())) { |
matching_requests.push_back(id); |