Modified: trunk/Source/WebCore/loader/LinkLoader.cpp (226961 => 226962)
--- trunk/Source/WebCore/loader/LinkLoader.cpp 2018-01-16 02:44:14 UTC (rev 226961)
+++ trunk/Source/WebCore/loader/LinkLoader.cpp 2018-01-16 06:44:41 UTC (rev 226962)
@@ -110,7 +110,8 @@
// Sanity check to avoid re-entrancy here.
if (equalIgnoringFragmentIdentifier(url, baseURL))
continue;
- preloadIfNeeded(relAttribute, url, document, header.as(), header.media(), header.mimeType(), header.crossOrigin(), nullptr);
+ preconnect(relAttribute, url, document, header.crossOrigin());
+ preload(relAttribute, url, document, header.as(), header.media(), header.mimeType(), header.crossOrigin(), nullptr);
}
}
@@ -211,8 +212,28 @@
return false;
}
-std::unique_ptr<LinkPreloadResourceClient> LinkLoader::preloadIfNeeded(const LinkRelAttribute& relAttribute, const URL& href, Document& document, const String& as, const String& media, const String& mimeType, const String& crossOriginMode, LinkLoader* loader)
+void LinkLoader::preconnect(const LinkRelAttribute& relAttribute, const URL& href, Document& document, const String& crossOrigin)
{
+ if (!relAttribute.isLinkPreconnect || !href.isValid() || !href.protocolIsInHTTPFamily() || !document.frame())
+ return;
+ ASSERT(document.settings().linkPreconnectEnabled());
+ StoredCredentialsPolicy storageCredentialsPolicy = StoredCredentialsPolicy::Use;
+ if (equalIgnoringASCIICase(crossOrigin, "anonymous") && document.securityOrigin().canAccess(SecurityOrigin::create(href)))
+ storageCredentialsPolicy = StoredCredentialsPolicy::DoNotUse;
+ ASSERT(document.frame()->loader().networkingContext());
+ platformStrategies()->loaderStrategy()->preconnectTo(*document.frame()->loader().networkingContext(), href, storageCredentialsPolicy, [weakDocument = document.createWeakPtr(), href](ResourceError error) {
+ if (!weakDocument)
+ return;
+
+ if (!error.isNull())
+ weakDocument->addConsoleMessage(MessageSource::Network, MessageLevel::Error, makeString(ASCIILiteral("Failed to preconnect to "), href.string(), ASCIILiteral(". Error: "), error.localizedDescription()));
+ else
+ weakDocument->addConsoleMessage(MessageSource::Network, MessageLevel::Info, makeString(ASCIILiteral("Successfuly preconnected to "), href.string()));
+ });
+}
+
+std::unique_ptr<LinkPreloadResourceClient> LinkLoader::preload(const LinkRelAttribute& relAttribute, const URL& href, Document& document, const String& as, const String& media, const String& mimeType, const String& crossOriginMode, LinkLoader* loader)
+{
if (!document.loader() || !relAttribute.isLinkPreload)
return nullptr;
@@ -259,25 +280,10 @@
document.frame()->loader().client().prefetchDNS(href.host());
}
- if (relAttribute.isLinkPreconnect && href.isValid() && href.protocolIsInHTTPFamily() && document.frame()) {
- ASSERT(document.settings().linkPreconnectEnabled());
- StoredCredentialsPolicy storageCredentialsPolicy = StoredCredentialsPolicy::Use;
- if (equalIgnoringASCIICase(crossOrigin, "anonymous") && document.securityOrigin().canAccess(SecurityOrigin::create(href)))
- storageCredentialsPolicy = StoredCredentialsPolicy::DoNotUse;
- ASSERT(document.frame()->loader().networkingContext());
- platformStrategies()->loaderStrategy()->preconnectTo(*document.frame()->loader().networkingContext(), href, storageCredentialsPolicy, [weakDocument = document.createWeakPtr(), href](ResourceError error) {
- if (!weakDocument)
- return;
+ preconnect(relAttribute, href, document, crossOrigin);
- if (!error.isNull())
- weakDocument->addConsoleMessage(MessageSource::Network, MessageLevel::Error, makeString(ASCIILiteral("Failed to preconnect to "), href.string(), ASCIILiteral(". Error: "), error.localizedDescription()));
- else
- weakDocument->addConsoleMessage(MessageSource::Network, MessageLevel::Info, makeString(ASCIILiteral("Successfuly preconnected to "), href.string()));
- });
- }
-
if (m_client.shouldLoadLink()) {
- auto resourceClient = preloadIfNeeded(relAttribute, href, document, as, media, mimeType, crossOrigin, this);
+ auto resourceClient = preload(relAttribute, href, document, as, media, mimeType, crossOrigin, this);
if (resourceClient)
m_preloadResourceClient = WTFMove(resourceClient);
else if (m_preloadResourceClient)
Modified: trunk/Source/WebCore/loader/LinkLoader.h (226961 => 226962)
--- trunk/Source/WebCore/loader/LinkLoader.h 2018-01-16 02:44:14 UTC (rev 226961)
+++ trunk/Source/WebCore/loader/LinkLoader.h 2018-01-16 06:44:41 UTC (rev 226962)
@@ -64,7 +64,8 @@
private:
void notifyFinished(CachedResource&) override;
- static std::unique_ptr<LinkPreloadResourceClient> preloadIfNeeded(const LinkRelAttribute&, const URL& href, Document&, const String& as, const String& media, const String& type, const String& crossOriginMode, LinkLoader*);
+ static void preconnect(const LinkRelAttribute&, const URL& href, Document&, const String& crossOrigin);
+ static std::unique_ptr<LinkPreloadResourceClient> preload(const LinkRelAttribute&, const URL& href, Document&, const String& as, const String& media, const String& type, const String& crossOriginMode, LinkLoader*);
LinkLoaderClient& m_client;
CachedResourceHandle<CachedResource> m_cachedLinkResource;