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

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

Issue 2231523002: Make ResourceFetcher return Resources with LoadError instead of nullptrs. (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
Index: third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
diff --git a/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp b/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
index 53805481da6e80d641d7c919c9e5b9dbff74b711..468ba2251fa2306fe9beb2b3ae15d381730cac10 100644
--- a/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
+++ b/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
@@ -379,6 +379,14 @@ Resource* ResourceFetcher::resourceForStaticData(const FetchRequest& request, co
return resource;
}
+Resource* ResourceFetcher::resourceForBlockedRequest(const FetchRequest& request, const ResourceFactory& factory, bool needsSynchronousCacheHit)
+{
+ Resource* resource = factory.create(request.resourceRequest(), request.options(), request.charset());
+ resource->setNeedsSynchronousCacheHit(needsSynchronousCacheHit);
Nate Chapin 2016/08/09 22:43:23 Is there a case where needsSynchronousCacheHit is
engedy 2016/08/17 16:41:56 Looking through the clients that use `needsSynchro
Nate Chapin 2016/08/17 20:05:05 SubstituteData is very trusted and gets to short c
engedy 2016/09/21 21:04:01 What do you think about adding a DCHECK?
Nate Chapin 2016/09/21 23:23:41 Works for me.
+ resource->error(ResourceError::cancelledDueToAccessCheckError(request.url()));
+ return resource;
+}
+
void ResourceFetcher::moveCachedNonBlockingResourceToBlocking(Resource* resource, const FetchRequest& request)
{
// TODO(yoav): Test that non-blocking resources (video/audio/track) continue to not-block even after being preloaded and discovered.
@@ -423,8 +431,9 @@ Resource* ResourceFetcher::requestResource(FetchRequest& request, const Resource
if (!request.url().isValid())
return nullptr;
- if (!context().canRequest(factory.type(), request.resourceRequest(), MemoryCache::removeFragmentIdentifierIfNeeded(request.url()), request.options(), request.forPreload(), request.getOriginRestriction()))
- return nullptr;
+ if (!context().canRequest(factory.type(), request.resourceRequest(), MemoryCache::removeFragmentIdentifierIfNeeded(request.url()), request.options(), request.forPreload(), request.getOriginRestriction())) {
Nate Chapin 2016/08/09 22:43:23 Is it possible to move this check later, so that w
engedy 2016/08/17 16:41:56 It is possible, but unless I misunderstood your su
Nate Chapin 2016/08/17 20:05:05 Hrm, I guess the hard case here is for the Resourc
+ return resourceForBlockedRequest(request, factory, substituteData.forceSynchronousLoad());
+ }
unsigned long identifier = createUniqueIdentifier();
request.mutableResourceRequest().setPriority(computeLoadPriority(factory.type(), request, ResourcePriority::NotVisible));

Powered by Google App Engine
This is Rietveld 408576698