diff options
Diffstat (limited to 'Source/WebCore/loader/LinkLoader.h')
-rw-r--r-- | Source/WebCore/loader/LinkLoader.h | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/Source/WebCore/loader/LinkLoader.h b/Source/WebCore/loader/LinkLoader.h index 9b5d8cb76..9c714729d 100644 --- a/Source/WebCore/loader/LinkLoader.h +++ b/Source/WebCore/loader/LinkLoader.h @@ -29,46 +29,44 @@ * */ -#ifndef LinkLoader_h -#define LinkLoader_h +#pragma once +#include "CachedResource.h" #include "CachedResourceClient.h" #include "CachedResourceHandle.h" #include "LinkLoaderClient.h" -#include "Timer.h" -#include <wtf/RefPtr.h> +#include <wtf/WeakPtr.h> namespace WebCore { class Document; class URL; -struct LinkRelAttribute; +class LinkPreloadResourceClient; -// The LinkLoader can load link rel types icon, dns-prefetch, subresource and prefetch. -class LinkLoader : public CachedResourceClient { +struct LinkRelAttribute; +class LinkLoader : private CachedResourceClient { public: - explicit LinkLoader(LinkLoaderClient*); + explicit LinkLoader(LinkLoaderClient&); virtual ~LinkLoader(); - // from CachedResourceClient - virtual void notifyFinished(CachedResource*); + bool loadLink(const LinkRelAttribute&, const URL&, const String& as, const String& crossOrigin, Document&); + static std::optional<CachedResource::Type> resourceTypeFromAsAttribute(const String& as); + static void loadLinksFromHeader(const String& headerValue, const URL& baseURL, Document&); - void released(); - bool loadLink(const LinkRelAttribute&, const String& type, const String& sizes, const URL&, Document*); + WeakPtr<LinkLoader> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(); } + void triggerEvents(const CachedResource&); + void cancelLoad(); private: - void linkLoadTimerFired(Timer<LinkLoader>&); - void linkLoadingErrorTimerFired(Timer<LinkLoader>&); - - LinkLoaderClient* m_client; + void notifyFinished(CachedResource&) override; + static std::unique_ptr<LinkPreloadResourceClient> preloadIfNeeded(const LinkRelAttribute&, const URL& href, Document&, const String& as, const String& crossOriginMode, LinkLoader*, LinkLoaderClient*); + LinkLoaderClient& m_client; CachedResourceHandle<CachedResource> m_cachedLinkResource; - Timer<LinkLoader> m_linkLoadTimer; - Timer<LinkLoader> m_linkLoadingErrorTimer; + std::unique_ptr<LinkPreloadResourceClient> m_preloadResourceClient; + WeakPtrFactory<LinkLoader> m_weakPtrFactory; }; - -} -#endif +} |