Title: [228201] trunk/Source/WebCore
Revision
228201
Author
commit-qu...@webkit.org
Date
2018-02-06 16:32:24 -0800 (Tue, 06 Feb 2018)

Log Message

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

Patch by Youenn Fablet <you...@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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228200 => 228201)


--- trunk/Source/WebCore/ChangeLog	2018-02-07 00:29:30 UTC (rev 228200)
+++ trunk/Source/WebCore/ChangeLog	2018-02-07 00:32:24 UTC (rev 228201)
@@ -1,5 +1,19 @@
 2018-02-06  Youenn Fablet  <you...@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  <you...@apple.com>
+
         imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-respond-with-response-body-with-invalid-chunk.https.html is flaky
         https://bugs.webkit.org/show_bug.cgi?id=182541
 

Modified: trunk/Source/WebCore/loader/LinkLoader.cpp (228200 => 228201)


--- trunk/Source/WebCore/loader/LinkLoader.cpp	2018-02-07 00:29:30 UTC (rev 228200)
+++ trunk/Source/WebCore/loader/LinkLoader.cpp	2018-02-07 00:32:24 UTC (rev 228201)
@@ -139,22 +139,22 @@
 {
     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)

Modified: trunk/Source/WebCore/loader/LinkPreloadResourceClients.h (228200 => 228201)


--- trunk/Source/WebCore/loader/LinkPreloadResourceClients.h	2018-02-07 00:29:30 UTC (rev 228200)
+++ trunk/Source/WebCore/loader/LinkPreloadResourceClients.h	2018-02-07 00:32:24 UTC (rev 228201)
@@ -36,6 +36,7 @@
 #include "CachedResourceHandle.h"
 #include "CachedScript.h"
 #include "CachedStyleSheetClient.h"
+#include "CachedTextTrack.h"
 
 #include <wtf/WeakPtr.h>
 
@@ -76,16 +77,21 @@
     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); }
 
     void clear() override { clearResource(*this); }
@@ -92,7 +98,7 @@
     bool shouldMarkAsReferenced() const override { return false; }
 
 private:
-    LinkPreloadScriptResourceClient(LinkLoader& loader, CachedScript& resource)
+    LinkPreloadDefaultResourceClient(LinkLoader& loader, CachedResource& resource)
         : LinkPreloadResourceClient(loader, resource)
     {
         addResource(*this);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to