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

Unified Diff: third_party/WebKit/Source/core/fetch/ResourceLoader.cpp

Issue 1478103002: [WIP] [service worker] Fix detach controller and fallback to network mechanism (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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: third_party/WebKit/Source/core/fetch/ResourceLoader.cpp
diff --git a/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp b/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp
index 298d331b6ea6bdd11abe7e15130e9182471260ab..07ae611f8070b8522df548b7a989be2a323745a7 100644
--- a/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp
+++ b/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp
@@ -334,32 +334,39 @@ void ResourceLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& res
const ResourceResponse& resourceResponse = response.toResourceResponse();
TRACE_EVENT1("devtools.timeline", "ResourceReceiveResponse", "data", InspectorReceiveResponseEvent::data(m_resource->identifier(), resourceResponse));
- if (responseNeedsAccessControlCheck()) {
- if (response.wasFetchedViaServiceWorker()) {
- if (response.wasFallbackRequiredByServiceWorker()) {
+ if (response.wasFetchedViaServiceWorker()) {
+ if (response.wasFallbackRequiredByServiceWorker()) {
+ // Fallback can be required in two cases:
+ // 1) The SW let a cross-origin request fallback to network. In that
+ // case, retry the request without the SW if CORS was enabled;
+ // otherwise, fail the request as disallowed.
+ // 2) The browser failed to dispatch the main resource request to
+ // the SW. In that case, retry the request without the SW.
+ if (responseNeedsAccessControlCheck() || m_resource->type() == Resource::MainResource) {
m_loader->cancel();
m_loader.clear();
m_connectionState = ConnectionStateStarted;
m_loader = adoptPtr(Platform::current()->createURLLoader());
ASSERT(m_loader);
- ASSERT(!m_request.skipServiceWorker());
+ // skipServiceWorker can be true if this request was redirected.
+ // ASSERT(!m_request.skipServiceWorker());
falken 2015/11/26 10:36:42 This ASSERT is probably meaning to say "we must no
m_request.setSkipServiceWorker(true);
WrappedResourceRequest wrappedRequest(m_request);
m_loader->loadAsynchronously(wrappedRequest, this);
return;
}
- } else {
- // If the response successfully validated a cached resource, perform
- // the access control with respect to it. Need to do this right here
- // before the resource switches clients over to that validated resource.
- Resource* resource = m_resource;
- if (!resource->isCacheValidator() || resourceResponse.httpStatusCode() != 304)
- m_resource->setResponse(resourceResponse);
- if (!m_fetcher->canAccessResource(resource, m_options.securityOrigin.get(), response.url(), ResourceFetcher::ShouldLogAccessControlErrors)) {
- m_fetcher->didReceiveResponse(m_resource, resourceResponse);
- cancel(ResourceError::cancelledDueToAccessCheckError(KURL(response.url())));
- return;
- }
+ }
+ } else if (responseNeedsAccessControlCheck()) {
+ // If the response successfully validated a cached resource, perform
+ // the access control with respect to it. Need to do this right here
+ // before the resource switches clients over to that validated resource.
+ Resource* resource = m_resource;
+ if (!resource->isCacheValidator() || resourceResponse.httpStatusCode() != 304)
+ m_resource->setResponse(resourceResponse);
+ if (!m_fetcher->canAccessResource(resource, m_options.securityOrigin.get(), response.url(), ResourceFetcher::ShouldLogAccessControlErrors)) {
+ m_fetcher->didReceiveResponse(m_resource, resourceResponse);
+ cancel(ResourceError::cancelledDueToAccessCheckError(KURL(response.url())));
+ return;
}
}

Powered by Google App Engine
This is Rietveld 408576698