Title: [221461] trunk
Revision
221461
Author
beid...@apple.com
Date
2017-08-31 17:12:52 -0700 (Thu, 31 Aug 2017)

Log Message

Add (entirely incorrect) fetching of ServiceWorker scripts.
https://bugs.webkit.org/show_bug.cgi?id=176179

Reviewed by Andy Estes.

Source/WebCore:

No new tests (Covered by changes to existing tests).

When the Storage process is running the "Update" algorithm and a ServiceWorker script file needs to be fetched, this patch:
  - Messages back to the WebContent process that started the register/update job
  - Executes a FetchLoad in that script context for the script
  - Sends the results back to the Storage process

We don't do anything with the results yet.

Soon.

* WebCore.xcodeproj/project.pbxproj:

* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::startScriptFetchForJob):
(WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):
(WebCore::ServiceWorkerContainer::jobFailedLoadingScript):
* workers/service/ServiceWorkerContainer.h:

* workers/service/ServiceWorkerFetchResult.h: Copied from Source/WebCore/workers/service/server/SWClientConnection.h.
(WebCore::ServiceWorkerFetchResult::encode const):
(WebCore::ServiceWorkerFetchResult::decode):

* workers/service/ServiceWorkerJob.cpp:
(WebCore::ServiceWorkerJob::startScriptFetch):
(WebCore::ServiceWorkerJob::fetchScriptWithContext):
(WebCore::ServiceWorkerJob::didReceiveResponse):
(WebCore::ServiceWorkerJob::didReceiveData):
(WebCore::ServiceWorkerJob::didSucceed):
(WebCore::ServiceWorkerJob::didFail):
* workers/service/ServiceWorkerJob.h:

* workers/service/ServiceWorkerJobClient.h:

* workers/service/server/SWClientConnection.cpp:
(WebCore::SWClientConnection::finishedFetchingScript):
(WebCore::SWClientConnection::failedFetchingScript):
(WebCore::SWClientConnection::startScriptFetchForServer):
* workers/service/server/SWClientConnection.h:

* workers/service/server/SWServer.cpp:
(WebCore::SWServer::Connection::finishFetchingScriptInServer):
(WebCore::SWServer::startScriptFetch):
(WebCore::SWServer::scriptFetchFinished):
* workers/service/server/SWServer.h:

* workers/service/server/SWServerRegistration.cpp:
(WebCore::SWServerRegistration::scriptFetchFinished):
(WebCore::SWServerRegistration::runUpdateJob):
(WebCore::SWServerRegistration::startScriptFetchFromMainThread):
(WebCore::SWServerRegistration::startScriptFetchForCurrentJob):
* workers/service/server/SWServerRegistration.h:

Source/WebKit:

* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::startScriptFetchInClient):
* StorageProcess/ServiceWorker/WebSWServerConnection.h:
* StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:

* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::finishFetchingScriptInServer):
* WebProcess/Storage/WebSWClientConnection.h:
* WebProcess/Storage/WebSWClientConnection.messages.in:

LayoutTests:

* http/tests/workers/service/basic-register-expected.txt:
* http/tests/workers/service/resources/basic-register.js:
* http/tests/workers/service/resources/registration-task-queue-scheduling-1.js:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (221460 => 221461)


--- trunk/LayoutTests/ChangeLog	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/LayoutTests/ChangeLog	2017-09-01 00:12:52 UTC (rev 221461)
@@ -1,3 +1,14 @@
+2017-08-31  Brady Eidson  <beid...@apple.com>
+
+        Add (entirely incorrect) fetching of ServiceWorker scripts.
+        https://bugs.webkit.org/show_bug.cgi?id=176179
+
+        Reviewed by Andy Estes.
+
+        * http/tests/workers/service/basic-register-expected.txt:
+        * http/tests/workers/service/resources/basic-register.js:
+        * http/tests/workers/service/resources/registration-task-queue-scheduling-1.js:
+
 2017-08-31  Antti Koivisto  <an...@apple.com>
 
         Remove newBlockInsideInlineModel and anonymous inline block

Modified: trunk/LayoutTests/http/tests/workers/service/basic-register-expected.txt (221460 => 221461)


--- trunk/LayoutTests/http/tests/workers/service/basic-register-expected.txt	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/LayoutTests/http/tests/workers/service/basic-register-expected.txt	2017-09-01 00:12:52 UTC (rev 221461)
@@ -1,2 +1,3 @@
-CONSOLE MESSAGE: line 11: Registration failed with error: UnknownError: serviceWorker job scheduling is not yet implemented
+CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Script URL http://127.0.0.1:8000/workers/service/resources/empty-worker.js fetched with 41 bytes, but we're not using the result yet
+CONSOLE MESSAGE: line 21: Registration failed with error: UnknownError: Script URL http://127.0.0.1:8000/workers/service/resources/empty-worker-doesnt-exist.js fetch resulted in error: ServiceWorker script network fetch failed with HTTP status code 404
 

Modified: trunk/LayoutTests/http/tests/workers/service/resources/basic-register.js (221460 => 221461)


