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

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

Issue 2466843002: Cancel the request when URLLoader is gone (Closed)
Patch Set: fix Created 4 years, 1 month 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/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 6b3e7706856ae695d8ca4f5b78da5bc023248c94..3709943c1e1ffdd47c11040dd10576328fbd223c 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -1806,26 +1806,8 @@ bool ResourceDispatcherHostImpl::Send(IPC::Message* message) {
return false;
}
-// Note that this cancel is subtly different from the other
-// CancelRequest methods in this file, which also tear down the loader.
void ResourceDispatcherHostImpl::OnCancelRequest(int request_id) {
- int child_id = filter_->child_id();
-
- // When the old renderer dies, it sends a message to us to cancel its
- // requests.
- if (IsTransferredNavigation(GlobalRequestID(child_id, request_id)))
- return;
-
- ResourceLoader* loader = GetLoader(child_id, request_id);
-
- // It is possible that the request has been completed and removed from the
- // loader queue but the client has not processed the request completed message
- // before issuing a cancel. This happens frequently for beacons which are
- // canceled in the response received handler.
- if (!loader)
- return;
-
- loader->CancelRequest(true);
+ CancelRequestFromRenderer(GlobalRequestID(filter_->child_id(), request_id));
}
ResourceRequestInfoImpl* ResourceDispatcherHostImpl::CreateRequestInfo(
@@ -2454,6 +2436,25 @@ int ResourceDispatcherHostImpl::MakeRequestID() {
return --request_id_;
}
+void ResourceDispatcherHostImpl::CancelRequestFromRenderer(
+ GlobalRequestID request_id) {
+ // When the old renderer dies, it sends a message to us to cancel its
+ // requests.
+ if (IsTransferredNavigation(request_id))
+ return;
+
+ ResourceLoader* loader = GetLoader(request_id);
+
+ // It is possible that the request has been completed and removed from the
+ // loader queue but the client has not processed the request completed message
+ // before issuing a cancel. This happens frequently for beacons which are
+ // canceled in the response received handler.
+ if (!loader)
+ return;
+
+ loader->CancelRequest(true);
+}
+
void ResourceDispatcherHostImpl::StartLoading(
ResourceRequestInfoImpl* info,
std::unique_ptr<ResourceLoader> loader) {
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/loader/url_loader_factory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698