Title: [221495] trunk/Source/WebCore
Revision
221495
Author
beid...@apple.com
Date
2017-09-01 14:33:02 -0700 (Fri, 01 Sep 2017)

Log Message

Move ServiceWorkerJob from FetchLoader to ThreadableLoader.
https://bugs.webkit.org/show_bug.cgi?id=176231

Reviewed by Youenn Fablet.

No new tests (No behavior change).

* WebCore.xcodeproj/project.pbxproj:

Re-indent these headers. Yuck!
* loader/ThreadableLoader.h:
(WebCore::ThreadableLoader::ref):
(WebCore::ThreadableLoader::deref):
(WebCore::ThreadableLoader::ThreadableLoader):
(WebCore::ThreadableLoader::~ThreadableLoader):
* loader/ThreadableLoaderClient.h:
(WebCore::ThreadableLoaderClient::didSendData):
(WebCore::ThreadableLoaderClient::didReceiveResponse):
(WebCore::ThreadableLoaderClient::didReceiveData):
(WebCore::ThreadableLoaderClient::didFinishLoading):
(WebCore::ThreadableLoaderClient::didFail):
(WebCore::ThreadableLoaderClient::didFinishTiming):
(WebCore::ThreadableLoaderClient::ThreadableLoaderClient):
(WebCore::ThreadableLoaderClient::~ThreadableLoaderClient):

Move from FetchLoaderClient to ThreadableLoaderClient:
* workers/service/ServiceWorkerJob.cpp:
(WebCore::ServiceWorkerJob::fetchScriptWithContext):
(WebCore::ServiceWorkerJob::didReceiveResponse):
(WebCore::ServiceWorkerJob::didReceiveData):
(WebCore::ServiceWorkerJob::didFinishLoading):
(WebCore::ServiceWorkerJob::didFail):
(WebCore::ServiceWorkerJob::didSucceed): Deleted.
* workers/service/ServiceWorkerJob.h:

* workers/service/server/SWClientConnection.cpp: Add a now-required include.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (221494 => 221495)


--- trunk/Source/WebCore/ChangeLog	2017-09-01 20:40:11 UTC (rev 221494)
+++ trunk/Source/WebCore/ChangeLog	2017-09-01 21:33:02 UTC (rev 221495)
@@ -1,3 +1,42 @@
+2017-09-01  Brady Eidson  <beid...@apple.com>
+
+        Move ServiceWorkerJob from FetchLoader to ThreadableLoader.
+        https://bugs.webkit.org/show_bug.cgi?id=176231
+
+        Reviewed by Youenn Fablet.
+
+        No new tests (No behavior change).
+
+        * WebCore.xcodeproj/project.pbxproj:
+
+        Re-indent these headers. Yuck!
+        * loader/ThreadableLoader.h:
+        (WebCore::ThreadableLoader::ref):
+        (WebCore::ThreadableLoader::deref):
+        (WebCore::ThreadableLoader::ThreadableLoader):
+        (WebCore::ThreadableLoader::~ThreadableLoader):
+        * loader/ThreadableLoaderClient.h:
+        (WebCore::ThreadableLoaderClient::didSendData):
+        (WebCore::ThreadableLoaderClient::didReceiveResponse):
+        (WebCore::ThreadableLoaderClient::didReceiveData):
+        (WebCore::ThreadableLoaderClient::didFinishLoading):
+        (WebCore::ThreadableLoaderClient::didFail):
+        (WebCore::ThreadableLoaderClient::didFinishTiming):
+        (WebCore::ThreadableLoaderClient::ThreadableLoaderClient):
+        (WebCore::ThreadableLoaderClient::~ThreadableLoaderClient):
+
+        Move from FetchLoaderClient to ThreadableLoaderClient:
+        * workers/service/ServiceWorkerJob.cpp:
+        (WebCore::ServiceWorkerJob::fetchScriptWithContext):
+        (WebCore::ServiceWorkerJob::didReceiveResponse):
+        (WebCore::ServiceWorkerJob::didReceiveData):
+        (WebCore::ServiceWorkerJob::didFinishLoading):
+        (WebCore::ServiceWorkerJob::didFail):
+        (WebCore::ServiceWorkerJob::didSucceed): Deleted.
+        * workers/service/ServiceWorkerJob.h:
+
+        * workers/service/server/SWClientConnection.cpp: Add a now-required include.
+
 2017-09-01  Eric Carlson  <eric.carl...@apple.com>
 
         Switch HTMLMediaElement to release logging

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (221494 => 221495)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-09-01 20:40:11 UTC (rev 221494)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-09-01 21:33:02 UTC (rev 221495)
@@ -2305,8 +2305,8 @@
 		517A53461F50C17F00DCDC0A /* SWServerWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A53421F50C16100DCDC0A /* SWServerWorker.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		517A534E1F54A8BA00DCDC0A /* ServiceWorkerRegistrationData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A534B1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.cpp */; };
 		517A534F1F54A8BA00DCDC0A /* ServiceWorkerRegistrationData.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A534C1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		517A53581F5889E800DCDC0A /* FetchLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4147E2B61C89912600A7E715 /* FetchLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		517A535A1F5889EF00DCDC0A /* FetchLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 4147E2B51C89912600A7E715 /* FetchLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		517A53581F5889E800DCDC0A /* FetchLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4147E2B61C89912600A7E715 /* FetchLoaderClient.h */; };