--- trunk/LayoutTests/http/tests/workers/service/resources/basic-register.js	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/LayoutTests/http/tests/workers/service/resources/basic-register.js	2017-09-01 00:12:52 UTC (rev 221461)
@@ -6,6 +6,16 @@
 navigator.serviceWorker.register("resources/empty-worker.js", { })
 .then(function(r) {
 	console.log("Registered!");
+}, function(e) {
+	console.log("Registration failed with error: " + e);
+})
+.catch(function(e) {
+	console.log("Exception registering: " + e);
+});
+
+navigator.serviceWorker.register("resources/empty-worker-doesnt-exist.js", { })
+.then(function(r) {
+	console.log("Registered!");
 	done();
 }, function(e) {
 	console.log("Registration failed with error: " + e);

Modified: trunk/LayoutTests/http/tests/workers/service/resources/registration-task-queue-scheduling-1.js (221460 => 221461)


--- trunk/LayoutTests/http/tests/workers/service/resources/registration-task-queue-scheduling-1.js	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/LayoutTests/http/tests/workers/service/resources/registration-task-queue-scheduling-1.js	2017-09-01 00:12:52 UTC (rev 221461)
@@ -48,8 +48,8 @@
 		console.log("Original window resolved successfully (unexpected)")
 		done();
 	}, function(e) {
-		if (e+"" != "UnknownError: serviceWorker job scheduling is not yet implemented") {
-			alert("Unexpected error received from server");
+		if (e+"" != "UnknownError: Script URL http://127.0.0.1:8000/workers/service/resources/empty-worker.js fetched with 41 bytes, but we're not using the result yet") {
+			alert("Unexpected error received from server: " + e);
 			finishSWTest();
 		}
 		

Modified: trunk/Source/WebCore/ChangeLog (221460 => 221461)


--- trunk/Source/WebCore/ChangeLog	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebCore/ChangeLog	2017-09-01 00:12:52 UTC (rev 221461)
@@ -1,3 +1,63 @@
+2017-08-31  Brady Eidson  <beid...@apple.com>
+
+        Add (entirely incorrect) fetching of ServiceWorker scripts.
+        https://bugs.webkit.org/show_bug.cgi?id=176179
+
+        Reviewed by Andy Estes.
+
+        No new tests (Covered by changes to existing tests).
+
+        When the Storage process is running the "Update" algorithm and a ServiceWorker script file needs to be fetched, this patch:
+          - Messages back to the WebContent process that started the register/update job
+          - Executes a FetchLoad in that script context for the script
+          - Sends the results back to the Storage process
+
+        We don't do anything with the results yet.
+
+        Soon.
+
+        * WebCore.xcodeproj/project.pbxproj:
+
+        * workers/service/ServiceWorkerContainer.cpp:
+        (WebCore::ServiceWorkerContainer::startScriptFetchForJob):
+        (WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):
+        (WebCore::ServiceWorkerContainer::jobFailedLoadingScript):
+        * workers/service/ServiceWorkerContainer.h:
+
+        * workers/service/ServiceWorkerFetchResult.h: Copied from Source/WebCore/workers/service/server/SWClientConnection.h.
+        (WebCore::ServiceWorkerFetchResult::encode const):
+        (WebCore::ServiceWorkerFetchResult::decode):
+
+        * workers/service/ServiceWorkerJob.cpp:
+        (WebCore::ServiceWorkerJob::startScriptFetch):
+        (WebCore::ServiceWorkerJob::fetchScriptWithContext):
+        (WebCore::ServiceWorkerJob::didReceiveResponse):
+        (WebCore::ServiceWorkerJob::didReceiveData):
+        (WebCore::ServiceWorkerJob::didSucceed):
+        (WebCore::ServiceWorkerJob::didFail):
+        * workers/service/ServiceWorkerJob.h:
+
+        * workers/service/ServiceWorkerJobClient.h:
+
+        * workers/service/server/SWClientConnection.cpp:
+        (WebCore::SWClientConnection::finishedFetchingScript):
+        (WebCore::SWClientConnection::failedFetchingScript):
+        (WebCore::SWClientConnection::startScriptFetchForServer):
+        * workers/service/server/SWClientConnection.h:
+
+        * workers/service/server/SWServer.cpp:
+        (WebCore::SWServer::Connection::finishFetchingScriptInServer):
+        (WebCore::SWServer::startScriptFetch):
+        (WebCore::SWServer::scriptFetchFinished):
+        * workers/service/server/SWServer.h:
+
+        * workers/service/server/SWServerRegistration.cpp:
+        (WebCore::SWServerRegistration::scriptFetchFinished):
+        (WebCore::SWServerRegistration::runUpdateJob):
+        (WebCore::SWServerRegistration::startScriptFetchFromMainThread):
+        (WebCore::SWServerRegistration::startScriptFetchForCurrentJob):
+        * workers/service/server/SWServerRegistration.h:
+
 2017-08-31  Daniel Bates  <daba...@apple.com>
 
         Make RenderStyle's non-inherited flags more human friendly

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (221460 => 221461)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-09-01 00:12:52 UTC (rev 221461)
@@ -2305,6 +2305,10 @@
 		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, ); }; };
