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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ResourceLoader.cpp

Issue 2105503002: Skip foreign fetch when the skipServiceWorker flag is set on a request. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix resource loading Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 145 }
146 146
147 bool ResourceLoader::responseNeedsAccessControlCheck() const 147 bool ResourceLoader::responseNeedsAccessControlCheck() const
148 { 148 {
149 // If the fetch was (potentially) CORS enabled, an access control check of t he response is required. 149 // If the fetch was (potentially) CORS enabled, an access control check of t he response is required.
150 return m_resource->options().corsEnabled == IsCORSEnabled; 150 return m_resource->options().corsEnabled == IsCORSEnabled;
151 } 151 }
152 152
153 void ResourceLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& res ponse, WebDataConsumerHandle* rawHandle) 153 void ResourceLoader::didReceiveResponse(WebURLLoader*, const WebURLResponse& res ponse, WebDataConsumerHandle* rawHandle)
154 { 154 {
155 ASSERT(!response.isNull()); 155 DCHECK(!response.isNull());
156 // |rawHandle|'s ownership is transferred to the callee. 156 // |rawHandle|'s ownership is transferred to the callee.
157 std::unique_ptr<WebDataConsumerHandle> handle = wrapUnique(rawHandle); 157 std::unique_ptr<WebDataConsumerHandle> handle = wrapUnique(rawHandle);
158 const ResourceResponse& resourceResponse = response.toResourceResponse(); 158 const ResourceResponse& resourceResponse = response.toResourceResponse();
159 159
160 if (responseNeedsAccessControlCheck()) { 160 if (responseNeedsAccessControlCheck()) {
161 if (response.wasFetchedViaServiceWorker()) { 161 if (response.wasFetchedViaServiceWorker()) {
162 if (response.wasFallbackRequiredByServiceWorker()) { 162 if (response.wasFallbackRequiredByServiceWorker()) {
163 m_loader.reset(); 163 m_loader.reset();
164 m_loader = wrapUnique(Platform::current()->createURLLoader()); 164 m_loader = wrapUnique(Platform::current()->createURLLoader());
165 ASSERT(m_loader); 165 DCHECK(m_loader);
166 ResourceRequest request = m_resource->lastResourceRequest(); 166 ResourceRequest request = m_resource->lastResourceRequest();
167 ASSERT(!request.skipServiceWorker()); 167 DCHECK_EQ(request.skipServiceWorker(), WebURLRequest::SkipServic eWorker::None);
168 request.setSkipServiceWorker(true); 168 request.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::C ontrolling);
horo 2016/06/28 12:10:02 This code is executed when a CORS request was send
Marijn Kruisselbrink 2016/06/28 17:06:12 Also see my reply in DocumentThreadableLoader, but
169 m_loader->loadAsynchronously(WrappedResourceRequest(request), th is); 169 m_loader->loadAsynchronously(WrappedResourceRequest(request), th is);
170 return; 170 return;
171 } 171 }
172 } else { 172 } else {
173 if (!m_resource->isCacheValidator() || resourceResponse.httpStatusCo de() != 304) 173 if (!m_resource->isCacheValidator() || resourceResponse.httpStatusCo de() != 304)
174 m_resource->setResponse(resourceResponse); 174 m_resource->setResponse(resourceResponse);
175 if (!m_fetcher->canAccessResource(m_resource.get(), m_resource->opti ons().securityOrigin.get(), response.url(), ResourceFetcher::ShouldLogAccessCont rolErrors)) { 175 if (!m_fetcher->canAccessResource(m_resource.get(), m_resource->opti ons().securityOrigin.get(), response.url(), ResourceFetcher::ShouldLogAccessCont rolErrors)) {
176 m_fetcher->didReceiveResponse(m_resource.get(), resourceResponse ); 176 m_fetcher->didReceiveResponse(m_resource.get(), resourceResponse );
177 didFail(nullptr, ResourceError::cancelledDueToAccessCheckError(K URL(response.url()))); 177 didFail(nullptr, ResourceError::cancelledDueToAccessCheckError(K URL(response.url())));
178 return; 178 return;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // empty buffer is a noop in most cases, but is destructive in the case of 255 // empty buffer is a noop in most cases, but is destructive in the case of
256 // a 304, where it will overwrite the cached data we should be reusing. 256 // a 304, where it will overwrite the cached data we should be reusing.
257 if (dataOut.size()) { 257 if (dataOut.size()) {
258 m_fetcher->didReceiveData(m_resource.get(), dataOut.data(), dataOut.size (), encodedDataLength); 258 m_fetcher->didReceiveData(m_resource.get(), dataOut.data(), dataOut.size (), encodedDataLength);
259 m_resource->setResourceBuffer(dataOut); 259 m_resource->setResourceBuffer(dataOut);
260 } 260 }
261 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); 261 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
262 } 262 }
263 263
264 } // namespace blink 264 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698