+		517A535A1F5889EF00DCDC0A /* FetchLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 4147E2B51C89912600A7E715 /* FetchLoader.h */; };
 		517A535B1F588A4C00DCDC0A /* FetchBodyConsumer.h in Headers */ = {isa = PBXBuildFile; fileRef = 41CF8BE51D46222000707DC9 /* FetchBodyConsumer.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		517A63C31B74318700E7DCDC /* KeyedDecoderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A63BF1B74317E00E7DCDC /* KeyedDecoderCF.cpp */; };
@@ -11446,8 +11446,8 @@
 		7CBA5BA61F0B4BDE0034D745 /* JSDOMConvertWebGL.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMConvertWebGL.cpp; sourceTree = "<group>"; };
 		7CBBBCC41F560567005EFAAC /* DOMMatrix2DInit.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = DOMMatrix2DInit.idl; sourceTree = "<group>"; };
 		7CBBBCC61F560568005EFAAC /* DOMMatrix2DInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMMatrix2DInit.h; sourceTree = "<group>"; };
-		7CBBBCC81F5617C0005EFAAC /* JSDOMMatrix2DInit.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = JSDOMMatrix2DInit.cpp; path = JSDOMMatrix2DInit.cpp; sourceTree = "<group>"; };
-		7CBBBCC91F5617C0005EFAAC /* JSDOMMatrix2DInit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = JSDOMMatrix2DInit.h; path = JSDOMMatrix2DInit.h; sourceTree = "<group>"; };
+		7CBBBCC81F5617C0005EFAAC /* JSDOMMatrix2DInit.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMMatrix2DInit.cpp; sourceTree = "<group>"; };
+		7CBBBCC91F5617C0005EFAAC /* JSDOMMatrix2DInit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSDOMMatrix2DInit.h; sourceTree = "<group>"; };
 		7CC2DDF81EC9415A0027B774 /* NotificationPermission.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NotificationPermission.h; sourceTree = "<group>"; };
 		7CC2DDFA1EC9415A0027B774 /* NotificationPermission.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = NotificationPermission.idl; sourceTree = "<group>"; };
 		7CC2DDFE1EC95A440027B774 /* JSNotificationPermission.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNotificationPermission.cpp; sourceTree = "<group>"; };

Modified: trunk/Source/WebCore/loader/ThreadableLoader.h (221494 => 221495)


--- trunk/Source/WebCore/loader/ThreadableLoader.h	2017-09-01 20:40:11 UTC (rev 221494)
+++ trunk/Source/WebCore/loader/ThreadableLoader.h	2017-09-01 21:33:02 UTC (rev 221495)
@@ -37,62 +37,62 @@
 
 namespace WebCore {
 
-    class ResourceError;
-    class ResourceRequest;
-    class ResourceResponse;
-    class ScriptExecutionContext;
-    class ThreadableLoaderClient;
+class ResourceError;
+class ResourceRequest;
+class ResourceResponse;
+class ScriptExecutionContext;
+class ThreadableLoaderClient;
 
-    enum PreflightPolicy {
-        ConsiderPreflight,
-        ForcePreflight,
-        PreventPreflight
-    };
+enum PreflightPolicy {
+    ConsiderPreflight,
+    ForcePreflight,
+    PreventPreflight
+};
 
-    enum class ContentSecurityPolicyEnforcement {
-        DoNotEnforce,
-        EnforceChildSrcDirective,
-        EnforceConnectSrcDirective,
-        EnforceScriptSrcDirective,
-    };
+enum class ContentSecurityPolicyEnforcement {
+    DoNotEnforce,
+    EnforceChildSrcDirective,
+    EnforceConnectSrcDirective,
+    EnforceScriptSrcDirective,
+};
 
-    enum class ResponseFilteringPolicy {
-        Enable,
-        Disable,
-    };
+enum class ResponseFilteringPolicy {
+    Enable,
+    Disable,
+};
 
-    struct ThreadableLoaderOptions : ResourceLoaderOptions {
-        ThreadableLoaderOptions();
-        ThreadableLoaderOptions(const ResourceLoaderOptions&, PreflightPolicy, ContentSecurityPolicyEnforcement, String&& initiator, ResponseFilteringPolicy);
-        ~ThreadableLoaderOptions();
+struct ThreadableLoaderOptions : ResourceLoaderOptions {
+    ThreadableLoaderOptions();
+    ThreadableLoaderOptions(const ResourceLoaderOptions&, PreflightPolicy, ContentSecurityPolicyEnforcement, String&& initiator, ResponseFilteringPolicy);
+    ~ThreadableLoaderOptions();
 
-        ThreadableLoaderOptions isolatedCopy() const;
+    ThreadableLoaderOptions isolatedCopy() const;
 
-        PreflightPolicy preflightPolicy { ConsiderPreflight };
-        ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement { ContentSecurityPolicyEnforcement::EnforceConnectSrcDirective };
-        String initiator; // This cannot be an AtomicString, as isolatedCopy() wouldn't create an object that's safe for passing to another thread.
-        ResponseFilteringPolicy filteringPolicy { ResponseFilteringPolicy::Disable };
-    };
+    PreflightPolicy preflightPolicy { ConsiderPreflight };
+    ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement { ContentSecurityPolicyEnforcement::EnforceConnectSrcDirective };
+    String initiator; // This cannot be an AtomicString, as isolatedCopy() wouldn't create an object that's safe for passing to another thread.
+    ResponseFilteringPolicy filteringPolicy { ResponseFilteringPolicy::Disable };
+};
 
-    // Useful for doing loader operations from any thread (not threadsafe,
-    // just able to run on threads other than the main thread).
-    class ThreadableLoader {
-        WTF_MAKE_NONCOPYABLE(ThreadableLoader);
-    public:
-        static void loadResourceSynchronously(ScriptExecutionContext&, ResourceRequest&&, ThreadableLoaderClient&, const ThreadableLoaderOptions&);
-        static RefPtr<ThreadableLoader> create(ScriptExecutionContext&, ThreadableLoaderClient&, ResourceRequest&&, const ThreadableLoaderOptions&, String&& referrer = String());
+// Useful for doing loader operations from any thread (not threadsafe,
+// just able to run on threads other than the main thread).
+class ThreadableLoader {
+    WTF_MAKE_NONCOPYABLE(ThreadableLoader);
+public:
+    static void loadResourceSynchronously(ScriptExecutionContext&, ResourceRequest&&, ThreadableLoaderClient&, const ThreadableLoaderOptions&);
+    static RefPtr<ThreadableLoader> create(ScriptExecutionContext&, ThreadableLoaderClient&, ResourceRequest&&, const ThreadableLoaderOptions&, String&& referrer = String());
 
-        virtual void cancel() = 0;
-        void ref() { refThreadableLoader(); }
-        void deref() { derefThreadableLoader(); }
+    virtual void cancel() = 0;
+    void ref() { refThreadableLoader(); }
+    void deref() { derefThreadableLoader(); }
 
-        static void logError(ScriptExecutionContext&, const ResourceError&, const String&);
+    static void logError(ScriptExecutionContext&, const ResourceError&, const String&);
 
-    protected:
-        ThreadableLoader() { }
-        virtual ~ThreadableLoader() { }
-        virtual void refThreadableLoader() = 0;
-        virtual void derefThreadableLoader() = 0;
-    };
+protected:
+    ThreadableLoader() { }
+    virtual ~ThreadableLoader() { }
+    virtual void refThreadableLoader() = 0;
+    virtual void derefThreadableLoader() = 0;
+};
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/loader/ThreadableLoaderClient.h (221494 => 221495)


--- trunk/Source/WebCore/loader/ThreadableLoaderClient.h	2017-09-01 20:40:11 UTC (rev 221494)
+++ trunk/Source/WebCore/loader/ThreadableLoaderClient.h	2017-09-01 21:33:02 UTC (rev 221495)
@@ -32,24 +32,24 @@
 
 namespace WebCore {
 
-    class ResourceError;
-    class ResourceResponse;
-    class ResourceTiming;
+class ResourceError;
+class ResourceResponse;
+class ResourceTiming;
 
-    class ThreadableLoaderClient {
-        WTF_MAKE_NONCOPYABLE(ThreadableLoaderClient); WTF_MAKE_FAST_ALLOCATED;
-    public:
-        virtual void didSendData(unsigned long long /*bytesSent*/, unsigned long long /*totalBytesToBeSent*/) { }
+class ThreadableLoaderClient {
+    WTF_MAKE_NONCOPYABLE(ThreadableLoaderClient);
+public:
+    virtual void didSendData(unsigned long long /*bytesSent*/, unsigned long long /*totalBytesToBeSent*/) { }
 
-        virtual void didReceiveResponse(unsigned long /*identifier*/, const ResourceResponse&) { }
-        virtual void didReceiveData(const char*, int /*dataLength*/) { }
-        virtual void didFinishLoading(unsigned long /*identifier*/) { }
-        virtual void didFail(const ResourceError&) { }
-        virtual void didFinishTiming(const ResourceTiming&) { }
+    virtual void didReceiveResponse(unsigned long /*identifier*/, const ResourceResponse&) { }
+    virtual void didReceiveData(const char*, int /*dataLength*/) { }
+    virtual void didFinishLoading(unsigned long /*identifier*/) { }
+    virtual void didFail(const ResourceError&) { }
+    virtual void didFinishTiming(const ResourceTiming&) { }
 
-    protected:
-        ThreadableLoaderClient() { }
-        virtual ~ThreadableLoaderClient() { }
-    };
+protected:
+    ThreadableLoaderClient() { }
+    virtual ~ThreadableLoaderClient() { }
+};
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerJob.cpp (221494 => 221495)