+		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 */; };
 		517A63C41B74318B00E7DCDC /* KeyedEncoderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A63C11B74317E00E7DCDC /* KeyedEncoderCF.cpp */; };
 		517A63C51B74318F00E7DCDC /* KeyedDecoderCF.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A63C01B74317E00E7DCDC /* KeyedDecoderCF.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10131,6 +10135,7 @@
 		517A53431F50C16100DCDC0A /* SWServerWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SWServerWorker.cpp; sourceTree = "<group>"; };
 		517A534B1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerRegistrationData.cpp; sourceTree = "<group>"; };
 		517A534C1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerRegistrationData.h; sourceTree = "<group>"; };
+		517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerFetchResult.h; sourceTree = "<group>"; };
 		517A63BF1B74317E00E7DCDC /* KeyedDecoderCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyedDecoderCF.cpp; sourceTree = "<group>"; };
 		517A63C01B74317E00E7DCDC /* KeyedDecoderCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyedDecoderCF.h; sourceTree = "<group>"; };
 		517A63C11B74317E00E7DCDC /* KeyedEncoderCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyedEncoderCF.cpp; sourceTree = "<group>"; };
@@ -18862,6 +18867,7 @@
 				51F175581F3EBC0C00C74950 /* ServiceWorkerContainer.cpp */,
 				51F175571F3EBC0C00C74950 /* ServiceWorkerContainer.h */,
 				51F175561F3EBC0C00C74950 /* ServiceWorkerContainer.idl */,
+				517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */,
 				51F175551F3EBC0C00C74950 /* ServiceWorkerGlobalScope.cpp */,
 				51F175541F3EBC0C00C74950 /* ServiceWorkerGlobalScope.h */,
 				51F175531F3EBC0C00C74950 /* ServiceWorkerGlobalScope.idl */,
@@ -26821,6 +26827,7 @@
 				1A8A64561D19FCFC00D0E00F /* ApplePayPaymentMethodSelectedEvent.h in Headers */,
 				7C6522F51E00A51700677F22 /* ApplePayPaymentPass.h in Headers */,
 				7C6579E01E0079F900E3A27A /* ApplePayPaymentRequest.h in Headers */,
+				517A535A1F5889EF00DCDC0A /* FetchLoader.h in Headers */,
 				1A8A64591D19FCFC00D0E00F /* ApplePaySession.h in Headers */,
 				1A58E8651D19D4EB00C0EA73 /* ApplePaySessionPaymentRequest.h in Headers */,
 				1A8A645C1D19FCFC00D0E00F /* ApplePayShippingContactSelectedEvent.h in Headers */,
@@ -27789,6 +27796,7 @@
 				93F198E508245E59001E9ABC /* HTMLDocument.h in Headers */,
 				977B3867122883E900B81FF8 /* HTMLDocumentParser.h in Headers */,
 				93F198E608245E59001E9ABC /* HTMLElement.h in Headers */,
+				517A53581F5889E800DCDC0A /* FetchLoaderClient.h in Headers */,
 				A17C81230F2A5CF7005DAAEB /* HTMLElementFactory.h in Headers */,
 				977B37241228721700B81FF8 /* HTMLElementStack.h in Headers */,
 				B562DB6017D3CD630010AF96 /* HTMLElementTypeHelpers.h in Headers */,
@@ -28940,6 +28948,7 @@
 				FA654A6C1108ABED002626F1 /* MathMLUnderOverElement.h in Headers */,
 				37C738EF1EDBD71B003F2B0B /* MathMLUnknownElement.h in Headers */,
 				439046EA12DA25E812AF80AC /* MathOperator.h in Headers */,
+				517A535B1F588A4C00DCDC0A /* FetchBodyConsumer.h in Headers */,
 				49D5DC2C0F423A73008F20FD /* Matrix3DTransformOperation.h in Headers */,
 				49E911C70EF86D47009D0CAF /* MatrixTransformOperation.h in Headers */,
 				5CBC8DAD1AAA302200E1C803 /* MediaAccessibilitySoftLink.h in Headers */,
@@ -29102,6 +29111,7 @@
 				656D37430ADBA5DE00A4554D /* NetscapePlugInStreamLoader.h in Headers */,
 				A19D934B1AA11B1E00B46C24 /* NetworkExtensionContentFilter.h in Headers */,
 				628D214C12131ED10055DCFC /* NetworkingContext.h in Headers */,
+				517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */,
 				8A81BF8511DCFD9000DA2B98 /* NetworkLoadMetrics.h in Headers */,
 				59C27F07138D28CF0079B7E2 /* NetworkResourcesData.h in Headers */,
 				1A7FA6190DDA3B3A0028F8A5 /* NetworkStateNotifier.h in Headers */,

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp (221460 => 221461)


--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp	2017-09-01 00:12:52 UTC (rev 221461)
@@ -32,7 +32,9 @@
 #include "IDLTypes.h"
 #include "JSDOMPromiseDeferred.h"
 #include "JSServiceWorkerRegistration.h"
+#include "Logging.h"
 #include "NavigatorBase.h"
+#include "ResourceError.h"
 #include "ScopeGuard.h"
 #include "ScriptExecutionContext.h"
 #include "SecurityOrigin.h"
@@ -181,6 +183,35 @@
     job.promise().resolve<IDLInterface<ServiceWorkerRegistration>>(registration.get());
 }
 
