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

Unified Diff: Source/core/loader/DocumentThreadableLoader.cpp

Issue 538473002: DevTools: NetworkPanel: headers missing for cors-cancelled requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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 | « Source/core/loader/DocumentThreadableLoader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/loader/DocumentThreadableLoader.cpp
diff --git a/Source/core/loader/DocumentThreadableLoader.cpp b/Source/core/loader/DocumentThreadableLoader.cpp
index 19f8effdff8c540e374f6996f4e4371a7a7858cd..e44cdc440077adbe04b84766eeccfd586c95fb34 100644
--- a/Source/core/loader/DocumentThreadableLoader.cpp
+++ b/Source/core/loader/DocumentThreadableLoader.cpp
@@ -317,20 +317,8 @@ void DocumentThreadableLoader::responseReceived(Resource* resource, const Resour
handleResponse(resource->identifier(), response);
}
-void DocumentThreadableLoader::handlePreflightResponse(unsigned long identifier, const ResourceResponse& response)
+void DocumentThreadableLoader::handlePreflightResponse(const ResourceResponse& response)
{
- // Notifying the inspector here is necessary because a call to handlePreflightFailure() might synchronously
- // cause the underlying ResourceLoader to be cancelled before it tells the inspector about the response.
- // In that case, if we don't tell the inspector about the response now, the resource type in the inspector
- // will default to "other" instead of something more descriptive.
- DocumentLoader* loader = m_document.frame()->loader().documentLoader();
- TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ResourceReceiveResponse", "data", InspectorReceiveResponseEvent::data(identifier, m_document.frame(), response));
- // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeline migrates to tracing.
- LocalFrame* frame = m_document.frame();
- InspectorInstrumentation::didReceiveResourceResponse(frame, identifier, loader, response, resource() ? resource()->loader() : 0);
- // It is essential that inspector gets resource response BEFORE console.
- frame->console().reportResourceResponseReceived(loader, identifier, response);
-
String accessControlErrorDescription;
if (!passesAccessControlCheck(response, effectiveAllowCredentials(), securityOrigin(), accessControlErrorDescription)) {
@@ -354,12 +342,23 @@ void DocumentThreadableLoader::handlePreflightResponse(unsigned long identifier,
CrossOriginPreflightResultCache::shared().appendEntry(securityOrigin()->toString(), m_actualRequest->url(), preflightResult.release());
}
+void DocumentThreadableLoader::notifyResponseReceived(unsigned long identifier, const ResourceResponse& response)
+{
+ DocumentLoader* loader = m_document.frame()->loader().documentLoader();
+ TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "ResourceReceiveResponse", "data", InspectorReceiveResponseEvent::data(identifier, m_document.frame(), response));
+ LocalFrame* frame = m_document.frame();
+ InspectorInstrumentation::didReceiveResourceResponse(frame, identifier, loader, response, resource() ? resource()->loader() : 0);
+ // It is essential that inspector gets resource response BEFORE console.
+ frame->console().reportResourceResponseReceived(loader, identifier, response);
+}
+
void DocumentThreadableLoader::handleResponse(unsigned long identifier, const ResourceResponse& response)
{
ASSERT(m_client);
if (m_actualRequest) {
- handlePreflightResponse(identifier, response);
+ notifyResponseReceived(identifier, response);
+ handlePreflightResponse(response);
return;
}
@@ -367,11 +366,13 @@ void DocumentThreadableLoader::handleResponse(unsigned long identifier, const Re
bool isCrossOriginResponse = false;
if (response.wasFetchedViaServiceWorker()) {
if (!isAllowedByPolicy(response.url())) {
+ notifyResponseReceived(identifier, response);
m_client->didFailRedirectCheck();
return;
}
isCrossOriginResponse = !securityOrigin()->canRequest(response.url());
if (m_options.crossOriginRequestPolicy == DenyCrossOriginRequests && isCrossOriginResponse) {
+ notifyResponseReceived(identifier, response);
m_client->didFail(ResourceError(errorDomainBlinkInternal, 0, response.url().string(), "Cross origin requests are not supported."));
return;
}
@@ -386,6 +387,7 @@ void DocumentThreadableLoader::handleResponse(unsigned long identifier, const Re
if (isCrossOriginResponse && m_options.crossOriginRequestPolicy == UseAccessControl) {
String accessControlErrorDescription;
if (!passesAccessControlCheck(response, effectiveAllowCredentials(), securityOrigin(), accessControlErrorDescription)) {
+ notifyResponseReceived(identifier, response);
m_client->didFailAccessControlCheck(ResourceError(errorDomainBlinkInternal, 0, response.url().string(), accessControlErrorDescription));
return;
}
« no previous file with comments | « Source/core/loader/DocumentThreadableLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698