--- trunk/Source/WebCore/workers/service/ServiceWorkerJob.cpp	2017-09-01 20:40:11 UTC (rev 221494)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerJob.cpp	2017-09-01 21:33:02 UTC (rev 221495)
@@ -82,23 +82,19 @@
     ASSERT(currentThread() == m_creationThread);
     ASSERT(!m_completed);
 
-    m_fetchLoader = std::make_unique<FetchLoader>(*this, nullptr);
-
     // FIXME: This Fetch request is set up incorrectly and without proper care.
     // The ServiceWorkers spec specifics many details to apply here.
 
-    auto fetchHeaders = FetchHeaders::create();
+    auto request = ResourceRequest { m_jobData.scriptURL };
     auto referrer = m_jobData.clientCreationURL.string();
-    auto fetchRequest = FetchRequest::create(context, std::nullopt, WTFMove(fetchHeaders), { m_jobData.scriptURL }, { }, WTFMove(referrer));
-
-    m_fetchLoader->start(context, fetchRequest);
+    m_loader = ThreadableLoader::create(context, *this, WTFMove(request), { }, WTFMove(referrer));
 }
 
-void ServiceWorkerJob::didReceiveResponse(const ResourceResponse& response)
+void ServiceWorkerJob::didReceiveResponse(unsigned long, const ResourceResponse& response)
 {
     ASSERT(currentThread() == m_creationThread);
     ASSERT(!m_completed);
-    ASSERT(m_fetchLoader);
+    ASSERT(m_loader);
     ASSERT(!m_scriptData);
 
     m_lastResponse = response;
@@ -109,11 +105,11 @@
     }
 }
 