+void ServiceWorkerContainer::startScriptFetchForJob(ServiceWorkerJob& job)
+{
+    LOG(ServiceWorker, "SeviceWorkerContainer %p starting script fetch for job %" PRIu64, this, job.data().identifier());
+
+    auto* context = scriptExecutionContext();
+    if (!context) {
+        LOG_ERROR("ServiceWorkerContainer::jobResolvedWithRegistration called but the container's ScriptExecutionContext is gone");
+        m_swConnection->failedFetchingScript(job, { errorDomainWebKitInternal, 0, job.data().scriptURL, ASCIILiteral("Attempt to fetch service worker script with no ScriptExecutionContext") });
+        jobDidFinish(job);
+        return;
+    }
+
+    job.fetchScriptWithContext(*context);
+}
+
+void ServiceWorkerContainer::jobFinishedLoadingScript(ServiceWorkerJob& job, Ref<SharedBuffer>&& data)
+{
+    LOG(ServiceWorker, "SeviceWorkerContainer %p finished fetching script for job %" PRIu64, this, job.data().identifier());
+
+    m_swConnection->finishedFetchingScript(job, data.get());
+}
+
+void ServiceWorkerContainer::jobFailedLoadingScript(ServiceWorkerJob& job, const ResourceError& error)
+{
+    LOG(ServiceWorker, "SeviceWorkerContainer %p failed fetching script for job %" PRIu64, this, job.data().identifier());
+
+    m_swConnection->failedFetchingScript(job, error);
+}
+
 void ServiceWorkerContainer::jobDidFinish(ServiceWorkerJob& job)
 {
     auto taken = m_jobMap.take(job.data().identifier());

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h (221460 => 221461)


--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h	2017-09-01 00:12:52 UTC (rev 221461)
@@ -73,6 +73,10 @@
 
     void jobFailedWithException(ServiceWorkerJob&, const Exception&) final;
     void jobResolvedWithRegistration(ServiceWorkerJob&, const ServiceWorkerRegistrationData&) final;
+    void startScriptFetchForJob(ServiceWorkerJob&) final;
+    void jobFinishedLoadingScript(ServiceWorkerJob&, Ref<SharedBuffer>&&) final;
+    void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&) final;
+
     void jobDidFinish(ServiceWorkerJob&);
 
     uint64_t connectionIdentifier() final;

Copied: trunk/Source/WebCore/workers/service/ServiceWorkerFetchResult.h (from rev 221460, trunk/Source/WebCore/workers/service/server/SWClientConnection.h) (0 => 221461)


--- trunk/Source/WebCore/workers/service/ServiceWorkerFetchResult.h	                        (rev 0)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerFetchResult.h	2017-09-01 00:12:52 UTC (rev 221461)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(SERVICE_WORKER)
+
+#include "ResourceError.h"
+#include "ServiceWorkerRegistrationKey.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+struct ServiceWorkerFetchResult {
+    uint64_t jobIdentifier;
+    uint64_t connectionIdentifier;
+    ServiceWorkerRegistrationKey registrationKey;
+    Vector<uint8_t> scriptData;
+    ResourceError scriptError;
+
+    template<class Encoder> void encode(Encoder&) const;
+    template<class Decoder> static bool decode(Decoder&, ServiceWorkerFetchResult&);
+};
+
+template<class Encoder>
+void ServiceWorkerFetchResult::encode(Encoder& encoder) const
+{
+    encoder << jobIdentifier << connectionIdentifier << registrationKey << scriptData << scriptError;
+}
+
+template<class Decoder>
+bool ServiceWorkerFetchResult::decode(Decoder& decoder, ServiceWorkerFetchResult& result)
+{
+    if (!decoder.decode(result.jobIdentifier))
+        return false;
+    if (!decoder.decode(result.connectionIdentifier))
+        return false;
+    if (!decoder.decode(result.registrationKey))
+        return false;
+    if (!decoder.decode(result.scriptData))
+        return false;
+    if (!decoder.decode(result.scriptError))
+        return false;
+
+    return true;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerJob.cpp (221460 => 221461)


--- trunk/Source/WebCore/workers/service/ServiceWorkerJob.cpp	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerJob.cpp	2017-09-01 00:12:52 UTC (rev 221461)
@@ -28,7 +28,12 @@
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "FetchHeaders.h"
+#include "FetchLoader.h"
+#include "FetchRequest.h"
 #include "JSDOMPromiseDeferred.h"
+#include "ResourceError.h"
+#include "ResourceResponse.h"
 #include "ServiceWorkerJobData.h"
 #include "ServiceWorkerRegistration.h"
 
@@ -64,6 +69,80 @@
     m_client->jobResolvedWithRegistration(*this, data);
 }
 
