Diff
Modified: trunk/Source/WebCore/ChangeLog (220759 => 220760)
--- trunk/Source/WebCore/ChangeLog 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/ChangeLog 2017-08-15 21:15:09 UTC (rev 220760)
@@ -1,3 +1,82 @@
+2017-08-15 Chris Dumez <cdu...@apple.com>
+
+ Update CachedResourceLoader::requestResource() to return a WTF::Expected
+ https://bugs.webkit.org/show_bug.cgi?id=175505
+
+ Reviewed by Youenn Fablet.
+
+ Update CachedResourceLoader::requestResource() to return a WTF::Expected
+ type instead of using an out parameter for the ResourceError in case of
+ synchronous failure.
+
+ * Modules/beacon/NavigatorBeacon.cpp:
+ (WebCore::NavigatorBeacon::sendBeacon):
+ * bindings/js/CachedScriptFetcher.cpp:
+ (WebCore::CachedScriptFetcher::requestScriptWithCache const):
+ * css/CSSFontFaceSrcValue.cpp:
+ (WebCore::CSSFontFaceSrcValue::cachedFont):
+ * css/CSSImageSetValue.cpp:
+ (WebCore::CSSImageSetValue::loadBestFitImage):
+ * css/CSSImageValue.cpp:
+ (WebCore::CSSImageValue::loadImage):
+ * css/StyleRuleImport.cpp:
+ (WebCore::StyleRuleImport::requestStyleSheet):
+ * dom/ProcessingInstruction.cpp:
+ (WebCore::ProcessingInstruction::checkStyleSheet):
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::process):
+ * loader/CrossOriginPreflightChecker.cpp:
+ (WebCore::CrossOriginPreflightChecker::startPreflight):
+ * loader/DocumentLoader.cpp:
+ (WebCore::DocumentLoader::startLoadingMainResource):
+ * loader/DocumentThreadableLoader.cpp:
+ (WebCore::DocumentThreadableLoader::loadRequest):
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::loadedResourceFromMemoryCache):
+ * loader/FrameLoader.h:
+ * loader/ImageLoader.cpp:
+ (WebCore::ImageLoader::updateFromElement):
+ * loader/LinkLoader.cpp:
+ (WebCore::LinkLoader::preloadIfNeeded):
+ * loader/MediaResourceLoader.cpp:
+ (WebCore::MediaResourceLoader::requestResource):
+ * loader/TextTrackLoader.cpp:
+ (WebCore::TextTrackLoader::load):
+ * loader/cache/CachedResourceLoader.cpp:
+ (WebCore::castCachedResourceTo):
+ (WebCore::CachedResourceLoader::requestImage):
+ (WebCore::CachedResourceLoader::requestFont):
+ (WebCore::CachedResourceLoader::requestTextTrack):
+ (WebCore::CachedResourceLoader::requestCSSStyleSheet):
+ (WebCore::CachedResourceLoader::requestUserCSSStyleSheet):
+ (WebCore::CachedResourceLoader::requestScript):
+ (WebCore::CachedResourceLoader::requestXSLStyleSheet):
+ (WebCore::CachedResourceLoader::requestSVGDocument):
+ (WebCore::CachedResourceLoader::requestLinkResource):
+ (WebCore::CachedResourceLoader::requestMedia):
+ (WebCore::CachedResourceLoader::requestIcon):
+ (WebCore::CachedResourceLoader::requestRawResource):
+ (WebCore::CachedResourceLoader::requestBeaconResource):
+ (WebCore::CachedResourceLoader::requestMainResource):
+ (WebCore::CachedResourceLoader::shouldContinueAfterNotifyingLoadedFromMemoryCache):
+ (WebCore::CachedResourceLoader::requestResource):
+ (WebCore::CachedResourceLoader::preload):
+ * loader/cache/CachedResourceLoader.h:
+ * loader/cache/CachedSVGDocumentReference.cpp:
+ (WebCore::CachedSVGDocumentReference::load):
+ * loader/icon/IconLoader.cpp:
+ (WebCore::IconLoader::startLoading):
+ * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
+ (WebCore::WebCoreAVFResourceLoader::startLoading):
+ * svg/SVGFEImageElement.cpp:
+ (WebCore::SVGFEImageElement::requestImageResource):
+ * svg/SVGFontFaceUriElement.cpp:
+ (WebCore::SVGFontFaceUriElement::loadFont):
+ * svg/SVGUseElement.cpp:
+ (WebCore::SVGUseElement::updateExternalDocument):
+ * xml/XSLImportRule.cpp:
+ (WebCore::XSLImportRule::loadSheet):
+
2017-08-15 Don Olmstead <don.olmst...@sony.com>
[PAL] Move Sleep classes into PAL
Modified: trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp (220759 => 220760)
--- trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -73,13 +73,12 @@
options.mode = FetchOptions::Mode::NoCors;
}
}
- ResourceError error;
- if (!document.cachedResourceLoader().requestBeaconResource({ WTFMove(request), options }, &error)) {
- if (!error.isNull())
- document.addConsoleMessage(MessageSource::Network, MessageLevel::Error, error.localizedDescription());
- return false;
- }
- return true;
+ auto cachedResource = document.cachedResourceLoader().requestBeaconResource({ WTFMove(request), options });
+ if (cachedResource)
+ return true;
+
+ document.addConsoleMessage(MessageSource::Network, MessageLevel::Error, cachedResource.error().localizedDescription());
+ return false;
}
}
Modified: trunk/Source/WebCore/bindings/js/CachedScriptFetcher.cpp (220759 => 220760)
--- trunk/Source/WebCore/bindings/js/CachedScriptFetcher.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/bindings/js/CachedScriptFetcher.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -63,7 +63,7 @@
if (!m_initiatorName.isNull())
request.setInitiator(m_initiatorName);
- return document.cachedResourceLoader().requestScript(WTFMove(request));
+ return document.cachedResourceLoader().requestScript(WTFMove(request)).valueOr(nullptr);
}
}
Modified: trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp (220759 => 220760)
--- trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/css/CSSFontFaceSrcValue.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -101,7 +101,7 @@
CachedResourceRequest request(ResourceRequest(document->completeURL(m_resource)), options);
request.setInitiator(cachedResourceRequestInitiators().css);
- m_cachedFont = document->cachedResourceLoader().requestFont(WTFMove(request), isSVG);
+ m_cachedFont = document->cachedResourceLoader().requestFont(WTFMove(request), isSVG).valueOr(nullptr);
return m_cachedFont.get();
}
Modified: trunk/Source/WebCore/css/CSSImageSetValue.cpp (220759 => 220760)
--- trunk/Source/WebCore/css/CSSImageSetValue.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/css/CSSImageSetValue.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -105,7 +105,7 @@
if (options.mode == FetchOptions::Mode::Cors)
request.updateForAccessControl(*document);
- m_cachedImage = loader.requestImage(WTFMove(request));
+ m_cachedImage = loader.requestImage(WTFMove(request)).valueOr(nullptr);
m_bestFitImageScaleFactor = image.scaleFactor;
}
return { m_cachedImage.get(), m_bestFitImageScaleFactor };
Modified: trunk/Source/WebCore/css/CSSImageValue.cpp (220759 => 220760)
--- trunk/Source/WebCore/css/CSSImageValue.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/css/CSSImageValue.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -74,7 +74,7 @@
ASSERT(loader.document());
request.updateForAccessControl(*loader.document());
}
- m_cachedImage = loader.requestImage(WTFMove(request));
+ m_cachedImage = loader.requestImage(WTFMove(request)).valueOr(nullptr);
}
return m_cachedImage.get();
}
Modified: trunk/Source/WebCore/css/StyleRuleImport.cpp (220759 => 220760)
--- trunk/Source/WebCore/css/StyleRuleImport.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/css/StyleRuleImport.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -123,7 +123,7 @@
request.setOptions(ResourceLoaderOptions(DoNotSendCallbacks, SniffContent, BufferData, AllowStoredCredentials, ClientCredentialPolicy::MayAskClientForCredentials, FetchOptions::Credentials::Include, SkipSecurityCheck, FetchOptions::Mode::NoCors, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::SkipPolicyCheck, DefersLoadingPolicy::AllowDefersLoading, CachingPolicy::AllowCaching));
m_cachedSheet = document->cachedResourceLoader().requestUserCSSStyleSheet(WTFMove(request));
} else
- m_cachedSheet = document->cachedResourceLoader().requestCSSStyleSheet(WTFMove(request));
+ m_cachedSheet = document->cachedResourceLoader().requestCSSStyleSheet(WTFMove(request)).valueOr(nullptr);
if (m_cachedSheet) {
// if the import rule is issued dynamically, the sheet may be
// removed from the pending sheet count, so let the doc know
Modified: trunk/Source/WebCore/dom/ProcessingInstruction.cpp (220759 => 220760)
--- trunk/Source/WebCore/dom/ProcessingInstruction.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/dom/ProcessingInstruction.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -162,7 +162,7 @@
if (m_isXSL) {
auto options = CachedResourceLoader::defaultCachedResourceOptions();
options.mode = FetchOptions::Mode::SameOrigin;
- m_cachedSheet = document().cachedResourceLoader().requestXSLStyleSheet({ResourceRequest(document().completeURL(href)), options});
+ m_cachedSheet = document().cachedResourceLoader().requestXSLStyleSheet({ResourceRequest(document().completeURL(href)), options}).valueOr(nullptr);
} else
#endif
{
@@ -169,7 +169,7 @@
String charset = attrs.get("charset");
CachedResourceRequest request(document().completeURL(href), CachedResourceLoader::defaultCachedResourceOptions(), std::nullopt, charset.isEmpty() ? document().charset() : WTFMove(charset));
- m_cachedSheet = document().cachedResourceLoader().requestCSSStyleSheet(WTFMove(request));
+ m_cachedSheet = document().cachedResourceLoader().requestCSSStyleSheet(WTFMove(request)).valueOr(nullptr);
}
if (m_cachedSheet)
m_cachedSheet->addClient(*this);
Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (220759 => 220760)
--- trunk/Source/WebCore/html/HTMLLinkElement.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -313,7 +313,7 @@
request.setAsPotentiallyCrossOrigin(crossOrigin(), document());
ASSERT_WITH_SECURITY_IMPLICATION(!m_cachedSheet);
- m_cachedSheet = document().cachedResourceLoader().requestCSSStyleSheet(WTFMove(request));
+ m_cachedSheet = document().cachedResourceLoader().requestCSSStyleSheet(WTFMove(request)).valueOr(nullptr);
if (m_cachedSheet)
m_cachedSheet->addClient(*this);
Modified: trunk/Source/WebCore/loader/CrossOriginPreflightChecker.cpp (220759 => 220760)
--- trunk/Source/WebCore/loader/CrossOriginPreflightChecker.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/loader/CrossOriginPreflightChecker.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -107,7 +107,7 @@
preflightRequest.setInitiator(m_loader.options().initiator);
ASSERT(!m_resource);
- m_resource = m_loader.document().cachedResourceLoader().requestRawResource(WTFMove(preflightRequest));
+ m_resource = m_loader.document().cachedResourceLoader().requestRawResource(WTFMove(preflightRequest)).valueOr(nullptr);
if (m_resource)
m_resource->addClient(*this);
}
Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (220759 => 220760)
--- trunk/Source/WebCore/loader/DocumentLoader.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -1487,7 +1487,7 @@
origin->setStorageBlockingPolicy(frameLoader()->frame().settings().storageBlockingPolicy());
mainResourceRequest.setDomainForCachePartition(origin->domainForCachePartition());
}
- m_mainResource = m_cachedResourceLoader->requestMainResource(WTFMove(mainResourceRequest));
+ m_mainResource = m_cachedResourceLoader->requestMainResource(WTFMove(mainResourceRequest)).valueOr(nullptr);
#if ENABLE(CONTENT_EXTENSIONS)
if (m_mainResource && m_mainResource->errorOccurred() && m_frame->page() && m_mainResource->resourceError().domain() == ContentExtensions::WebKitContentBlockerDomain) {
Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp (220759 => 220760)
--- trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -449,19 +449,12 @@
resource->removeClient(*this);
}
- // We create an URL here as the request will be moved in requestRawResource
- URL requestUrl = newRequest.resourceRequest().url();
- ResourceError error;
- m_resource = m_document.cachedResourceLoader().requestRawResource(WTFMove(newRequest), &error);
+ auto cachedResource = m_document.cachedResourceLoader().requestRawResource(WTFMove(newRequest));
+ m_resource = cachedResource.valueOr(nullptr);
if (m_resource)
m_resource->addClient(*this);
- else {
- if (error.isNull()) {
- // FIXME: Since we receive a synchronous error, this is probably due to some AccessControl checks. We should try to retrieve the actual error.
- logErrorAndFail(ResourceError(String(), 0, requestUrl, String(), ResourceError::Type::AccessControl));
- } else
- logErrorAndFail(error);
- }
+ else
+ logErrorAndFail(cachedResource.error());
return;
}
Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (220759 => 220760)
--- trunk/Source/WebCore/loader/FrameLoader.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -3236,39 +3236,38 @@
request = newRequest;
}
-void FrameLoader::loadedResourceFromMemoryCache(CachedResource* resource, ResourceRequest& newRequest)
+void FrameLoader::loadedResourceFromMemoryCache(CachedResource& resource, ResourceRequest& newRequest, ResourceError& error)
{
Page* page = m_frame.page();
if (!page)
return;
- if (!resource->shouldSendResourceLoadCallbacks() || m_documentLoader->haveToldClientAboutLoad(resource->url()))
+ if (!resource.shouldSendResourceLoadCallbacks() || m_documentLoader->haveToldClientAboutLoad(resource.url()))
return;
// Main resource delegate messages are synthesized in MainResourceLoader, so we must not send them here.
- if (resource->type() == CachedResource::MainResource)
+ if (resource.type() == CachedResource::MainResource)
return;
if (!page->areMemoryCacheClientCallsEnabled()) {
- InspectorInstrumentation::didLoadResourceFromMemoryCache(*page, m_documentLoader.get(), resource);
- m_documentLoader->recordMemoryCacheLoadForFutureClientNotification(resource->resourceRequest());
- m_documentLoader->didTellClientAboutLoad(resource->url());
+ InspectorInstrumentation::didLoadResourceFromMemoryCache(*page, m_documentLoader.get(), &resource);
+ m_documentLoader->recordMemoryCacheLoadForFutureClientNotification(resource.resourceRequest());
+ m_documentLoader->didTellClientAboutLoad(resource.url());
return;
}
- if (m_client.dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(), newRequest, resource->response(), resource->encodedSize())) {
- InspectorInstrumentation::didLoadResourceFromMemoryCache(*page, m_documentLoader.get(), resource);
- m_documentLoader->didTellClientAboutLoad(resource->url());
+ if (m_client.dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(), newRequest, resource.response(), resource.encodedSize())) {
+ InspectorInstrumentation::didLoadResourceFromMemoryCache(*page, m_documentLoader.get(), &resource);
+ m_documentLoader->didTellClientAboutLoad(resource.url());
return;
}
unsigned long identifier;
- ResourceError error;
requestFromDelegate(newRequest, identifier, error);
- ResourceResponse response = resource->response();
+ ResourceResponse response = resource.response();
response.setSource(ResourceResponse::Source::MemoryCache);
- notifier().sendRemainingDelegateMessages(m_documentLoader.get(), identifier, newRequest, response, 0, resource->encodedSize(), 0, error);
+ notifier().sendRemainingDelegateMessages(m_documentLoader.get(), identifier, newRequest, response, 0, resource.encodedSize(), 0, error);
}
void FrameLoader::applyUserAgent(ResourceRequest& request)
Modified: trunk/Source/WebCore/loader/FrameLoader.h (220759 => 220760)
--- trunk/Source/WebCore/loader/FrameLoader.h 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/loader/FrameLoader.h 2017-08-15 21:15:09 UTC (rev 220760)
@@ -190,7 +190,7 @@
void didReachLayoutMilestone(LayoutMilestones);
void didFirstLayout();
- void loadedResourceFromMemoryCache(CachedResource*, ResourceRequest& newRequest);
+ void loadedResourceFromMemoryCache(CachedResource&, ResourceRequest& newRequest, ResourceError&);
void tellClientAboutPastMemoryCacheLoads();
void checkLoadComplete();
Modified: trunk/Source/WebCore/loader/ImageLoader.cpp (220759 => 220760)
--- trunk/Source/WebCore/loader/ImageLoader.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/loader/ImageLoader.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -192,7 +192,7 @@
document.cachedResourceLoader().m_documentResources.set(newImage->url(), newImage.get());
document.cachedResourceLoader().setAutoLoadImages(autoLoadOtherImages);
} else
- newImage = document.cachedResourceLoader().requestImage(WTFMove(request));
+ newImage = document.cachedResourceLoader().requestImage(WTFMove(request)).valueOr(nullptr);
// If we do not have an image here, it means that a cross-site
// violation occurred, or that the image was blocked via Content
Modified: trunk/Source/WebCore/loader/LinkLoader.cpp (220759 => 220760)
--- trunk/Source/WebCore/loader/LinkLoader.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/loader/LinkLoader.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -229,7 +229,7 @@
linkRequest.setIsLinkPreload();
linkRequest.setAsPotentiallyCrossOrigin(crossOriginMode, document);
- CachedResourceHandle<CachedResource> cachedLinkResource = document.cachedResourceLoader().preload(type.value(), WTFMove(linkRequest));
+ auto cachedLinkResource = document.cachedResourceLoader().preload(type.value(), WTFMove(linkRequest)).valueOr(nullptr);
if (cachedLinkResource && loader)
return createLinkPreloadResourceClient(*cachedLinkResource, *loader, type.value());
@@ -279,7 +279,7 @@
}
ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
options.contentSecurityPolicyImposition = ContentSecurityPolicyImposition::SkipPolicyCheck;
- m_cachedLinkResource = document.cachedResourceLoader().requestLinkResource(type, CachedResourceRequest(ResourceRequest(document.completeURL(href)), options, priority));
+ m_cachedLinkResource = document.cachedResourceLoader().requestLinkResource(type, CachedResourceRequest(ResourceRequest(document.completeURL(href)), options, priority)).valueOr(nullptr);
if (m_cachedLinkResource)
m_cachedLinkResource->addClient(*this);
}
Modified: trunk/Source/WebCore/loader/MediaResourceLoader.cpp (220759 => 220760)
--- trunk/Source/WebCore/loader/MediaResourceLoader.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/loader/MediaResourceLoader.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -82,7 +82,7 @@
if (m_mediaElement)
cacheRequest.setInitiator(*m_mediaElement.get());
- CachedResourceHandle<CachedRawResource> resource = m_document->cachedResourceLoader().requestMedia(WTFMove(cacheRequest));
+ auto resource = m_document->cachedResourceLoader().requestMedia(WTFMove(cacheRequest)).valueOr(nullptr);
if (!resource)
return nullptr;
Modified: trunk/Source/WebCore/loader/TextTrackLoader.cpp (220759 => 220760)
--- trunk/Source/WebCore/loader/TextTrackLoader.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/loader/TextTrackLoader.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -155,7 +155,7 @@
CachedResourceRequest cueRequest(ResourceRequest(document->completeURL(url)), options);
cueRequest.setAsPotentiallyCrossOrigin(crossOriginMode, *document);
- m_resource = document->cachedResourceLoader().requestTextTrack(WTFMove(cueRequest));
+ m_resource = document->cachedResourceLoader().requestTextTrack(WTFMove(cueRequest)).valueOr(nullptr);
if (!m_resource)
return false;
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp (220759 => 220760)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -86,6 +86,14 @@
// Timeout for link preloads to be used after window.onload
static const Seconds unusedPreloadTimeout { 3_s };
+template <typename T, typename U>
+static inline ResourceErrorOr<CachedResourceHandle<T>> castCachedResourceTo(ResourceErrorOr<CachedResourceHandle<U>>&& cachedResource)
+{
+ if (cachedResource)
+ return CachedResourceHandle<T> { static_cast<T*>(cachedResource.value().get()) };
+ return makeUnexpected(cachedResource.error());
+}
+
static CachedResource* createResource(CachedResource::Type type, CachedResourceRequest&& request, SessionID sessionID)
{
switch (type) {
@@ -181,7 +189,7 @@
return sessionID;
}
-CachedResourceHandle<CachedImage> CachedResourceLoader::requestImage(CachedResourceRequest&& request, ResourceError* error)
+ResourceErrorOr<CachedResourceHandle<CachedImage>> CachedResourceLoader::requestImage(CachedResourceRequest&& request)
{
if (Frame* frame = this->frame()) {
if (frame->loader().pageDismissalEventBeingDispatched() != FrameLoader::PageDismissalType::None) {
@@ -190,38 +198,38 @@
URL requestURL = request.resourceRequest().url();
if (requestURL.isValid() && canRequest(CachedResource::ImageResource, requestURL, request, ForPreload::No))
PingLoader::loadImage(*frame, requestURL);
- return nullptr;
+ return CachedResourceHandle<CachedImage> { };
}
}
auto defer = clientDefersImage(request.resourceRequest().url()) ? DeferOption::DeferredByClient : DeferOption::NoDefer;
- return downcast<CachedImage>(requestResource(CachedResource::ImageResource, WTFMove(request), error, ForPreload::No, defer).get());
+ return castCachedResourceTo<CachedImage>(requestResource(CachedResource::ImageResource, WTFMove(request), ForPreload::No, defer));
}
-CachedResourceHandle<CachedFont> CachedResourceLoader::requestFont(CachedResourceRequest&& request, bool isSVG, ResourceError* error)
+ResourceErrorOr<CachedResourceHandle<CachedFont>> CachedResourceLoader::requestFont(CachedResourceRequest&& request, bool isSVG)
{
#if ENABLE(SVG_FONTS)
if (isSVG)
- return downcast<CachedSVGFont>(requestResource(CachedResource::SVGFontResource, WTFMove(request), error).get());
+ return castCachedResourceTo<CachedFont>(requestResource(CachedResource::SVGFontResource, WTFMove(request)));
#else
UNUSED_PARAM(isSVG);
#endif
- return downcast<CachedFont>(requestResource(CachedResource::FontResource, WTFMove(request), error).get());
+ return castCachedResourceTo<CachedFont>(requestResource(CachedResource::FontResource, WTFMove(request)));
}
#if ENABLE(VIDEO_TRACK)
-CachedResourceHandle<CachedTextTrack> CachedResourceLoader::requestTextTrack(CachedResourceRequest&& request, ResourceError* error)
+ResourceErrorOr<CachedResourceHandle<CachedTextTrack>> CachedResourceLoader::requestTextTrack(CachedResourceRequest&& request)
{
- return downcast<CachedTextTrack>(requestResource(CachedResource::TextTrackResource, WTFMove(request), error).get());
+ return castCachedResourceTo<CachedTextTrack>(requestResource(CachedResource::TextTrackResource, WTFMove(request)));
}
#endif
-CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestCSSStyleSheet(CachedResourceRequest&& request, ResourceError* error)
+ResourceErrorOr<CachedResourceHandle<CachedCSSStyleSheet>> CachedResourceLoader::requestCSSStyleSheet(CachedResourceRequest&& request)
{
- return downcast<CachedCSSStyleSheet>(requestResource(CachedResource::CSSStyleSheet, WTFMove(request), error).get());
+ return castCachedResourceTo<CachedCSSStyleSheet>(requestResource(CachedResource::CSSStyleSheet, WTFMove(request)));
}
-CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestUserCSSStyleSheet(CachedResourceRequest&& request, ResourceError*)
+CachedResourceHandle<CachedCSSStyleSheet> CachedResourceLoader::requestUserCSSStyleSheet(CachedResourceRequest&& request)
{
ASSERT(document());
request.setDomainForCachePartition(*document());
@@ -247,55 +255,55 @@
return userSheet;
}
-CachedResourceHandle<CachedScript> CachedResourceLoader::requestScript(CachedResourceRequest&& request, ResourceError* error)
+ResourceErrorOr<CachedResourceHandle<CachedScript>> CachedResourceLoader::requestScript(CachedResourceRequest&& request)
{
- return downcast<CachedScript>(requestResource(CachedResource::Script, WTFMove(request), error).get());
+ return castCachedResourceTo<CachedScript>(requestResource(CachedResource::Script, WTFMove(request)));
}
#if ENABLE(XSLT)
-CachedResourceHandle<CachedXSLStyleSheet> CachedResourceLoader::requestXSLStyleSheet(CachedResourceRequest&& request, ResourceError* error)
+ResourceErrorOr<CachedResourceHandle<CachedXSLStyleSheet>> CachedResourceLoader::requestXSLStyleSheet(CachedResourceRequest&& request)
{
- return downcast<CachedXSLStyleSheet>(requestResource(CachedResource::XSLStyleSheet, WTFMove(request), error).get());
+ return castCachedResourceTo<CachedXSLStyleSheet>(requestResource(CachedResource::XSLStyleSheet, WTFMove(request)));
}
#endif
-CachedResourceHandle<CachedSVGDocument> CachedResourceLoader::requestSVGDocument(CachedResourceRequest&& request, ResourceError* error)
+ResourceErrorOr<CachedResourceHandle<CachedSVGDocument>> CachedResourceLoader::requestSVGDocument(CachedResourceRequest&& request)
{
- return downcast<CachedSVGDocument>(requestResource(CachedResource::SVGDocumentResource, WTFMove(request), error).get());
+ return castCachedResourceTo<CachedSVGDocument>(requestResource(CachedResource::SVGDocumentResource, WTFMove(request)));
}
#if ENABLE(LINK_PREFETCH)
-CachedResourceHandle<CachedResource> CachedResourceLoader::requestLinkResource(CachedResource::Type type, CachedResourceRequest&& request, ResourceError* error)
+ResourceErrorOr<CachedResourceHandle<CachedResource>> CachedResourceLoader::requestLinkResource(CachedResource::Type type, CachedResourceRequest&& request)
{
ASSERT(frame());
ASSERT(type == CachedResource::LinkPrefetch || type == CachedResource::LinkSubresource);
- return requestResource(type, WTFMove(request), error);
+ return requestResource(type, WTFMove(request));
}
#endif
-CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestMedia(CachedResourceRequest&& request, ResourceError* error)
+ResourceErrorOr<CachedResourceHandle<CachedRawResource>> CachedResourceLoader::requestMedia(CachedResourceRequest&& request)
{
- return downcast<CachedRawResource>(requestResource(CachedResource::MediaResource, WTFMove(request), error).get());
+ return castCachedResourceTo<CachedRawResource>(requestResource(CachedResource::MediaResource, WTFMove(request)));
}
-CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestIcon(CachedResourceRequest&& request, ResourceError* error)
+ResourceErrorOr<CachedResourceHandle<CachedRawResource>> CachedResourceLoader::requestIcon(CachedResourceRequest&& request)
{
- return downcast<CachedRawResource>(requestResource(CachedResource::Icon, WTFMove(request), error).get());
+ return castCachedResourceTo<CachedRawResource>(requestResource(CachedResource::Icon, WTFMove(request)));
}
-CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestRawResource(CachedResourceRequest&& request, ResourceError* error)
+ResourceErrorOr<CachedResourceHandle<CachedRawResource>> CachedResourceLoader::requestRawResource(CachedResourceRequest&& request)
{
- return downcast<CachedRawResource>(requestResource(CachedResource::RawResource, WTFMove(request), error).get());
+ return castCachedResourceTo<CachedRawResource>(requestResource(CachedResource::RawResource, WTFMove(request)));
}
-CachedResourceHandle<CachedResource> CachedResourceLoader::requestBeaconResource(CachedResourceRequest&& request, ResourceError* error)
+ResourceErrorOr<CachedResourceHandle<CachedResource>> CachedResourceLoader::requestBeaconResource(CachedResourceRequest&& request)
{
- return requestResource(CachedResource::Beacon, WTFMove(request), error).get();
+ return requestResource(CachedResource::Beacon, WTFMove(request));
}
-CachedResourceHandle<CachedRawResource> CachedResourceLoader::requestMainResource(CachedResourceRequest&& request, ResourceError* error)
+ResourceErrorOr<CachedResourceHandle<CachedRawResource>> CachedResourceLoader::requestMainResource(CachedResourceRequest&& request)
{
- return downcast<CachedRawResource>(requestResource(CachedResource::MainResource, WTFMove(request), error).get());
+ return castCachedResourceTo<CachedRawResource>(requestResource(CachedResource::MainResource, WTFMove(request)));
}
static MixedContentChecker::ContentType contentTypeFromResourceType(CachedResource::Type type)
@@ -556,16 +564,16 @@
return false;
}
-bool CachedResourceLoader::shouldContinueAfterNotifyingLoadedFromMemoryCache(const CachedResourceRequest& request, CachedResource* resource)
+bool CachedResourceLoader::shouldContinueAfterNotifyingLoadedFromMemoryCache(const CachedResourceRequest& request, CachedResource& resource, ResourceError& error)
{
- if (!resource || !frame() || resource->status() != CachedResource::Cached)
+ if (!frame() || resource.status() != CachedResource::Cached)
return true;
- ResourceRequest newRequest = ResourceRequest(resource->url());
+ ResourceRequest newRequest = ResourceRequest(resource.url());
newRequest.setInitiatorIdentifier(request.resourceRequest().initiatorIdentifier());
if (request.resourceRequest().hiddenFromInspector())
newRequest.setHiddenFromInspector(true);
- frame()->loader().loadedResourceFromMemoryCache(resource, newRequest);
+ frame()->loader().loadedResourceFromMemoryCache(resource, newRequest, error);
// FIXME <http://webkit.org/b/113251>: If the delegate modifies the request's
// URL, it is no longer appropriate to use this CachedResource.
@@ -688,7 +696,7 @@
request.updateAccordingCacheMode();
}
-CachedResourceHandle<CachedResource> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest&& request, ResourceError* error, ForPreload forPreload, DeferOption defer)
+ResourceErrorOr<CachedResourceHandle<CachedResource>> CachedResourceLoader::requestResource(CachedResource::Type type, CachedResourceRequest&& request, ForPreload forPreload, DeferOption defer)
{
if (Document* document = this->document())
request.upgradeInsecureRequestIfNeeded(*document);
@@ -699,9 +707,7 @@
if (!url.isValid()) {
RELEASE_LOG_IF_ALLOWED("requestResource: URL is invalid (frame = %p)", frame());
- if (error)
- *error = { errorDomainWebKitInternal, 0, url, ASCIILiteral("URL is invalid") };
- return nullptr;
+ return makeUnexpected(ResourceError { errorDomainWebKitInternal, 0, url, ASCIILiteral("URL is invalid") });
}
prepareFetch(type, request);
@@ -709,9 +715,7 @@
// We are passing url as well as request, as request url may contain a fragment identifier.
if (!canRequest(type, url, request, forPreload)) {
RELEASE_LOG_IF_ALLOWED("requestResource: Not allowed to request resource (frame = %p)", frame());
- if (error)
- *error = { errorDomainWebKitInternal, 0, url, ASCIILiteral("Not allowed to request resource"), ResourceError::Type::AccessControl };
- return nullptr;
+ return makeUnexpected(ResourceError { errorDomainWebKitInternal, 0, url, ASCIILiteral("Not allowed to request resource"), ResourceError::Type::AccessControl });
}
#if ENABLE(CONTENT_EXTENSIONS)
@@ -722,15 +726,13 @@
if (blockedStatus.blockedLoad) {
RELEASE_LOG_IF_ALLOWED("requestResource: Resource blocked by content blocker (frame = %p)", frame());
if (type == CachedResource::Type::MainResource) {
- auto resource = createResource(type, WTFMove(request), sessionID());
+ CachedResourceHandle<CachedResource> resource = createResource(type, WTFMove(request), sessionID());
ASSERT(resource);
resource->error(CachedResource::Status::LoadError);
resource->setResourceError(ResourceError(ContentExtensions::WebKitContentBlockerDomain, 0, resourceRequest.url(), WEB_UI_STRING("The URL was blocked by a content blocker", "WebKitErrorBlockedByContentBlocker description")));
- return resource;
+ return WTFMove(resource);
}
- if (error)
- *error = { errorDomainWebKitInternal, 0, url, ASCIILiteral("Resource blocked by content blocker"), ResourceError::Type::AccessControl };
- return nullptr;
+ return makeUnexpected(ResourceError { errorDomainWebKitInternal, 0, url, ASCIILiteral("Resource blocked by content blocker"), ResourceError::Type::AccessControl });
}
if (blockedStatus.madeHTTPS
&& type == CachedResource::Type::MainResource
@@ -794,8 +796,9 @@
if (resource->status() != CachedResource::Status::Cached)
policy = Load;
} else {
- if (!shouldContinueAfterNotifyingLoadedFromMemoryCache(request, resource.get()))
- return nullptr;
+ ResourceError error;
+ if (!shouldContinueAfterNotifyingLoadedFromMemoryCache(request, *resource, error))
+ return makeUnexpected(WTFMove(error));
logMemoryCacheResourceRequest(frame(), DiagnosticLoggingKeys::memoryCacheEntryDecisionKey(), DiagnosticLoggingKeys::usedKey());
loadTiming.setResponseEnd(MonotonicTime::now());
@@ -818,10 +821,8 @@
}
break;
}
+ ASSERT(resource);
- if (!resource)
- return nullptr;
-
if (forPreload == ForPreload::No && resource->loader() && resource->ignoreForRequestCount()) {
resource->setIgnoreForRequestCount(false);
incrementRequestCount(*resource);
@@ -834,12 +835,12 @@
if (resource->errorOccurred()) {
if (resource->allowsCaching() && resource->inCache())
memoryCache.remove(*resource);
- if (error) {
- auto resourceError = resource->resourceError();
- // Synchronous cancellations are likely due to access control.
- *error = !resourceError.isNull() && !resourceError.isCancellation() ? resourceError : ResourceError(String(), 0, url, String(), ResourceError::Type::AccessControl);
- }
- return nullptr;
+
+ auto resourceError = resource->resourceError();
+ // Synchronous cancellations are likely due to access control.
+ if (resourceError.isNull() || resourceError.isCancellation())
+ return makeUnexpected(ResourceError { String(), 0, url, String(), ResourceError::Type::AccessControl });
+ return makeUnexpected(resourceError);
}
}
@@ -848,7 +849,7 @@
ASSERT(resource->url() == url.string());
m_documentResources.set(resource->url(), resource);
- return resource;
+ return WTFMove(resource);
}
void CachedResourceLoader::documentDidFinishLoadEvent()
@@ -1250,21 +1251,22 @@
ASSERT(m_requestCount > -1);
}
-CachedResourceHandle<CachedResource> CachedResourceLoader::preload(CachedResource::Type type, CachedResourceRequest&& request)
+ResourceErrorOr<CachedResourceHandle<CachedResource>> CachedResourceLoader::preload(CachedResource::Type type, CachedResourceRequest&& request)
{
if (request.charset().isEmpty() && (type == CachedResource::Script || type == CachedResource::CSSStyleSheet))
request.setCharset(m_document->charset());
- CachedResourceHandle<CachedResource> resource = requestResource(type, WTFMove(request), nullptr, ForPreload::Yes);
- if (resource && (!m_preloads || !m_preloads->contains(resource.get()))) {
+ auto resource = requestResource(type, WTFMove(request), ForPreload::Yes);
+ if (resource && (!m_preloads || !m_preloads->contains(resource.value().get()))) {
+ auto resourceValue = resource.value();
// Fonts need special treatment since just creating the resource doesn't trigger a load.
if (type == CachedResource::FontResource)
- downcast<CachedFont>(resource.get())->beginLoadIfNeeded(*this);
- resource->increasePreloadCount();
+ downcast<CachedFont>(resourceValue.get())->beginLoadIfNeeded(*this);
+ resourceValue->increasePreloadCount();
if (!m_preloads)
m_preloads = std::make_unique<ListHashSet<CachedResource*>>();
- m_preloads->add(resource.get());
+ m_preloads->add(resourceValue.get());
}
return resource;
}
Modified: trunk/Source/WebCore/loader/cache/CachedResourceLoader.h (220759 => 220760)
--- trunk/Source/WebCore/loader/cache/CachedResourceLoader.h 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/loader/cache/CachedResourceLoader.h 2017-08-15 21:15:09 UTC (rev 220760)
@@ -33,6 +33,7 @@
#include "KeepaliveRequestTracker.h"
#include "ResourceTimingInformation.h"
#include "Timer.h"
+#include <wtf/Expected.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/ListHashSet.h>
@@ -55,6 +56,9 @@
class Settings;
class URL;
+template <typename T>
+using ResourceErrorOr = Expected<T, ResourceError>;
+
// The CachedResourceLoader provides a per-context interface to the MemoryCache
// and enforces a bunch of security checks and rules for resource revalidation.
// Its lifetime is roughly per-DocumentLoader, in that it is generally created
@@ -72,25 +76,25 @@
static Ref<CachedResourceLoader> create(DocumentLoader* documentLoader) { return adoptRef(*new CachedResourceLoader(documentLoader)); }
~CachedResourceLoader();
- CachedResourceHandle<CachedImage> requestImage(CachedResourceRequest&&, ResourceError* = nullptr);
- CachedResourceHandle<CachedCSSStyleSheet> requestCSSStyleSheet(CachedResourceRequest&&, ResourceError* = nullptr);
- CachedResourceHandle<CachedCSSStyleSheet> requestUserCSSStyleSheet(CachedResourceRequest&&, ResourceError* = nullptr);
- CachedResourceHandle<CachedScript> requestScript(CachedResourceRequest&&, ResourceError* = nullptr);
- CachedResourceHandle<CachedFont> requestFont(CachedResourceRequest&&, bool isSVG, ResourceError* = nullptr);
- CachedResourceHandle<CachedRawResource> requestMedia(CachedResourceRequest&&, ResourceError* = nullptr);
- CachedResourceHandle<CachedRawResource> requestIcon(CachedResourceRequest&&, ResourceError* = nullptr);
- CachedResourceHandle<CachedResource> requestBeaconResource(CachedResourceRequest&&, ResourceError* = nullptr);
- CachedResourceHandle<CachedRawResource> requestRawResource(CachedResourceRequest&&, ResourceError* = nullptr);
- CachedResourceHandle<CachedRawResource> requestMainResource(CachedResourceRequest&&, ResourceError* = nullptr);
- CachedResourceHandle<CachedSVGDocument> requestSVGDocument(CachedResourceRequest&&, ResourceError* = nullptr);
+ ResourceErrorOr<CachedResourceHandle<CachedImage>> requestImage(CachedResourceRequest&&);
+ ResourceErrorOr<CachedResourceHandle<CachedCSSStyleSheet>> requestCSSStyleSheet(CachedResourceRequest&&);
+ CachedResourceHandle<CachedCSSStyleSheet> requestUserCSSStyleSheet(CachedResourceRequest&&);
+ ResourceErrorOr<CachedResourceHandle<CachedScript>> requestScript(CachedResourceRequest&&);
+ ResourceErrorOr<CachedResourceHandle<CachedFont>> requestFont(CachedResourceRequest&&, bool isSVG);
+ ResourceErrorOr<CachedResourceHandle<CachedRawResource>> requestMedia(CachedResourceRequest&&);
+ ResourceErrorOr<CachedResourceHandle<CachedRawResource>> requestIcon(CachedResourceRequest&&);
+ ResourceErrorOr<CachedResourceHandle<CachedResource>> requestBeaconResource(CachedResourceRequest&&);
+ ResourceErrorOr<CachedResourceHandle<CachedRawResource>> requestRawResource(CachedResourceRequest&&);
+ ResourceErrorOr<CachedResourceHandle<CachedRawResource>> requestMainResource(CachedResourceRequest&&);
+ ResourceErrorOr<CachedResourceHandle<CachedSVGDocument>> requestSVGDocument(CachedResourceRequest&&);
#if ENABLE(XSLT)
- CachedResourceHandle<CachedXSLStyleSheet> requestXSLStyleSheet(CachedResourceRequest&&, ResourceError* = nullptr);
+ ResourceErrorOr<CachedResourceHandle<CachedXSLStyleSheet>> requestXSLStyleSheet(CachedResourceRequest&&);
#endif
#if ENABLE(LINK_PREFETCH)
- CachedResourceHandle<CachedResource> requestLinkResource(CachedResource::Type, CachedResourceRequest&&, ResourceError* = nullptr);
+ ResourceErrorOr<CachedResourceHandle<CachedResource>> requestLinkResource(CachedResource::Type, CachedResourceRequest&&);
#endif
#if ENABLE(VIDEO_TRACK)
- CachedResourceHandle<CachedTextTrack> requestTextTrack(CachedResourceRequest&&, ResourceError* = nullptr);
+ ResourceErrorOr<CachedResourceHandle<CachedTextTrack>> requestTextTrack(CachedResourceRequest&&);
#endif
// Logs an access denied message to the console for the specified URL.
@@ -132,7 +136,7 @@
WEBCORE_EXPORT bool isPreloaded(const String& urlString) const;
enum class ClearPreloadsMode { ClearSpeculativePreloads, ClearAllPreloads };
void clearPreloads(ClearPreloadsMode);
- CachedResourceHandle<CachedResource> preload(CachedResource::Type, CachedResourceRequest&&);
+ ResourceErrorOr<CachedResourceHandle<CachedResource>> preload(CachedResource::Type, CachedResourceRequest&&);
void printPreloadStats();
void warnUnusedPreloads();
void stopUnusedPreloadsTimer();
@@ -155,7 +159,7 @@
enum class ForPreload { Yes, No };
enum class DeferOption { NoDefer, DeferredByClient };
- CachedResourceHandle<CachedResource> requestResource(CachedResource::Type, CachedResourceRequest&&, ResourceError* = nullptr, ForPreload = ForPreload::No, DeferOption = DeferOption::NoDefer);
+ ResourceErrorOr<CachedResourceHandle<CachedResource>> requestResource(CachedResource::Type, CachedResourceRequest&&, ForPreload = ForPreload::No, DeferOption = DeferOption::NoDefer);
CachedResourceHandle<CachedResource> revalidateResource(CachedResourceRequest&&, CachedResource&);
CachedResourceHandle<CachedResource> loadResource(CachedResource::Type, CachedResourceRequest&&);
@@ -171,7 +175,7 @@
bool shouldUpdateCachedResourceWithCurrentRequest(const CachedResource&, const CachedResourceRequest&);
CachedResourceHandle<CachedResource> updateCachedResourceWithCurrentRequest(const CachedResource&, CachedResourceRequest&&);
- bool shouldContinueAfterNotifyingLoadedFromMemoryCache(const CachedResourceRequest&, CachedResource*);
+ bool shouldContinueAfterNotifyingLoadedFromMemoryCache(const CachedResourceRequest&, CachedResource&, ResourceError&);
bool checkInsecureContent(CachedResource::Type, const URL&) const;
bool allowedByContentSecurityPolicy(CachedResource::Type, const URL&, const ResourceLoaderOptions&, ContentSecurityPolicy::RedirectResponseReceived) const;
Modified: trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.cpp (220759 => 220760)
--- trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/loader/cache/CachedSVGDocumentReference.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -56,7 +56,7 @@
fetchOptions.mode = FetchOptions::Mode::SameOrigin;
CachedResourceRequest request(ResourceRequest(loader.document()->completeURL(m_url)), fetchOptions);
request.setInitiator(cachedResourceRequestInitiators().css);
- m_document = loader.requestSVGDocument(WTFMove(request));
+ m_document = loader.requestSVGDocument(WTFMove(request)).valueOr(nullptr);
if (m_document)
m_document->addClient(*this);
Modified: trunk/Source/WebCore/loader/icon/IconLoader.cpp (220759 => 220760)
--- trunk/Source/WebCore/loader/icon/IconLoader.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/loader/icon/IconLoader.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -75,11 +75,12 @@
request.setInitiator(cachedResourceRequestInitiators().icon);
- m_resource = frame->document()->cachedResourceLoader().requestIcon(WTFMove(request));
+ auto cachedResource = frame->document()->cachedResourceLoader().requestIcon(WTFMove(request));
+ m_resource = cachedResource.valueOr(nullptr);
if (m_resource)
m_resource->addClient(*this);
else
- LOG_ERROR("Failed to start load for icon at url %s", resourceRequestURL.string().ascii().data());
+ LOG_ERROR("Failed to start load for icon at url %s (error: %s)", resourceRequestURL.string().ascii().data(), cachedResource.error().localizedDescription().utf8().data());
}
void IconLoader::stopLoading()
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp (220759 => 220760)
--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -77,7 +77,7 @@
CachedResourceRequest request(WTFMove(resourceRequest), ResourceLoaderOptions(SendCallbacks, DoNotSniffContent, BufferData, DoNotAllowStoredCredentials, ClientCredentialPolicy::CannotAskClientForCredentials, FetchOptions::Credentials::Omit, DoSecurityCheck, FetchOptions::Mode::NoCors, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading, CachingPolicy::DisallowCaching));
CachedResourceLoader* loader = m_parent->player()->cachedResourceLoader();
- m_resource = loader ? loader->requestRawResource(WTFMove(request)) : 0;
+ m_resource = loader ? loader->requestRawResource(WTFMove(request)).valueOr(nullptr) : nullptr;
if (m_resource)
m_resource->addClient(*this);
else {
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm (220759 => 220760)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm 2017-08-15 21:15:09 UTC (rev 220760)
@@ -74,7 +74,7 @@
// is in a user-agent shadow tree. See <https://bugs.webkit.org/show_bug.cgi?id=173498>.
CachedResourceRequest request(WTFMove(resourceRequest), ResourceLoaderOptions(SendCallbacks, DoNotSniffContent, BufferData, DoNotAllowStoredCredentials, ClientCredentialPolicy::CannotAskClientForCredentials, FetchOptions::Credentials::Omit, DoSecurityCheck, FetchOptions::Mode::NoCors, DoNotIncludeCertificateInfo, ContentSecurityPolicyImposition::DoPolicyCheck, DefersLoadingPolicy::AllowDefersLoading, CachingPolicy::DisallowCaching));
if (auto* loader = m_parent->player()->cachedResourceLoader())
- m_resource = loader->requestMedia(WTFMove(request));
+ m_resource = loader->requestMedia(WTFMove(request)).valueOr(nullptr);
if (m_resource)
m_resource->addClient(*this);
Modified: trunk/Source/WebCore/svg/SVGFEImageElement.cpp (220759 => 220760)
--- trunk/Source/WebCore/svg/SVGFEImageElement.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/svg/SVGFEImageElement.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -89,7 +89,7 @@
CachedResourceRequest request(ResourceRequest(document().completeURL(href())), options);
request.setInitiator(*this);
- m_cachedImage = document().cachedResourceLoader().requestImage(WTFMove(request));
+ m_cachedImage = document().cachedResourceLoader().requestImage(WTFMove(request)).valueOr(nullptr);
if (m_cachedImage)
m_cachedImage->addClient(*this);
Modified: trunk/Source/WebCore/svg/SVGFontFaceUriElement.cpp (220759 => 220760)
--- trunk/Source/WebCore/svg/SVGFontFaceUriElement.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/svg/SVGFontFaceUriElement.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -106,7 +106,7 @@
CachedResourceLoader& cachedResourceLoader = document().cachedResourceLoader();
CachedResourceRequest request(ResourceRequest(document().completeURL(href)), options);
request.setInitiator(*this);
- m_cachedFont = cachedResourceLoader.requestFont(WTFMove(request), isSVGFontTarget(*this));
+ m_cachedFont = cachedResourceLoader.requestFont(WTFMove(request), isSVGFontTarget(*this)).valueOr(nullptr);
if (m_cachedFont) {
m_cachedFont->addClient(*this);
m_cachedFont->beginLoadIfNeeded(cachedResourceLoader);
Modified: trunk/Source/WebCore/svg/SVGUseElement.cpp (220759 => 220760)
--- trunk/Source/WebCore/svg/SVGUseElement.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/svg/SVGUseElement.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -574,7 +574,7 @@
options.mode = FetchOptions::Mode::SameOrigin;
CachedResourceRequest request { ResourceRequest { externalDocumentURL }, options };
request.setInitiator(*this);
- m_externalDocument = document().cachedResourceLoader().requestSVGDocument(WTFMove(request));
+ m_externalDocument = document().cachedResourceLoader().requestSVGDocument(WTFMove(request)).valueOr(nullptr);
if (m_externalDocument)
m_externalDocument->addClient(*this);
}
Modified: trunk/Source/WebCore/xml/XSLImportRule.cpp (220759 => 220760)
--- trunk/Source/WebCore/xml/XSLImportRule.cpp 2017-08-15 21:08:21 UTC (rev 220759)
+++ trunk/Source/WebCore/xml/XSLImportRule.cpp 2017-08-15 21:15:09 UTC (rev 220760)
@@ -103,7 +103,7 @@
auto options = CachedResourceLoader::defaultCachedResourceOptions();
options.mode = FetchOptions::Mode::SameOrigin;
- m_cachedSheet = cachedResourceLoader->requestXSLStyleSheet({ResourceRequest(cachedResourceLoader->document()->completeURL(absHref)), options});
+ m_cachedSheet = cachedResourceLoader->requestXSLStyleSheet({ResourceRequest(cachedResourceLoader->document()->completeURL(absHref)), options}).valueOr(nullptr);
if (m_cachedSheet) {
m_cachedSheet->addClient(*this);