summaryrefslogtreecommitdiff
path: root/Source/WebCore/loader/LinkLoader.cpp
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebCore/loader/LinkLoader.cpp
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
downloadqtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/loader/LinkLoader.cpp')
-rw-r--r--Source/WebCore/loader/LinkLoader.cpp65
1 files changed, 30 insertions, 35 deletions
diff --git a/Source/WebCore/loader/LinkLoader.cpp b/Source/WebCore/loader/LinkLoader.cpp
index b9bccd9b2..f69e26edf 100644
--- a/Source/WebCore/loader/LinkLoader.cpp
+++ b/Source/WebCore/loader/LinkLoader.cpp
@@ -37,9 +37,9 @@
#include "CachedResourceLoader.h"
#include "CachedResourceRequest.h"
#include "ContainerNode.h"
-#include "DNS.h"
#include "Document.h"
#include "Frame.h"
+#include "FrameLoaderClient.h"
#include "FrameView.h"
#include "LinkRelAttribute.h"
#include "Settings.h"
@@ -47,10 +47,10 @@
namespace WebCore {
-LinkLoader::LinkLoader(LinkLoaderClient* client)
+LinkLoader::LinkLoader(LinkLoaderClient& client)
: m_client(client)
- , m_linkLoadTimer(this, &LinkLoader::linkLoadTimerFired)
- , m_linkLoadingErrorTimer(this, &LinkLoader::linkLoadingErrorTimerFired)
+ , m_linkLoadTimer(*this, &LinkLoader::linkLoadTimerFired)
+ , m_linkLoadingErrorTimer(*this, &LinkLoader::linkLoadingErrorTimerFired)
{
}
@@ -60,16 +60,14 @@ LinkLoader::~LinkLoader()
m_cachedLinkResource->removeClient(this);
}
-void LinkLoader::linkLoadTimerFired(Timer<LinkLoader>* timer)
+void LinkLoader::linkLoadTimerFired()
{
- ASSERT_UNUSED(timer, timer == &m_linkLoadTimer);
- m_client->linkLoaded();
+ m_client.linkLoaded();
}
-void LinkLoader::linkLoadingErrorTimerFired(Timer<LinkLoader>* timer)
+void LinkLoader::linkLoadingErrorTimerFired()
{
- ASSERT_UNUSED(timer, timer == &m_linkLoadingErrorTimer);
- m_client->linkLoadingErrored();
+ m_client.linkLoadingErrored();
}
void LinkLoader::notifyFinished(CachedResource* resource)
@@ -82,46 +80,47 @@ void LinkLoader::notifyFinished(CachedResource* resource)
m_linkLoadTimer.startOneShot(0);
m_cachedLinkResource->removeClient(this);
- m_cachedLinkResource = 0;
+ m_cachedLinkResource = nullptr;
}
-bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const String& type,
- const String& sizes, const KURL& href, Document* document)
+bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const URL& href, Document& document)
{
// We'll record this URL per document, even if we later only use it in top level frames
- if (relAttribute.m_iconType != InvalidIcon && href.isValid() && !href.isEmpty()) {
- if (!m_client->shouldLoadLink())
+ if (relAttribute.iconType != InvalidIcon && href.isValid() && !href.isEmpty()) {
+ if (!m_client.shouldLoadLink())
return false;
- document->addIconURL(href.string(), type, sizes, relAttribute.m_iconType);
+ if (Frame* frame = document.frame())
+ frame->loader().client().dispatchDidChangeIcons(relAttribute.iconType);
}
- if (relAttribute.m_isDNSPrefetch) {
- Settings* settings = document->settings();
+ if (relAttribute.isDNSPrefetch) {
+ Settings* settings = document.settings();
// FIXME: The href attribute of the link element can be in "//hostname" form, and we shouldn't attempt
// to complete that as URL <https://bugs.webkit.org/show_bug.cgi?id=48857>.
- if (settings && settings->dnsPrefetchingEnabled() && href.isValid() && !href.isEmpty())
- prefetchDNS(href.host());
+ if (settings && settings->dnsPrefetchingEnabled() && href.isValid() && !href.isEmpty() && document.frame())
+ document.frame()->loader().client().prefetchDNS(href.host());
}
#if ENABLE(LINK_PREFETCH)
- if ((relAttribute.m_isLinkPrefetch || relAttribute.m_isLinkSubresource) && href.isValid() && document->frame()) {
- if (!m_client->shouldLoadLink())
+ if ((relAttribute.isLinkPrefetch || relAttribute.isLinkSubresource) && href.isValid() && document.frame()) {
+ if (!m_client.shouldLoadLink())
return false;
- ResourceLoadPriority priority = ResourceLoadPriorityUnresolved;
+
+ Optional<ResourceLoadPriority> priority;
CachedResource::Type type = CachedResource::LinkPrefetch;
- // We only make one request to the cachedresourcelodaer if multiple rel types are
- // specified,
- if (relAttribute.m_isLinkSubresource) {
- priority = ResourceLoadPriorityLow;
+ if (relAttribute.isLinkSubresource) {
+ // We only make one request to the cached resource loader if multiple rel types are specified;
+ // this is the higher priority, which should overwrite the lower priority.
+ priority = ResourceLoadPriority::Low;
type = CachedResource::LinkSubresource;
}
- CachedResourceRequest linkRequest(ResourceRequest(document->completeURL(href)), priority);
-
+ CachedResourceRequest linkRequest(ResourceRequest(document.completeURL(href)), priority);
+
if (m_cachedLinkResource) {
m_cachedLinkResource->removeClient(this);
- m_cachedLinkResource = 0;
+ m_cachedLinkResource = nullptr;
}
- m_cachedLinkResource = document->cachedResourceLoader()->requestLinkResource(type, linkRequest);
+ m_cachedLinkResource = document.cachedResourceLoader().requestLinkResource(type, linkRequest);
if (m_cachedLinkResource)
m_cachedLinkResource->addClient(this);
}
@@ -130,8 +129,4 @@ bool LinkLoader::loadLink(const LinkRelAttribute& relAttribute, const String& ty
return true;
}
-void LinkLoader::released()
-{
-}
-
}