+void ServiceWorkerJob::startScriptFetch()
+{
+    ASSERT(currentThread() == m_creationThread);
+    ASSERT(!m_completed);
+
+    m_client->startScriptFetchForJob(*this);
+}
+
+void ServiceWorkerJob::fetchScriptWithContext(ScriptExecutionContext& context)
+{
+    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 referrer = m_jobData.clientCreationURL.string();
+    auto fetchRequest = FetchRequest::create(context, std::nullopt, WTFMove(fetchHeaders), { m_jobData.scriptURL }, { }, WTFMove(referrer));
+
+    m_fetchLoader->start(context, fetchRequest);
+}
+
+void ServiceWorkerJob::didReceiveResponse(const ResourceResponse& response)
+{
+    ASSERT(currentThread() == m_creationThread);
+    ASSERT(!m_completed);
+    ASSERT(m_fetchLoader);
+    ASSERT(!m_scriptData);
+
+    m_lastResponse = response;
+
+    if (response.httpStatusCode() < 200 || response.httpStatusCode() > 399) {
+        auto message = makeString(ASCIILiteral("ServiceWorker script network fetch failed with HTTP status code "), String::number(response.httpStatusCode()));
+        didFail({ errorDomainWebKitInternal, 0, m_lastResponse.url(), message });
+    }
+}
+
+void ServiceWorkerJob::didReceiveData(const char* data, size_t size)
+{
+    ASSERT(currentThread() == m_creationThread);
+    ASSERT(!m_completed);
+    ASSERT(m_fetchLoader);
+
+    if (!m_scriptData)
+        m_scriptData = SharedBuffer::create();
+
+    m_scriptData->get().append(data, size);
+}
+
+void ServiceWorkerJob::didSucceed()
+{
+    ASSERT(currentThread() == m_creationThread);
+    ASSERT(!m_completed);
+    ASSERT(m_fetchLoader);
+
+    if (!m_scriptData)
+        m_scriptData = SharedBuffer::create();
+    m_client->jobFinishedLoadingScript(*this, WTFMove(*m_scriptData));
+    m_fetchLoader = nullptr;
+}
+
+void ServiceWorkerJob::didFail(const ResourceError& error)
+{
+    ASSERT(currentThread() == m_creationThread);
+    ASSERT(!m_completed);
+    ASSERT(m_fetchLoader);
+
+    m_client->jobFailedLoadingScript(*this, error);
+    m_fetchLoader = nullptr;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerJob.h (221460 => 221461)


--- trunk/Source/WebCore/workers/service/ServiceWorkerJob.h	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerJob.h	2017-09-01 00:12:52 UTC (rev 221461)
@@ -27,6 +27,9 @@
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "FetchLoader.h"
+#include "FetchLoaderClient.h"
+#include "ResourceResponse.h"
 #include "ServiceWorkerJobClient.h"
 #include "ServiceWorkerJobData.h"
 #include <wtf/RefPtr.h>
@@ -38,10 +41,11 @@
 
 class DeferredPromise;
 class Exception;
+class ScriptExecutionContext;
 enum class ServiceWorkerJobType;
 struct ServiceWorkerRegistrationData;
 
-class ServiceWorkerJob : public ThreadSafeRefCounted<ServiceWorkerJob> {
+class ServiceWorkerJob : public ThreadSafeRefCounted<ServiceWorkerJob>, public FetchLoaderClient {
 public:
     static Ref<ServiceWorkerJob> create(ServiceWorkerJobClient& client, Ref<DeferredPromise>&& promise, ServiceWorkerJobData&& jobData)
     {
@@ -52,13 +56,22 @@
 
     void failedWithException(const Exception&);
     void resolvedWithRegistration(const ServiceWorkerRegistrationData&);
+    void startScriptFetch();
 
     ServiceWorkerJobData data() const { return m_jobData; }
     DeferredPromise& promise() { return m_promise.get(); }
 
+    void fetchScriptWithContext(ScriptExecutionContext&);
+
 private:
     ServiceWorkerJob(ServiceWorkerJobClient&, Ref<DeferredPromise>&&, ServiceWorkerJobData&&);
 
+    // FetchLoaderClient
+    void didReceiveResponse(const ResourceResponse&) final;
+    void didReceiveData(const char*, size_t) final;
+    void didSucceed() final;
+    void didFail(const ResourceError&) final;
+
     Ref<ServiceWorkerJobClient> m_client;
     ServiceWorkerJobData m_jobData;
     Ref<DeferredPromise> m_promise;
@@ -66,6 +79,9 @@
     bool m_completed { false };
 
     Ref<RunLoop> m_runLoop { RunLoop::current() };
+    std::unique_ptr<FetchLoader> m_fetchLoader;
+    ResourceResponse m_lastResponse;
+    std::optional<Ref<SharedBuffer>> m_scriptData;
 
 #if !ASSERT_DISABLED
     ThreadIdentifier m_creationThread { currentThread() };

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerJobClient.h (221460 => 221461)


--- trunk/Source/WebCore/workers/service/ServiceWorkerJobClient.h	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerJobClient.h	2017-09-01 00:12:52 UTC (rev 221461)
@@ -30,7 +30,9 @@
 namespace WebCore {
 
 class Exception;
+class ResourceError;
 class ServiceWorkerJob;
+class SharedBuffer;
 struct ServiceWorkerRegistrationData;
 
 class ServiceWorkerJobClient {
@@ -39,6 +41,9 @@
 
     virtual void jobFailedWithException(ServiceWorkerJob&, const Exception&) = 0;
     virtual void jobResolvedWithRegistration(ServiceWorkerJob&, const ServiceWorkerRegistrationData&) = 0;
+    virtual void startScriptFetchForJob(ServiceWorkerJob&) = 0;
+    virtual void jobFinishedLoadingScript(ServiceWorkerJob&, Ref<SharedBuffer>&&) = 0;
+    virtual void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&) = 0;
 
     virtual uint64_t connectionIdentifier() = 0;
 

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


--- trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp	2017-09-01 00:12:52 UTC (rev 221461)
@@ -29,6 +29,7 @@
 #if ENABLE(SERVICE_WORKER)
 
 #include "ExceptionData.h"
+#include "ServiceWorkerFetchResult.h"
 #include "ServiceWorkerJobData.h"
 
 namespace WebCore {
@@ -49,6 +50,22 @@
     scheduleJobInServer(job.data());
 }
 
+void SWClientConnection::finishedFetchingScript(ServiceWorkerJob& job, SharedBuffer& data)
+{
+    ASSERT(m_scheduledJobs.get(job.data().identifier()) == &job);
+
+    Vector<uint8_t> vector;
+    vector.append(reinterpret_cast<const uint8_t *>(data.data()), data.size());
+    finishFetchingScriptInServer({ job.data().identifier(), job.data().connectionIdentifier(), job.data().registrationKey(), vector, { } });
+}
+
+void SWClientConnection::failedFetchingScript(ServiceWorkerJob& job, const ResourceError& error)
+{
+    ASSERT(m_scheduledJobs.get(job.data().identifier()) == &job);
+
+    finishFetchingScriptInServer({ job.data().identifier(), job.data().connectionIdentifier(), job.data().registrationKey(), { }, error });
+}
+
 void SWClientConnection::jobRejectedInServer(uint64_t jobIdentifier, const ExceptionData& exceptionData)
 {
     auto job = m_scheduledJobs.take(jobIdentifier);
@@ -71,6 +88,22 @@
     job->resolvedWithRegistration(registrationData);
 }
 
+void SWClientConnection::startScriptFetchForServer(uint64_t jobIdentifier)
+{
+    auto job = m_scheduledJobs.get(jobIdentifier);
+    if (!job) {
+        LOG_ERROR("Job %" PRIu64 " instructed to start fetch from server, but job was not found", jobIdentifier);
+
+        // FIXME: Should message back to the server here to signal failure to fetch,
+        // but we currently need the registration key to do so, and don't have it here.
+        // In the future we'll refactor to have a global, cross-process job identifier that can be used to overcome this.
+
+        return;
+    }
+
+    job->startScriptFetch();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebCore/workers/service/server/SWClientConnection.h (221460 => 221461)


--- trunk/Source/WebCore/workers/service/server/SWClientConnection.h	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebCore/workers/service/server/SWClientConnection.h	2017-09-01 00:12:52 UTC (rev 221461)
@@ -33,7 +33,10 @@
 
 namespace WebCore {
 
+class ResourceError;
+class SharedBuffer;
 struct ExceptionData;
+struct ServiceWorkerFetchResult;
 struct ServiceWorkerRegistrationData;
 
 class SWClientConnection : public ThreadSafeRefCounted<SWClientConnection> {
@@ -42,6 +45,8 @@
     WEBCORE_EXPORT virtual ~SWClientConnection();
 
     void scheduleJob(ServiceWorkerJob&);
+    void finishedFetchingScript(ServiceWorkerJob&, SharedBuffer&);
+    void failedFetchingScript(ServiceWorkerJob&, const ResourceError&);
 
     virtual uint64_t identifier() const = 0;
 
@@ -48,9 +53,11 @@
 protected:
     WEBCORE_EXPORT void jobRejectedInServer(uint64_t jobIdentifier, const ExceptionData&);
     WEBCORE_EXPORT void jobResolvedInServer(uint64_t jobIdentifier, const ServiceWorkerRegistrationData&);
+    WEBCORE_EXPORT void startScriptFetchForServer(uint64_t jobIdentifier);
 
 private:
     virtual void scheduleJobInServer(const ServiceWorkerJobData&) = 0;
+    virtual void finishFetchingScriptInServer(const ServiceWorkerFetchResult&) = 0;
 
     HashMap<uint64_t, RefPtr<ServiceWorkerJob>> m_scheduledJobs;
 };

Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (221460 => 221461)


--- trunk/Source/WebCore/workers/service/server/SWServer.cpp	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp	2017-09-01 00:12:52 UTC (rev 221461)
@@ -32,6 +32,7 @@
 #include "ExceptionData.h"
 #include "Logging.h"
 #include "SWServerRegistration.h"
+#include "ServiceWorkerFetchResult.h"
 #include "ServiceWorkerJobData.h"
 #include <wtf/text/WTFString.h>
 
@@ -72,6 +73,11 @@
     m_server.scheduleJob(jobData);
 }
 
+void SWServer::Connection::finishFetchingScriptInServer(const ServiceWorkerFetchResult& result)
+{
+    m_server.scriptFetchFinished(result);
+}
+
 SWServer::SWServer()
 {
     m_taskThread = Thread::create(ASCIILiteral("ServiceWorker Task Thread"), [this] {
@@ -112,6 +118,29 @@
     connection->resolveJobInClient(jobData.identifier(), registrationData);
 }
 
+void SWServer::startScriptFetch(const ServiceWorkerJobData& jobData)
+{
+    LOG(ServiceWorker, "Server issuing startScriptFetch for current job %" PRIu64 "-%" PRIu64 " in client", jobData.connectionIdentifier(), jobData.identifier());
+    auto* connection = m_connections.get(jobData.connectionIdentifier());
+    if (!connection)
+        return;
+
+    connection->startScriptFetchInClient(jobData.identifier());
+}
+
+void SWServer::scriptFetchFinished(const ServiceWorkerFetchResult& result)
+{
+    LOG(ServiceWorker, "Server handling scriptFetchFinished for current job %" PRIu64 "-%" PRIu64 " in client", result.connectionIdentifier, result.jobIdentifier);
+
+    ASSERT(m_connections.contains(result.connectionIdentifier));
+
+    auto registration = m_registrations.get(result.registrationKey);
+    if (!registration)
+        return;
+
+    registration->scriptFetchFinished(result);
+}
+
 void SWServer::taskThreadEntryPoint()
 {
     ASSERT(!isMainThread());

Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (221460 => 221461)


--- trunk/Source/WebCore/workers/service/server/SWServer.h	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h	2017-09-01 00:12:52 UTC (rev 221461)
@@ -43,6 +43,7 @@
 
 class SWServerRegistration;
 struct ExceptionData;
+struct ServiceWorkerFetchResult;
 struct ServiceWorkerRegistrationData;
 
 class SWServer {
@@ -57,10 +58,12 @@
         SWServer& server() { return m_server; }
 
         WEBCORE_EXPORT void scheduleJobInServer(const ServiceWorkerJobData&);
+        WEBCORE_EXPORT void finishFetchingScriptInServer(const ServiceWorkerFetchResult&);
 
     private:
         virtual void rejectJobInClient(uint64_t jobIdentifier, const ExceptionData&) = 0;
         virtual void resolveJobInClient(uint64_t jobIdentifier, const ServiceWorkerRegistrationData&) = 0;
+        virtual void startScriptFetchInClient(uint64_t jobIdentifier) = 0;
 
         SWServer& m_server;
     };
@@ -71,6 +74,8 @@
     void scheduleJob(const ServiceWorkerJobData&);
     void rejectJob(const ServiceWorkerJobData&, const ExceptionData&);
     void resolveJob(const ServiceWorkerJobData&, const ServiceWorkerRegistrationData&);
+    void startScriptFetch(const ServiceWorkerJobData&);
+
     void postTask(CrossThreadTask&&);
     void postTaskReply(CrossThreadTask&&);
 
@@ -81,6 +86,8 @@
     void taskThreadEntryPoint();
     void handleTaskRepliesOnMainThread();
 
+    void scriptFetchFinished(const ServiceWorkerFetchResult&);
+
     HashMap<uint64_t, Connection*> m_connections;
     HashMap<ServiceWorkerRegistrationKey, std::unique_ptr<SWServerRegistration>> m_registrations;
 

Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp (221460 => 221461)


--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp	2017-09-01 00:12:52 UTC (rev 221461)
@@ -32,6 +32,7 @@
 #include "SWServer.h"
 #include "SWServerWorker.h"
 #include "SecurityOrigin.h"
+#include "ServiceWorkerFetchResult.h"
 #include "ServiceWorkerRegistrationData.h"
 #include "WorkerType.h"
 
@@ -63,6 +64,22 @@
         m_jobTimer.startOneShot(0_s);
 }
 
+void SWServerRegistration::scriptFetchFinished(const ServiceWorkerFetchResult& result)
+{
+    ASSERT(m_currentJob && m_currentJob->identifier() == result.jobIdentifier);
+
+    // FIXME: We fetched the script contents but don't do anything with them yet.
+    // These errors are for testing the current state of the feature.
+
+    String message;
+    if (result.scriptError.isNull())
+        message = makeString("Script URL ", m_currentJob->scriptURL.string(), " fetched with ", String::number(result.scriptData.size()), " bytes, but we're not using the result yet");
+    else
+        message = makeString("Script URL ", m_currentJob->scriptURL.string(), " fetch resulted in error: ", result.scriptError.localizedDescription());
+
+    rejectCurrentJob(ExceptionData { UnknownError, message });
+}
+
 void SWServerRegistration::startNextJob()
 {
     ASSERT(isMainThread());
@@ -149,9 +166,7 @@
     if (newestWorker && !equalIgnoringFragmentIdentifier(job.scriptURL, newestWorker->scriptURL()))
         return rejectWithExceptionOnMainThread(ExceptionData { TypeError, ASCIILiteral("Cannot update a service worker with a requested script URL whose newest worker has a different script URL") });
 
-    // FIXME: At this point we are ready to actually fetch the script for the worker in the registering context.
-    // For now we're still hard coding the same rejection we have so far.
-    rejectWithExceptionOnMainThread(ExceptionData { UnknownError, ASCIILiteral("serviceWorker job scheduling is not yet implemented") });
+    startScriptFetchFromMainThread();
 }
 
 void SWServerRegistration::rejectWithExceptionOnMainThread(const ExceptionData& exception)
@@ -166,6 +181,12 @@
     m_server.postTaskReply(createCrossThreadTask(*this, &SWServerRegistration::resolveCurrentJob, data()));
 }
 
+void SWServerRegistration::startScriptFetchFromMainThread()
+{
+    ASSERT(!isMainThread());
+    m_server.postTaskReply(createCrossThreadTask(*this, &SWServerRegistration::startScriptFetchForCurrentJob));
+}
+
 void SWServerRegistration::rejectCurrentJob(const ExceptionData& exceptionData)
 {
     ASSERT(isMainThread());
@@ -186,6 +207,14 @@
     finishCurrentJob();
 }
 
+void SWServerRegistration::startScriptFetchForCurrentJob()
+{
+    ASSERT(isMainThread());
+    ASSERT(m_currentJob);
+
+    m_server.startScriptFetch(*m_currentJob);
+}
+
 void SWServerRegistration::finishCurrentJob()
 {
     ASSERT(m_currentJob);

Modified: trunk/Source/WebCore/workers/service/server/SWServerRegistration.h (221460 => 221461)


--- trunk/Source/WebCore/workers/service/server/SWServerRegistration.h	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebCore/workers/service/server/SWServerRegistration.h	2017-09-01 00:12:52 UTC (rev 221461)
@@ -38,6 +38,7 @@
 class SWServer;
 class SWServerWorker;
 struct ExceptionData;
+struct ServiceWorkerFetchResult;
 
 class SWServerRegistration : public ThreadSafeIdentified<SWServerRegistration> {
 public:
@@ -46,6 +47,7 @@
     ~SWServerRegistration();
 
     void enqueueJob(const ServiceWorkerJobData&);
+    void scriptFetchFinished(const ServiceWorkerFetchResult&);
 
     ServiceWorkerRegistrationData data() const;
 
@@ -54,6 +56,7 @@
     void startNextJob();
     void rejectCurrentJob(const ExceptionData&);
     void resolveCurrentJob(const ServiceWorkerRegistrationData&);
+    void startScriptFetchForCurrentJob();
     void finishCurrentJob();
 
     void runRegisterJob(const ServiceWorkerJobData&);
@@ -61,6 +64,7 @@
 
     void rejectWithExceptionOnMainThread(const ExceptionData&);
     void resolveWithRegistrationOnMainThread();
+    void startScriptFetchFromMainThread();
     bool isEmpty();
     SWServerWorker* getNewestWorker();
 

Modified: trunk/Source/WebKit/ChangeLog (221460 => 221461)


--- trunk/Source/WebKit/ChangeLog	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebKit/ChangeLog	2017-09-01 00:12:52 UTC (rev 221461)
@@ -1,3 +1,20 @@
+2017-08-31  Brady Eidson  <beid...@apple.com>
+
+        Add (entirely incorrect) fetching of ServiceWorker scripts.
+        https://bugs.webkit.org/show_bug.cgi?id=176179
+
+        Reviewed by Andy Estes.
+
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        (WebKit::WebSWServerConnection::startScriptFetchInClient):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
+
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        (WebKit::WebSWClientConnection::finishFetchingScriptInServer):
+        * WebProcess/Storage/WebSWClientConnection.h:
+        * WebProcess/Storage/WebSWClientConnection.messages.in:
+
 2017-08-31  Megan Gardner  <megan_gard...@apple.com>
 
         Fix error in protocol revving

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (221460 => 221461)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp	2017-09-01 00:12:52 UTC (rev 221461)
@@ -28,6 +28,7 @@
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "DataReference.h"
 #include "Logging.h"
 #include "StorageToWebProcessConnectionMessages.h"
 #include "WebProcess.h"
@@ -70,6 +71,11 @@
     send(Messages::WebSWClientConnection::JobResolvedInServer(jobIdentifier, registrationData));
 }
 
+void WebSWServerConnection::startScriptFetchInClient(uint64_t jobIdentifier)
+{
+    send(Messages::WebSWClientConnection::StartScriptFetchForServer(jobIdentifier));
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h (221460 => 221461)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h	2017-09-01 00:12:52 UTC (rev 221461)
@@ -51,6 +51,7 @@
     // Implement SWServer::Connection
     void rejectJobInClient(uint64_t jobIdentifier, const WebCore::ExceptionData&) final;
     void resolveJobInClient(uint64_t jobIdentifier, const WebCore::ServiceWorkerRegistrationData&) final;
+    void startScriptFetchInClient(uint64_t jobIdentifier) final;
 
     IPC::Connection* messageSenderConnection() final { return m_connection.ptr(); }
     uint64_t messageSenderDestinationID() final { return identifier(); }

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in (221460 => 221461)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in	2017-09-01 00:12:52 UTC (rev 221461)
@@ -25,6 +25,7 @@
 messages -> WebSWServerConnection {
     # When possible, these messages can be implemented directly by WebCore::SWClientConnection
     ScheduleJobInServer(struct WebCore::ServiceWorkerJobData jobData)
+    FinishFetchingScriptInServer(struct WebCore::ServiceWorkerFetchResult result)
 }
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp (221460 => 221461)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2017-09-01 00:12:52 UTC (rev 221461)
@@ -30,7 +30,9 @@
 
 #include "Logging.h"
 #include "StorageToWebProcessConnectionMessages.h"
+#include "WebCoreArgumentCoders.h"
 #include "WebSWServerConnectionMessages.h"
+#include <WebCore/ServiceWorkerFetchResult.h>
 #include <WebCore/ServiceWorkerJobData.h>
 
 using namespace PAL;
@@ -56,6 +58,11 @@
     send(Messages::WebSWServerConnection::ScheduleJobInServer(jobData));
 }
 
+void WebSWClientConnection::finishFetchingScriptInServer(const ServiceWorkerFetchResult& result)
+{
+    send(Messages::WebSWServerConnection::FinishFetchingScriptInServer(result));
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h (221460 => 221461)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h	2017-09-01 00:12:52 UTC (rev 221461)
@@ -48,6 +48,7 @@
     uint64_t identifier() const final { return m_identifier; }
 
     void scheduleJobInServer(const WebCore::ServiceWorkerJobData&) final;
+    void finishFetchingScriptInServer(const WebCore::ServiceWorkerFetchResult&) final;
 
     void disconnectedFromWebProcess();
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in (221460 => 221461)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in	2017-09-01 00:09:14 UTC (rev 221460)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in	2017-09-01 00:12:52 UTC (rev 221461)
@@ -26,6 +26,7 @@
     # When possible, these messages can be implemented directly by WebCore::SWServer::Connection
     JobRejectedInServer(uint64_t identifier, struct WebCore::ExceptionData exception)
     JobResolvedInServer(uint64_t identifier, struct WebCore::ServiceWorkerRegistrationData registration)
+    StartScriptFetchForServer(uint64_t jobIdentifier)
 }
 
 #endif // ENABLE(SERVICE_WORKER)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to