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

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

Issue 2235123002: Stop ShouldServiceRequest from running callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b7adcbfb30dc89e2a831a099ee5d80cb272a72ed..d58ecfaa309aacbc05ef3cac77f1aa4135d4f694 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -1318,25 +1318,40 @@ void ResourceDispatcherHostImpl::BeginRequest(
net::HttpRequestHeaders headers;
headers.AddHeadersFromString(request_data.headers);
- BeginRequestStatus begin_request_status = CONTINUE;
- OnHeaderProcessedCallback callback;
- if (!is_shutdown_) {
- callback =
- base::Bind(&ResourceDispatcherHostImpl::ContinuePendingBeginRequest,
- base::Unretained(this), request_id, request_data,
- sync_result, route_id, headers);
- begin_request_status =
- ShouldServiceRequest(process_type, child_id, request_data, headers,
- filter_, resource_context, callback);
- } else {
- begin_request_status = ABORT;
- }
- if (begin_request_status == ABORT) {
+ if (is_shutdown_ ||
+ !ShouldServiceRequest(process_type, child_id, request_data, headers,
+ filter_, resource_context)) {
AbortRequestBeforeItStarts(filter_, sync_result, request_id);
return;
- } else if (begin_request_status == CONTINUE) {
- callback.Run(true, 0);
}
+ // Check if we have a registered interceptor for the headers passed in. If
+ // yes then we need to mark the current request as pending and wait for the
+ // interceptor to invoke the callback with a status code indicating whether
+ // the request needs to be aborted or continued.
+ for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) {
+ HeaderInterceptorMap::iterator index =
+ http_header_interceptor_map_.find(it.name());
+ if (index != http_header_interceptor_map_.end()) {
+ HeaderInterceptorInfo& interceptor_info = index->second;
+
+ bool call_interceptor = true;
+ if (!interceptor_info.starts_with.empty()) {
+ call_interceptor =
+ base::StartsWith(it.value(), interceptor_info.starts_with,
+ base::CompareCase::INSENSITIVE_ASCII);
+ }
+ if (call_interceptor) {
+ interceptor_info.interceptor.Run(
+ it.name(), it.value(), child_id, resource_context,
+ base::Bind(&ResourceDispatcherHostImpl::ContinuePendingBeginRequest,
+ base::Unretained(this), request_id, request_data,
+ sync_result, route_id, headers));
+ return;
+ }
+ }
+ }
+ ContinuePendingBeginRequest(request_id, request_data, sync_result, route_id,
+ headers, true, 0);
}
void ResourceDispatcherHostImpl::ContinuePendingBeginRequest(
@@ -2608,15 +2623,13 @@ CertStore* ResourceDispatcherHostImpl::GetCertStore() {
: CertStore::GetInstance();
}
-ResourceDispatcherHostImpl::BeginRequestStatus
-ResourceDispatcherHostImpl::ShouldServiceRequest(
+bool ResourceDispatcherHostImpl::ShouldServiceRequest(
int process_type,
int child_id,
const ResourceRequest& request_data,
const net::HttpRequestHeaders& headers,
ResourceMessageFilter* filter,
- ResourceContext* resource_context,
- OnHeaderProcessedCallback callback) {
+ ResourceContext* resource_context) {
ChildProcessSecurityPolicyImpl* policy =
ChildProcessSecurityPolicyImpl::GetInstance();
@@ -2624,7 +2637,7 @@ ResourceDispatcherHostImpl::ShouldServiceRequest(
if (!policy->CanRequestURL(child_id, request_data.url)) {
VLOG(1) << "Denied unauthorized request for "
<< request_data.url.possibly_invalid_spec();
- return ABORT;
+ return false;
}
// Check if the renderer is using an illegal Origin header. If so, kill it.
@@ -2636,7 +2649,7 @@ ResourceDispatcherHostImpl::ShouldServiceRequest(
if (!policy->CanCommitURL(child_id, origin)) {
VLOG(1) << "Killed renderer for illegal origin: " << origin_string;
bad_message::ReceivedBadMessage(filter, bad_message::RDH_ILLEGAL_ORIGIN);
- return ABORT;
+ return false;
}
}
@@ -2650,7 +2663,7 @@ ResourceDispatcherHostImpl::ShouldServiceRequest(
!policy->CanReadFile(child_id, iter->path())) {
NOTREACHED() << "Denied unauthorized upload of "
<< iter->path().value();
- return ABORT;
+ return false;
}
if (iter->type() ==
ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM) {
@@ -2659,36 +2672,12 @@ ResourceDispatcherHostImpl::ShouldServiceRequest(
if (!policy->CanReadFileSystemFile(child_id, url)) {
NOTREACHED() << "Denied unauthorized upload of "
<< iter->filesystem_url().spec();
- return ABORT;
+ return false;
}
}
}
}
-
- // Check if we have a registered interceptor for the headers passed in. If
- // yes then we need to mark the current request as pending and wait for the
- // interceptor to invoke the |callback| with a status code indicating whether
- // the request needs to be aborted or continued.
- for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) {
- HeaderInterceptorMap::iterator index =
- http_header_interceptor_map_.find(it.name());
- if (index != http_header_interceptor_map_.end()) {
- HeaderInterceptorInfo& interceptor_info = index->second;
-
- bool call_interceptor = true;
- if (!interceptor_info.starts_with.empty()) {
- call_interceptor =
- base::StartsWith(it.value(), interceptor_info.starts_with,
- base::CompareCase::INSENSITIVE_ASCII);
- }
- if (call_interceptor) {
- interceptor_info.interceptor.Run(it.name(), it.value(), child_id,
- resource_context, callback);
- return PENDING;
- }
- }
- }
- return CONTINUE;
+ return true;
}
} // namespace content
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698