Skip to content
Permalink
Browse files
Use downcast in createLinkPreloadResourceClient
https://bugs.webkit.org/show_bug.cgi?id=182488

Patch by Youenn Fablet <youenn@apple.com> on 2018-02-06
Reviewed by Antti Koivisto.

No observable change of behavior.
Add a new link preloader client for text track.

* loader/LinkLoader.cpp:
(WebCore::createLinkPreloadResourceClient):
* loader/LinkPreloadResourceClients.h:

Canonical link: https://commits.webkit.org/198351@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228201 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
youennf authored and webkit-commit-queue committed Feb 7, 2018
1 parent bd48331 commit 628be865acab44b0a19b2f46c5db5db1a8291f0b
Showing with 34 additions and 14 deletions.
  1. +14 −0 Source/WebCore/ChangeLog
  2. +9 −9 Source/WebCore/loader/LinkLoader.cpp
  3. +11 −5 Source/WebCore/loader/LinkPreloadResourceClients.h
@@ -1,3 +1,17 @@
2018-02-06 Youenn Fablet <youenn@apple.com>

Use downcast in createLinkPreloadResourceClient
https://bugs.webkit.org/show_bug.cgi?id=182488

Reviewed by Antti Koivisto.

No observable change of behavior.
Add a new link preloader client for text track.

* loader/LinkLoader.cpp:
(WebCore::createLinkPreloadResourceClient):
* loader/LinkPreloadResourceClients.h:

2018-02-06 Youenn Fablet <youenn@apple.com>

imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-respond-with-response-body-with-invalid-chunk.https.html is flaky
@@ -139,22 +139,22 @@ static std::unique_ptr<LinkPreloadResourceClient> createLinkPreloadResourceClien
{
switch (resource.type()) {
case CachedResource::ImageResource:
return LinkPreloadImageResourceClient::create(loader, static_cast<CachedImage&>(resource));
return LinkPreloadImageResourceClient::create(loader, downcast<CachedImage>(resource));
case CachedResource::Script:
return LinkPreloadScriptResourceClient::create(loader, static_cast<CachedScript&>(resource));
return LinkPreloadDefaultResourceClient::create(loader, downcast<CachedScript>(resource));
case CachedResource::CSSStyleSheet:
return LinkPreloadStyleResourceClient::create(loader, static_cast<CachedCSSStyleSheet&>(resource));
return LinkPreloadStyleResourceClient::create(loader, downcast<CachedCSSStyleSheet>(resource));
case CachedResource::FontResource:
return LinkPreloadFontResourceClient::create(loader, static_cast<CachedFont&>(resource));
case CachedResource::MediaResource:
if (!RuntimeEnabledFeatures::sharedFeatures().mediaPreloadingEnabled())
ASSERT_NOT_REACHED();
FALLTHROUGH;
return LinkPreloadFontResourceClient::create(loader, downcast<CachedFont>(resource));
#if ENABLE(VIDEO_TRACK)
case CachedResource::TextTrackResource:
return LinkPreloadDefaultResourceClient::create(loader, downcast<CachedTextTrack>(resource));
#endif
case CachedResource::MediaResource:
ASSERT(RuntimeEnabledFeatures::sharedFeatures().mediaPreloadingEnabled());
FALLTHROUGH;
case CachedResource::RawResource:
return LinkPreloadRawResourceClient::create(loader, static_cast<CachedRawResource&>(resource));
return LinkPreloadRawResourceClient::create(loader, downcast<CachedRawResource>(resource));
case CachedResource::MainResource:
case CachedResource::Icon:
#if ENABLE(SVG_FONTS)
@@ -36,6 +36,7 @@
#include "CachedResourceHandle.h"
#include "CachedScript.h"
#include "CachedStyleSheetClient.h"
#include "CachedTextTrack.h"

#include <wtf/WeakPtr.h>

@@ -76,14 +77,19 @@ class LinkPreloadResourceClient {
CachedResourceHandle<CachedResource> m_resource;
};

class LinkPreloadScriptResourceClient: public LinkPreloadResourceClient, CachedResourceClient {
class LinkPreloadDefaultResourceClient: public LinkPreloadResourceClient, CachedResourceClient {
public:
static std::unique_ptr<LinkPreloadScriptResourceClient> create(LinkLoader& loader, CachedScript& resource)
static std::unique_ptr<LinkPreloadDefaultResourceClient> create(LinkLoader& loader, CachedScript& resource)
{
return std::unique_ptr<LinkPreloadScriptResourceClient>(new LinkPreloadScriptResourceClient(loader, resource));
return std::unique_ptr<LinkPreloadDefaultResourceClient>(new LinkPreloadDefaultResourceClient(loader, resource));
}

virtual ~LinkPreloadScriptResourceClient() = default;
static std::unique_ptr<LinkPreloadDefaultResourceClient> create(LinkLoader& loader, CachedTextTrack& resource)
{
return std::unique_ptr<LinkPreloadDefaultResourceClient>(new LinkPreloadDefaultResourceClient(loader, resource));
}

virtual ~LinkPreloadDefaultResourceClient() = default;


void notifyFinished(CachedResource& resource) override { triggerEvents(resource); }
@@ -92,7 +98,7 @@ class LinkPreloadScriptResourceClient: public LinkPreloadResourceClient, CachedR
bool shouldMarkAsReferenced() const override { return false; }

private:
LinkPreloadScriptResourceClient(LinkLoader& loader, CachedScript& resource)
LinkPreloadDefaultResourceClient(LinkLoader& loader, CachedResource& resource)
: LinkPreloadResourceClient(loader, resource)
{
addResource(*this);

0 comments on commit 628be86

Please sign in to comment.