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; |
} |