-void ServiceWorkerJob::didReceiveData(const char* data, size_t size)
+void ServiceWorkerJob::didReceiveData(const char* data, int size)
 {
     ASSERT(currentThread() == m_creationThread);
     ASSERT(!m_completed);
-    ASSERT(m_fetchLoader);
+    ASSERT(m_loader);
 
     if (!m_scriptData)
         m_scriptData = SharedBuffer::create();
@@ -121,16 +117,16 @@
     m_scriptData->get().append(data, size);
 }
 
-void ServiceWorkerJob::didSucceed()
+void ServiceWorkerJob::didFinishLoading(unsigned long)
 {
     ASSERT(currentThread() == m_creationThread);
     ASSERT(!m_completed);
-    ASSERT(m_fetchLoader);
+    ASSERT(m_loader);
 
     if (!m_scriptData)
         m_scriptData = SharedBuffer::create();
     m_client->jobFinishedLoadingScript(*this, WTFMove(*m_scriptData));
-    m_fetchLoader = nullptr;
+    m_loader = nullptr;
 }
 
 void ServiceWorkerJob::didFail(const ResourceError& error)
@@ -137,10 +133,10 @@
 {
     ASSERT(currentThread() == m_creationThread);
     ASSERT(!m_completed);
-    ASSERT(m_fetchLoader);
+    ASSERT(m_loader);
 
     m_client->jobFailedLoadingScript(*this, error);
-    m_fetchLoader = nullptr;
+    m_loader = nullptr;
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerJob.h (221494 => 221495)


--- trunk/Source/WebCore/workers/service/ServiceWorkerJob.h	2017-09-01 20:40:11 UTC (rev 221494)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerJob.h	2017-09-01 21:33:02 UTC (rev 221495)
@@ -27,11 +27,11 @@
 
 #if ENABLE(SERVICE_WORKER)
 
-#include "FetchLoader.h"
-#include "FetchLoaderClient.h"
 #include "ResourceResponse.h"
 #include "ServiceWorkerJobClient.h"
 #include "ServiceWorkerJobData.h"
+#include "ThreadableLoader.h"
+#include "ThreadableLoaderClient.h"
 #include <wtf/RefPtr.h>
 #include <wtf/RunLoop.h>
 #include <wtf/ThreadSafeRefCounted.h>
@@ -45,7 +45,7 @@
 enum class ServiceWorkerJobType;
 struct ServiceWorkerRegistrationData;
 
-class ServiceWorkerJob : public ThreadSafeRefCounted<ServiceWorkerJob>, public FetchLoaderClient {
+class ServiceWorkerJob : public ThreadSafeRefCounted<ServiceWorkerJob>, public ThreadableLoaderClient {
 public:
     static Ref<ServiceWorkerJob> create(ServiceWorkerJobClient& client, Ref<DeferredPromise>&& promise, ServiceWorkerJobData&& jobData)
     {
@@ -66,10 +66,10 @@
 private:
     ServiceWorkerJob(ServiceWorkerJobClient&, Ref<DeferredPromise>&&, ServiceWorkerJobData&&);
 
-    // FetchLoaderClient
-    void didReceiveResponse(const ResourceResponse&) final;
-    void didReceiveData(const char*, size_t) final;
-    void didSucceed() final;
+    // ThreadableLoaderClient
+    void didReceiveResponse(unsigned long identifier, const ResourceResponse&) final;
+    void didReceiveData(const char* data, int length) final;
+    void didFinishLoading(unsigned long identifier) final;
     void didFail(const ResourceError&) final;
 
     Ref<ServiceWorkerJobClient> m_client;
@@ -79,7 +79,7 @@
     bool m_completed { false };
 
     Ref<RunLoop> m_runLoop { RunLoop::current() };
-    std::unique_ptr<FetchLoader> m_fetchLoader;
+    RefPtr<ThreadableLoader> m_loader;
     ResourceResponse m_lastResponse;
     std::optional<Ref<SharedBuffer>> m_scriptData;
 

Modified: trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp (221494 => 221495)


--- trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp	2017-09-01 20:40:11 UTC (rev 221494)
+++ trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp	2017-09-01 21:33:02 UTC (rev 221495)
@@ -31,6 +31,7 @@
 #include "ExceptionData.h"
 #include "ServiceWorkerFetchResult.h"
 #include "ServiceWorkerJobData.h"
+#include "SharedBuffer.h"
 
 namespace WebCore {
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to