Diff
Modified: trunk/LayoutTests/ChangeLog (223649 => 223650)
--- trunk/LayoutTests/ChangeLog 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/LayoutTests/ChangeLog 2017-10-19 02:26:00 UTC (rev 223650)
@@ -1,5 +1,17 @@
2017-10-18 Youenn Fablet <[email protected]>
+ Add preliminary support for ServiceWorker Handle Fetch
+ https://bugs.webkit.org/show_bug.cgi?id=178475
+
+ Reviewed by Chris Dumez.
+
+ * http/tests/workers/service/basic-fetch.https-expected.txt: Added.
+ * http/tests/workers/service/basic-fetch.https.html: Added.
+ * http/tests/workers/service/resources/basic-fetch-worker.js: Added.
+ * http/tests/workers/service/resources/basic-fetch.js: Added.
+
+2017-10-18 Youenn Fablet <[email protected]>
+
TestController should clear all fetch caches when resetting its state
https://bugs.webkit.org/show_bug.cgi?id=178486
Added: trunk/LayoutTests/http/tests/workers/service/basic-fetch.https-expected.txt (0 => 223650)
--- trunk/LayoutTests/http/tests/workers/service/basic-fetch.https-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/basic-fetch.https-expected.txt 2017-10-19 02:26:00 UTC (rev 223650)
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: line 12: test1 status code: 200
+CONSOLE MESSAGE: line 13: test1 status text: Hello from service worker
+CONSOLE MESSAGE: line 16: test2 status code: 500
+CONSOLE MESSAGE: line 17: test2 status text: Error from service worker
+CONSOLE MESSAGE: line 26: test3 fetch failed as expected
+
Added: trunk/LayoutTests/http/tests/workers/service/basic-fetch.https.html (0 => 223650)
--- trunk/LayoutTests/http/tests/workers/service/basic-fetch.https.html (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/basic-fetch.https.html 2017-10-19 02:26:00 UTC (rev 223650)
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src=""
+</head>
+<body>
+
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/workers/service/resources/basic-fetch-worker.js (0 => 223650)
--- trunk/LayoutTests/http/tests/workers/service/resources/basic-fetch-worker.js (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/basic-fetch-worker.js 2017-10-19 02:26:00 UTC (rev 223650)
@@ -0,0 +1 @@
+// FIXME: register an onfetch event handler and handle "test1", "test2" and "test3" URLs
Added: trunk/LayoutTests/http/tests/workers/service/resources/basic-fetch.js (0 => 223650)
--- trunk/LayoutTests/http/tests/workers/service/resources/basic-fetch.js (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/basic-fetch.js 2017-10-19 02:26:00 UTC (rev 223650)
@@ -0,0 +1,34 @@
+function done()
+{
+ finishSWTest();
+}
+
+async function test()
+{
+ try {
+ await navigator.serviceWorker.register("resources/basic-fetch-worker.js", { });
+
+ var response = await fetch("test1");
+ console.log("test1 status code: " + response.status);
+ console.log("test1 status text: " + response.statusText);
+
+ var response = await fetch("test2");
+ console.log("test2 status code: " + response.status);
+ console.log("test2 status text: " + response.statusText);
+
+ try {
+ response = await fetch("test3");
+ console.log("test3 fetch succeeded unexpectedly");
+ console.log("test3 status code: " + response.status);
+ console.log("test3 status text: " + response.statusText);
+
+ } catch (e) {
+ console.log("test3 fetch failed as expected");
+ }
+ } catch(e) {
+ console.log("Got exception: " + e);
+ }
+ finishSWTest();
+}
+
+test();
Modified: trunk/Source/WebCore/ChangeLog (223649 => 223650)
--- trunk/Source/WebCore/ChangeLog 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/ChangeLog 2017-10-19 02:26:00 UTC (rev 223650)
@@ -1,3 +1,41 @@
+2017-10-18 Youenn Fablet <[email protected]>
+
+ Add preliminary support for ServiceWorker Handle Fetch
+ https://bugs.webkit.org/show_bug.cgi?id=178475
+
+ Reviewed by Chris Dumez.
+
+ Test: http/tests/workers/service/basic-fetch.https.html
+
+ Adding parameters to allow WebKit to do loading through Service Worker or through regular networking.
+ A script context is now storing its selected service worker identifier. This should be fully implemented later on.
+ This selected service worker identifier is passed to loading code as a ResourceLoaderOptions field.
+ Service workers mode is also added as a ResourceLoaderOptions field so that the service worker can be bypassed.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * dom/ScriptExecutionContext.h:
+ (WebCore::ScriptExecutionContext::selectedServiceWorkerIdentifier const):
+ (WebCore::ScriptExecutionContext::setSelectedServiceWorkerIdentifier):
+ * loader/DocumentThreadableLoader.cpp:
+ (WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
+ * loader/FetchOptions.h:
+ (WebCore::isPotentialNavigationOrSubresourceRequest):
+ (WebCore::isNonSubresourceRequest):
+ * loader/ResourceLoaderOptions.h:
+ * loader/WorkerThreadableLoader.cpp:
+ (WebCore::WorkerThreadableLoader::WorkerThreadableLoader):
+ (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
+ * loader/WorkerThreadableLoader.h:
+ * platform/network/ResourceRequestBase.h:
+ * platform/network/ResourceResponseBase.h:
+ * workers/WorkerThread.h:
+ * workers/service/ServiceWorkerContainer.cpp:
+ (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
+ * workers/service/ServiceWorkerProvider.h:
+ * workers/service/context/SWContextManager.cpp: Removed.
+ * workers/service/context/ServiceWorkerThread.h:
+ * workers/service/server/SWServer.h:
+
2017-10-18 Zalan Bujtas <[email protected]>
[FrameView::layout cleanup] Group related pre-layout code to improve readability
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (223649 => 223650)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-10-19 02:26:00 UTC (rev 223650)
@@ -2327,8 +2327,6 @@
517A63C61B74319200E7DCDC /* KeyedEncoderCF.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A63C21B74317E00E7DCDC /* KeyedEncoderCF.h */; settings = {ATTRIBUTES = (Private, ); }; };
517B25A91CC82B2A0061C011 /* IDBConnectionProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517B25A71CC820320061C011 /* IDBConnectionProxy.cpp */; };
517B25AA1CC82B2A0061C011 /* IDBConnectionProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 517B25A81CC820320061C011 /* IDBConnectionProxy.h */; settings = {ATTRIBUTES = (Private, ); }; };
- 517C870A1F8EBB2500EB8076 /* SWContextManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517C87081F8EB9BF00EB8076 /* SWContextManager.cpp */; };
- 517C870B1F8EBB2500EB8076 /* SWContextManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 517C87091F8EB9C000EB8076 /* SWContextManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
517C87181F8FD4D900EB8076 /* ServiceWorkerContextData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517C87161F8FD4D300EB8076 /* ServiceWorkerContextData.cpp */; };
517DEEE51DE94ADC00B91644 /* ScrollingMomentumCalculatorMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 517DEEE31DE94ADC00B91644 /* ScrollingMomentumCalculatorMac.mm */; };
517DEEE81DE94B0800B91644 /* ScrollingMomentumCalculatorMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 517DEEE71DE94B0800B91644 /* ScrollingMomentumCalculatorMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10230,8 +10228,6 @@
517A63C21B74317E00E7DCDC /* KeyedEncoderCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyedEncoderCF.h; sourceTree = "<group>"; };
517B25A71CC820320061C011 /* IDBConnectionProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBConnectionProxy.cpp; sourceTree = "<group>"; };
517B25A81CC820320061C011 /* IDBConnectionProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBConnectionProxy.h; sourceTree = "<group>"; };
- 517C87081F8EB9BF00EB8076 /* SWContextManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SWContextManager.cpp; path = workers/service/context/SWContextManager.cpp; sourceTree = SOURCE_ROOT; };
- 517C87091F8EB9C000EB8076 /* SWContextManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SWContextManager.h; path = workers/service/context/SWContextManager.h; sourceTree = SOURCE_ROOT; };
517C87101F8EE72E00EB8076 /* ServiceWorkerThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ServiceWorkerThread.h; path = workers/service/context/ServiceWorkerThread.h; sourceTree = SOURCE_ROOT; };
517C87111F8EE72F00EB8076 /* ServiceWorkerThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ServiceWorkerThread.cpp; path = workers/service/context/ServiceWorkerThread.cpp; sourceTree = SOURCE_ROOT; };
517C87161F8FD4D300EB8076 /* ServiceWorkerContextData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerContextData.cpp; sourceTree = "<group>"; };
@@ -19089,8 +19085,6 @@
children = (
517C87111F8EE72F00EB8076 /* ServiceWorkerThread.cpp */,
517C87101F8EE72E00EB8076 /* ServiceWorkerThread.h */,
- 517C87081F8EB9BF00EB8076 /* SWContextManager.cpp */,
- 517C87091F8EB9C000EB8076 /* SWContextManager.h */,
);
path = context;
sourceTree = "<group>";
@@ -30636,7 +30630,6 @@
B2227AF60D00BF220071B782 /* SVGZoomAndPan.h in Headers */,
B2E4EC980D00C22B00432643 /* SVGZoomEvent.h in Headers */,
517A531D1F4B53B100DCDC0A /* SWClientConnection.h in Headers */,
- 517C870B1F8EBB2500EB8076 /* SWContextManager.h in Headers */,
517A52F01F47535B00DCDC0A /* SWServer.h in Headers */,
51F645971F4A686F00B54DED /* SWServerRegistration.h in Headers */,
517A53461F50C17F00DCDC0A /* SWServerWorker.h in Headers */,
@@ -34368,7 +34361,6 @@
B2227AF50D00BF220071B782 /* SVGZoomAndPan.cpp in Sources */,
B2E4EC970D00C22B00432643 /* SVGZoomEvent.cpp in Sources */,
517A531C1F4B53B100DCDC0A /* SWClientConnection.cpp in Sources */,
- 517C870A1F8EBB2500EB8076 /* SWContextManager.cpp in Sources */,
517A52F11F4754E700DCDC0A /* SWServer.cpp in Sources */,
51F645961F4A686F00B54DED /* SWServerRegistration.cpp in Sources */,
517A53451F50C17F00DCDC0A /* SWServerWorker.cpp in Sources */,
Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.h (223649 => 223650)
--- trunk/Source/WebCore/dom/ScriptExecutionContext.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -230,6 +230,11 @@
JSC::ExecState* execState();
+#if ENABLE(SERVICE_WORKER)
+ uint64_t selectedServiceWorkerIdentifier() const { return m_serviceWorkerIdentifier; }
+ void setSelectedServiceWorkerIdentifier(uint64_t identifier) { m_serviceWorkerIdentifier = identifier; }
+#endif
+
protected:
class AddConsoleMessageTask : public Task {
public:
@@ -297,6 +302,10 @@
#if !ASSERT_DISABLED || ENABLE(SECURITY_ASSERTIONS)
bool m_activeDOMObjectRemovalForbidden { false };
#endif
+
+#if ENABLE(SERVICE_WORKER)
+ uint64_t m_serviceWorkerIdentifier { 0 };
+#endif
};
} // namespace WebCore
Modified: trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp (223649 => 223650)
--- trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp 2017-10-19 02:26:00 UTC (rev 223650)
@@ -103,6 +103,11 @@
{
relaxAdoptionRequirement();
+#if ENABLE(SERVICE_WORKER)
+ if (m_options.serviceWorkersMode == ServiceWorkersMode::All && !m_options.serviceWorkerIdentifier)
+ m_options.serviceWorkerIdentifier = document.selectedServiceWorkerIdentifier();
+#endif
+
// Setting a referrer header is only supported in the async code path.
ASSERT(m_async || m_referrer.isEmpty());
Modified: trunk/Source/WebCore/loader/FetchOptions.h (223649 => 223650)
--- trunk/Source/WebCore/loader/FetchOptions.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/loader/FetchOptions.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -69,8 +69,23 @@
{
}
+inline bool isPotentialNavigationOrSubresourceRequest(FetchOptions::Destination destination)
+{
+ return destination == FetchOptions::Destination::Object
+ || destination == FetchOptions::Destination::Embed;
}
+inline bool isNonSubresourceRequest(FetchOptions::Destination destination)
+{
+ return destination == FetchOptions::Destination::Document
+ || destination == FetchOptions::Destination::Report
+ || destination == FetchOptions::Destination::Serviceworker
+ || destination == FetchOptions::Destination::Sharedworker
+ || destination == FetchOptions::Destination::Worker;
+}
+
+}
+
namespace WTF {
template<> struct EnumTraits<WebCore::FetchOptions::Destination> {
Modified: trunk/Source/WebCore/loader/ResourceLoaderOptions.h (223649 => 223650)
--- trunk/Source/WebCore/loader/ResourceLoaderOptions.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/loader/ResourceLoaderOptions.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -92,6 +92,11 @@
Worker,
};
+enum class ServiceWorkersMode {
+ All,
+ None,
+};
+
struct ResourceLoaderOptions : public FetchOptions {
ResourceLoaderOptions() { }
@@ -124,6 +129,8 @@
CachingPolicy cachingPolicy { CachingPolicy::AllowCaching };
SameOriginDataURLFlag sameOriginDataURLFlag { SameOriginDataURLFlag::Unset };
InitiatorContext initiatorContext { InitiatorContext::Document };
+ ServiceWorkersMode serviceWorkersMode { ServiceWorkersMode::All };
+ uint64_t serviceWorkerIdentifier { 0 };
ClientCredentialPolicy clientCredentialPolicy { ClientCredentialPolicy::CannotAskClientForCredentials };
unsigned maxRedirectCount { 20 };
Modified: trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp (223649 => 223650)
--- trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp 2017-10-19 02:26:00 UTC (rev 223650)
@@ -55,7 +55,7 @@
WorkerThreadableLoader::WorkerThreadableLoader(WorkerGlobalScope& workerGlobalScope, ThreadableLoaderClient& client, const String& taskMode, ResourceRequest&& request, const ThreadableLoaderOptions& options, const String& referrer)
: m_workerGlobalScope(workerGlobalScope)
, m_workerClientWrapper(ThreadableLoaderClientWrapper::create(client, options.initiator))
- , m_bridge(*new MainThreadBridge(m_workerClientWrapper.get(), workerGlobalScope.thread().workerLoaderProxy(), taskMode, WTFMove(request), options, referrer.isEmpty() ? workerGlobalScope.url().strippedForUseAsReferrer() : referrer, workerGlobalScope.securityOrigin(), workerGlobalScope.contentSecurityPolicy()))
+ , m_bridge(*new MainThreadBridge(m_workerClientWrapper.get(), workerGlobalScope.thread().workerLoaderProxy(), taskMode, WTFMove(request), options, referrer.isEmpty() ? workerGlobalScope.url().strippedForUseAsReferrer() : referrer, workerGlobalScope))
{
}
@@ -101,12 +101,15 @@
}
WorkerThreadableLoader::MainThreadBridge::MainThreadBridge(ThreadableLoaderClientWrapper& workerClientWrapper, WorkerLoaderProxy& loaderProxy, const String& taskMode,
- ResourceRequest&& request, const ThreadableLoaderOptions& options, const String& outgoingReferrer,
- const SecurityOrigin* securityOrigin, const ContentSecurityPolicy* contentSecurityPolicy)
+ ResourceRequest&& request, const ThreadableLoaderOptions& options, const String& outgoingReferrer, WorkerGlobalScope& globalScope)
: m_workerClientWrapper(&workerClientWrapper)
, m_loaderProxy(loaderProxy)
, m_taskMode(taskMode.isolatedCopy())
{
+
+ auto* securityOrigin = globalScope.securityOrigin();
+ auto* contentSecurityPolicy = globalScope.contentSecurityPolicy();
+
ASSERT(securityOrigin);
ASSERT(contentSecurityPolicy);
@@ -121,6 +124,11 @@
ASSERT(optionsCopy->options.initiatorContext == InitiatorContext::Document);
optionsCopy->options.initiatorContext = InitiatorContext::Worker;
+#if ENABLE(SERVICE_WORKER)
+ optionsCopy->options.serviceWorkersMode = globalScope.isServiceWorkerGlobalScope() ? ServiceWorkersMode::None : ServiceWorkersMode::All;
+ optionsCopy->options.serviceWorkerIdentifier = globalScope.selectedServiceWorkerIdentifier();
+#endif
+
// Can we benefit from request being an r-value to create more efficiently its isolated copy?
m_loaderProxy.postTaskToLoader([this, request = request.isolatedCopy(), options = WTFMove(optionsCopy), contentSecurityPolicyCopy = WTFMove(contentSecurityPolicyCopy)](ScriptExecutionContext& context) mutable {
ASSERT(isMainThread());
Modified: trunk/Source/WebCore/loader/WorkerThreadableLoader.h (223649 => 223650)
--- trunk/Source/WebCore/loader/WorkerThreadableLoader.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/loader/WorkerThreadableLoader.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -88,7 +88,7 @@
class MainThreadBridge : public ThreadableLoaderClient {
public:
// All executed on the worker context's thread.
- MainThreadBridge(ThreadableLoaderClientWrapper&, WorkerLoaderProxy&, const String& taskMode, ResourceRequest&&, const ThreadableLoaderOptions&, const String& outgoingReferrer, const SecurityOrigin*, const ContentSecurityPolicy*);
+ MainThreadBridge(ThreadableLoaderClientWrapper&, WorkerLoaderProxy&, const String& taskMode, ResourceRequest&&, const ThreadableLoaderOptions&, const String& outgoingReferrer, WorkerGlobalScope&);
void cancel();
void destroy();
Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.h (223649 => 223650)
--- trunk/Source/WebCore/platform/network/ResourceRequestBase.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -100,7 +100,7 @@
WEBCORE_EXPORT String httpContentType() const;
WEBCORE_EXPORT void setHTTPContentType(const String&);
- void clearHTTPContentType();
+ WEBCORE_EXPORT void clearHTTPContentType();
bool hasHTTPHeader(HTTPHeaderName) const;
Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.h (223649 => 223650)
--- trunk/Source/WebCore/platform/network/ResourceResponseBase.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -153,7 +153,7 @@
return 1280;
}
- void setType(Type);
+ WEBCORE_EXPORT void setType(Type);
Type type() const { return m_type; }
void setRedirected(bool isRedirected) { m_isRedirected = isRedirected; }
Modified: trunk/Source/WebCore/workers/WorkerThread.h (223649 => 223650)
--- trunk/Source/WebCore/workers/WorkerThread.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/workers/WorkerThread.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -61,7 +61,7 @@
public:
virtual ~WorkerThread();
- bool start();
+ WEBCORE_EXPORT bool start();
void stop();
ThreadIdentifier threadID() const { return m_thread ? m_thread->id() : 0; }
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp (223649 => 223650)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2017-10-19 02:26:00 UTC (rev 223650)
@@ -179,6 +179,9 @@
return;
}
+ // FIXME: Implement proper selection of service workers.
+ context->setSelectedServiceWorkerIdentifier(data.identifier);
+
auto registration = ServiceWorkerRegistration::create(*context, data);
job.promise().resolve<IDLInterface<ServiceWorkerRegistration>>(registration.get());
}
Deleted: trunk/Source/WebCore/workers/service/context/SWContextManager.cpp (223649 => 223650)
--- trunk/Source/WebCore/workers/service/context/SWContextManager.cpp 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.cpp 2017-10-19 02:26:00 UTC (rev 223650)
@@ -1,67 +0,0 @@
-/*
- * 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.
- */
-
-#include "config.h"
-#include "SWContextManager.h"
-
-#if ENABLE(SERVICE_WORKER)
-
-#include "Logging.h"
-#include <pal/SessionID.h>
-
-using namespace PAL;
-
-namespace WebCore {
-
-SWContextManager& SWContextManager::singleton()
-{
- static SWContextManager* sharedManager = new SWContextManager;
- return *sharedManager;
-}
-
-SWContextManager::SWContextManager()
-{
-
-}
-
-ExceptionOr<uint64_t> SWContextManager::startServiceWorkerContext(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data)
-{
- // FIXME: Provide a sensical session ID
-
- auto thread = ServiceWorkerThread::create(serverConnectionIdentifier, data, SessionID::defaultSessionID());
- auto threadIdentifier = thread->identifier();
- auto result = m_workerThreadMap.add(threadIdentifier, WTFMove(thread));
- ASSERT(result.isNewEntry);
-
- result.iterator->value->start();
-
- LOG(ServiceWorker, "Context process PID: %i started worker thread %s\n", getpid(), data.workerID.utf8().data());
-
- return threadIdentifier;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SERVICE_WORKER)
Deleted: trunk/Source/WebCore/workers/service/context/SWContextManager.h (223649 => 223650)
--- trunk/Source/WebCore/workers/service/context/SWContextManager.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -1,52 +0,0 @@
-/*
- * 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 "ExceptionOr.h"
-#include "ServiceWorkerThread.h"
-#include <wtf/HashMap.h>
-
-namespace WebCore {
-
-struct ServiceWorkerContextData;
-
-class SWContextManager {
-public:
- WEBCORE_EXPORT static SWContextManager& singleton();
-
- WEBCORE_EXPORT ExceptionOr<uint64_t> startServiceWorkerContext(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&);
-
-private:
- SWContextManager();
-
- HashMap<uint64_t, RefPtr<ServiceWorkerThread>> m_workerThreadMap;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h (223649 => 223650)
--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -52,7 +52,7 @@
void runEventLoop() override;
private:
- ServiceWorkerThread(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID);
+ WEBCORE_EXPORT ServiceWorkerThread(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID);
uint64_t m_serverConnectionIdentifier;
ServiceWorkerContextData m_data;
Modified: trunk/Source/WebKit/CMakeLists.txt (223649 => 223650)
--- trunk/Source/WebKit/CMakeLists.txt 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/CMakeLists.txt 2017-10-19 02:26:00 UTC (rev 223650)
@@ -683,6 +683,7 @@
WebProcess/Plugins/PluginProcessConnectionManager.messages.in
WebProcess/Plugins/PluginProxy.messages.in
+ WebProcess/Storage/ServiceWorkerClientFetch.messages.in
WebProcess/Storage/WebSWClientConnection.messages.in
WebProcess/UserContent/WebUserContentController.messages.in
Modified: trunk/Source/WebKit/ChangeLog (223649 => 223650)
--- trunk/Source/WebKit/ChangeLog 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/ChangeLog 2017-10-19 02:26:00 UTC (rev 223650)
@@ -1,3 +1,84 @@
+2017-10-18 Youenn Fablet <[email protected]>
+
+ Add preliminary support for ServiceWorker Handle Fetch
+ https://bugs.webkit.org/show_bug.cgi?id=178475
+
+ Reviewed by Chris Dumez.
+
+ Preliminary support of Handle Fetch algorithm and integration with fetch spec.
+ Adding ServiceWorkerClientFetch as the class responsible to do the load through ServiceWorker.
+ It is similar to WebResourceLoader that do the load through NetworkProcess.
+ In case ServiceWorkerClientFetch is not able to load through ServiceWorker,
+ it will fallback to WebResourceLoader through a fallback callback.
+
+ Loading through Service Worker is done currently if:
+ - There is a service worker registered for that origin
+ - Request is a subresource
+ - service workers mode is all
+ There will be cases where the service worker will not do the loading, for instance when fetch event handler is not set.
+ Future work should try to reduce the cases where the IPC dance is done unnecessarily.
+
+ ServiceWorkerClientFetch is responsible to adapt the ServiceWorker response to ResourceLoader.
+ In particular, it is calling ResourceLoader error callback if response is of type error.
+ It should call ResourceLoader redirection callback if response is a redirection response.
+ This will be done as a follow-up.
+
+ Implementing the IPC communication dedicated to fetch between WebProcess and ServiceWorker through StorageProcess.
+ In the future, WebProcess should create a direct IPC communication to the ServiceWorker process.
+
+ Moved SWContextManager from WebCore to WebKit and renamed it to ServiceWorkerContextManager.
+ This class is moved to WebKit as it will have to handle IPC and having a separation will add some unnecessary boilerplate.
+
+ * DerivedSources.make:
+ * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+ (WebKit::WebSWServerConnection::startFetch):
+ (WebKit::WebSWServerConnection::didReceiveFetchResponse):
+ (WebKit::WebSWServerConnection::didReceiveFetchData):
+ (WebKit::WebSWServerConnection::didFinishFetch):
+ (WebKit::WebSWServerConnection::failedFetch):
+ * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+ * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
+ * StorageProcess/StorageProcess.cpp:
+ (WebKit::StorageProcess::failedFetch):
+ (WebKit::StorageProcess::didReceiveFetchResponse):
+ (WebKit::StorageProcess::didReceiveFetchData):
+ (WebKit::StorageProcess::didFinishFetch):
+ * StorageProcess/StorageProcess.h:
+ * StorageProcess/StorageProcess.messages.in:
+ * WebKit.xcodeproj/project.pbxproj:
+ * WebProcess/Network/WebLoaderStrategy.cpp:
+ (WebKit::WebLoaderStrategy::scheduleLoad):
+ (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
+ * WebProcess/Network/WebLoaderStrategy.h:
+ * WebProcess/Storage/ServiceWorkerClientFetch.cpp: Added.
+ (WebKit::ServiceWorkerClientFetch::didReceiveResponse):
+ (WebKit::ServiceWorkerClientFetch::didReceiveData):
+ (WebKit::ServiceWorkerClientFetch::didFinishFetch):
+ (WebKit::ServiceWorkerClientFetch::didFail):
+ * WebProcess/Storage/ServiceWorkerClientFetch.h: Added.
+ * WebProcess/Storage/ServiceWorkerClientFetch.messages.in: Added.
+ * WebProcess/Storage/ServiceWorkerContextManager.cpp: Renamed from Source/WebCore/workers/service/context/SWContextManager.cpp.
+ (WebKit::ServiceWorkerContextManager::startServiceWorkerContext):
+ (WebKit::ServiceWorkerContextManager::startFetch):
+ * WebProcess/Storage/ServiceWorkerContextManager.h: Renamed from Source/WebCore/workers/service/context/SWContextManager.h.
+ (WebKit::ServiceWorkerContextManager::ServiceWorkerContextManager):
+ * WebProcess/Storage/WebSWClientConnection.cpp:
+ (WebKit::WebSWClientConnection::startFetch):
+ * WebProcess/Storage/WebSWClientConnection.h:
+ * WebProcess/Storage/WebServiceWorkerProvider.cpp:
+ (WebKit::shouldHandleFetch):
+ (WebKit::WebServiceWorkerProvider::handleFetch):
+ (WebKit::WebServiceWorkerProvider::didReceiveServiceWorkerClientFetchMessage):
+ * WebProcess/Storage/WebServiceWorkerProvider.h:
+ * WebProcess/Storage/WebToStorageProcessConnection.cpp:
+ (WebKit::WebToStorageProcessConnection::didReceiveMessage):
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::getWorkerContextConnection):
+ (WebKit::WebProcess::startServiceWorkerContext):
+ (WebKit::WebProcess::startFetchInServiceWorker):
+ * WebProcess/WebProcess.h:
+ * WebProcess/WebProcess.messages.in:
+
2017-10-18 Chelsea Pugh <[email protected]>
[iOS] Use new class name from UIKit when checking UITextSuggestion type
Modified: trunk/Source/WebKit/DerivedSources.make (223649 => 223650)
--- trunk/Source/WebKit/DerivedSources.make 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/DerivedSources.make 2017-10-19 02:26:00 UTC (rev 223650)
@@ -125,6 +125,7 @@
RemoteWebInspectorProxy \
RemoteWebInspectorUI \
SecItemShimProxy \
+ ServiceWorkerClientFetch \
SmartMagnificationController \
StorageAreaMap \
StorageManager \
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (223649 => 223650)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp 2017-10-19 02:26:00 UTC (rev 223650)
@@ -30,8 +30,10 @@
#include "DataReference.h"
#include "Logging.h"
+#include "ServiceWorkerClientFetchMessages.h"
#include "StorageProcess.h"
#include "StorageToWebProcessConnectionMessages.h"
+#include "WebCoreArgumentCoders.h"
#include "WebProcess.h"
#include "WebProcessMessages.h"
#include "WebSWClientConnectionMessages.h"
@@ -92,6 +94,31 @@
m_pendingContextDatas.append(data);
}
+void WebSWServerConnection::startFetch(uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const ResourceRequest& request, const FetchOptions& options)
+{
+ sendToContextProcess(Messages::WebProcess::StartFetchInServiceWorker(identifier(), fetchIdentifier, serviceWorkerIdentifier, request, options));
+}
+
+void WebSWServerConnection::didReceiveFetchResponse(uint64_t fetchIdentifier, const ResourceResponse& response)
+{
+ m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidReceiveResponse { response }, fetchIdentifier);
+}
+
+void WebSWServerConnection::didReceiveFetchData(uint64_t fetchIdentifier, const IPC::DataReference& data, int64_t encodedDataLength)
+{
+ m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidReceiveData { data, encodedDataLength }, fetchIdentifier);
+}
+
+void WebSWServerConnection::didFinishFetch(uint64_t fetchIdentifier)
+{
+ m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidFinish { }, fetchIdentifier);
+}
+
+void WebSWServerConnection::didFailFetch(uint64_t fetchIdentifier)
+{
+ m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidFail { }, fetchIdentifier);
+}
+
template<typename U> bool WebSWServerConnection::sendToContextProcess(U&& message)
{
if (!m_contextConnection)
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h (223649 => 223650)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -51,6 +51,11 @@
PAL::SessionID sessionID() const { return m_sessionID; }
+ void didReceiveFetchResponse(uint64_t fetchIdentifier, const WebCore::ResourceResponse&);
+ void didReceiveFetchData(uint64_t fetchIdentifier, const IPC::DataReference&, int64_t encodedDataLength);
+ void didFinishFetch(uint64_t fetchIdentifier);
+ void didFailFetch(uint64_t fetchIdentifier);
+
private:
// Implement SWServer::Connection (Messages to the client WebProcess)
void rejectJobInClient(uint64_t jobIdentifier, const WebCore::ExceptionData&) final;
@@ -57,9 +62,11 @@
void resolveJobInClient(uint64_t jobIdentifier, const WebCore::ServiceWorkerRegistrationData&) final;
void startScriptFetchInClient(uint64_t jobIdentifier) final;
+ void startFetch(uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&);
+
// Messages to the SW context WebProcess
void startServiceWorkerContext(const WebCore::ServiceWorkerContextData&) final;
-
+
IPC::Connection* messageSenderConnection() final { return m_contentConnection.ptr(); }
uint64_t messageSenderDestinationID() final { return identifier(); }
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in (223649 => 223650)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in 2017-10-19 02:26:00 UTC (rev 223650)
@@ -26,6 +26,8 @@
# When possible, these messages can be implemented directly by WebCore::SWClientConnection
ScheduleJobInServer(struct WebCore::ServiceWorkerJobData jobData)
FinishFetchingScriptInServer(struct WebCore::ServiceWorkerFetchResult result)
+
+ StartFetch(uint64_t identifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options)
}
#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebKit/StorageProcess/StorageProcess.cpp (223649 => 223650)
--- trunk/Source/WebKit/StorageProcess/StorageProcess.cpp 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.cpp 2017-10-19 02:26:00 UTC (rev 223650)
@@ -405,6 +405,30 @@
connection->scriptContextStarted(registrationKey, identifier, workerID);
}
+void StorageProcess::didFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
+{
+ if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier))
+ connection->didFailFetch(fetchIdentifier);
+}
+
+void StorageProcess::didReceiveFetchResponse(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const WebCore::ResourceResponse& response)
+{
+ if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier))
+ connection->didReceiveFetchResponse(fetchIdentifier, response);
+}
+
+void StorageProcess::didReceiveFetchData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const IPC::DataReference& data, int64_t encodedDataLength)
+{
+ if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier))
+ connection->didReceiveFetchData(fetchIdentifier, data, encodedDataLength);
+}
+
+void StorageProcess::didFinishFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
+{
+ if (auto* connection = m_swServerConnections.get(serverConnectionIdentifier))
+ connection->didFinishFetch(fetchIdentifier);
+}
+
void StorageProcess::registerSWServerConnection(WebSWServerConnection& connection)
{
ASSERT(!m_swServerConnections.contains(connection.identifier()));
Modified: trunk/Source/WebKit/StorageProcess/StorageProcess.h (223649 => 223650)
--- trunk/Source/WebKit/StorageProcess/StorageProcess.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -119,6 +119,11 @@
void didGetWorkerContextProcessConnection(const IPC::Attachment& encodedConnectionIdentifier);
void serviceWorkerContextFailedToStart(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerRegistrationKey&, const String& workerID, const String& message);
void serviceWorkerContextStarted(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerRegistrationKey&, uint64_t identifier, const String& workerID);
+
+ void didReceiveFetchResponse(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const WebCore::ResourceResponse&);
+ void didReceiveFetchData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, const IPC::DataReference&, int64_t encodedDataLength);
+ void didFinishFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier);
+ void didFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier);
#endif
#if ENABLE(INDEXED_DATABASE)
Vector<WebCore::SecurityOriginData> indexedDatabaseOrigins(const String& path);
Modified: trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in (223649 => 223650)
--- trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in 2017-10-19 02:26:00 UTC (rev 223650)
@@ -37,7 +37,13 @@
#if ENABLE(SERVICE_WORKER)
DidGetWorkerContextProcessConnection(IPC::Attachment connectionHandle)
+
ServiceWorkerContextFailedToStart(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerRegistrationKey registrationKey, String workerID, String message)
ServiceWorkerContextStarted(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerRegistrationKey registrationKey, uint64_t identifier, String workerID)
+
+ DidFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
+ DidReceiveFetchResponse(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, WebCore::ResourceResponse response)
+ DidReceiveFetchData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, IPC::DataReference data, int64_t encodedDataLength)
+ DidFinishFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier)
#endif
}
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (223649 => 223650)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2017-10-19 02:26:00 UTC (rev 223650)
@@ -890,6 +890,9 @@
413075B21DE85F580039EC69 /* LibWebRTCSocketFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075A61DE85EE70039EC69 /* LibWebRTCSocketFactory.h */; };
413075B31DE85F580039EC69 /* LibWebRTCProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 413075A71DE85EE70039EC69 /* LibWebRTCProvider.cpp */; };
413075B41DE85F580039EC69 /* LibWebRTCProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 413075A81DE85EE70039EC69 /* LibWebRTCProvider.h */; };
+ 4131F3D11F96BCCC0059995A /* ServiceWorkerClientFetch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4131F3D01F96BCC80059995A /* ServiceWorkerClientFetch.cpp */; };
+ 4131F3D41F96E9350059995A /* ServiceWorkerContextManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4131F3D31F96E9310059995A /* ServiceWorkerContextManager.cpp */; };
+ 4131F3D51F96E9350059995A /* ServiceWorkerContextManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 4131F3D21F96E9300059995A /* ServiceWorkerContextManager.h */; };
4135FBD11F4FB8090074C47B /* CacheStorageEngineCaches.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4135FBCF1F4FB7F20074C47B /* CacheStorageEngineCaches.cpp */; };
41897ECF1F415D620016FA42 /* WebCacheStorageConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41897ECE1F415D5C0016FA42 /* WebCacheStorageConnection.cpp */; };
41897ED01F415D650016FA42 /* WebCacheStorageProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41897ECC1F415D5C0016FA42 /* WebCacheStorageProvider.cpp */; };
@@ -1029,7 +1032,9 @@
5179556A162876F300FA43B6 /* NetworkProcess.h in Headers */ = {isa = PBXBuildFile; fileRef = 510CC7E016138E2900D03ED3 /* NetworkProcess.h */; };
5179556D162877B100FA43B6 /* NetworkProcessProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510CC7EA16138E7200D03ED3 /* NetworkProcessProxy.cpp */; };
5179556E162877B300FA43B6 /* NetworkProcessProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 510CC7EB16138E7200D03ED3 /* NetworkProcessProxy.h */; };
+ 617A52D81F43A9DA00DCDC0A /* ServiceWorkerClientFetchMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 617A52D71F43A9B600DCDC0A /* ServiceWorkerClientFetchConnectionMessageReceiver.cpp */; };
517A52D81F43A9DA00DCDC0A /* WebSWServerConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A52D71F43A9B600DCDC0A /* WebSWServerConnectionMessageReceiver.cpp */; };
+ 617A52D91F43A9DA00DCDC0A /* ServiceWorkerClientFetchMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 617A52D61F43A9B600DCDC0A /* ServiceWorkerClientFetchMessages.h */; };
517A52D91F43A9DA00DCDC0A /* WebSWServerConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A52D61F43A9B600DCDC0A /* WebSWServerConnectionMessages.h */; };
517A53041F4793C600DCDC0A /* WebSWClientConnection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A53031F4793B200DCDC0A /* WebSWClientConnection.cpp */; };
517A53051F4793C600DCDC0A /* WebSWClientConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A53021F4793B200DCDC0A /* WebSWClientConnection.h */; };
@@ -3178,6 +3183,11 @@
413075A61DE85EE70039EC69 /* LibWebRTCSocketFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCSocketFactory.h; path = Network/webrtc/LibWebRTCSocketFactory.h; sourceTree = "<group>"; };
413075A71DE85EE70039EC69 /* LibWebRTCProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = LibWebRTCProvider.cpp; path = Network/webrtc/LibWebRTCProvider.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
413075A81DE85EE70039EC69 /* LibWebRTCProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = LibWebRTCProvider.h; path = Network/webrtc/LibWebRTCProvider.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
+ 4131F3CE1F96A4950059995A /* ServiceWorkerClientFetch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerClientFetch.h; sourceTree = "<group>"; };
+ 4131F3CF1F96A9360059995A /* ServiceWorkerClientFetch.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ServiceWorkerClientFetch.messages.in; sourceTree = "<group>"; };
+ 4131F3D01F96BCC80059995A /* ServiceWorkerClientFetch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerClientFetch.cpp; sourceTree = "<group>"; };
+ 4131F3D21F96E9300059995A /* ServiceWorkerContextManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerContextManager.h; sourceTree = "<group>"; };
+ 4131F3D31F96E9310059995A /* ServiceWorkerContextManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerContextManager.cpp; sourceTree = "<group>"; };
4135FBCF1F4FB7F20074C47B /* CacheStorageEngineCaches.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CacheStorageEngineCaches.cpp; sourceTree = "<group>"; };
4135FBD01F4FB7F20074C47B /* CacheStorageEngineCaches.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageEngineCaches.h; sourceTree = "<group>"; };
41897ECB1F415D5C0016FA42 /* WebCacheStorageConnection.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebCacheStorageConnection.messages.in; sourceTree = "<group>"; };
@@ -3334,7 +3344,9 @@
516A4A5B120A2CCD00C05B7F /* APIError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIError.h; sourceTree = "<group>"; };
517A33B3130B308C00F80CB5 /* WKApplicationCacheManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKApplicationCacheManager.cpp; sourceTree = "<group>"; };
517A33B4130B308C00F80CB5 /* WKApplicationCacheManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKApplicationCacheManager.h; sourceTree = "<group>"; };
+ 617A52D61F43A9B600DCDC0A /* ServiceWorkerFetchClientMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWServerConnectionMessages.h; sourceTree = "<group>"; };
517A52D61F43A9B600DCDC0A /* WebSWServerConnectionMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWServerConnectionMessages.h; sourceTree = "<group>"; };
+ 617A52D71F43A9B600DCDC0A /* ServiceWorkerClientFetchMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerClientFetchMessageReceiver.cpp; sourceTree = "<group>"; };
517A52D71F43A9B600DCDC0A /* WebSWServerConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSWServerConnectionMessageReceiver.cpp; sourceTree = "<group>"; };
517A53021F4793B200DCDC0A /* WebSWClientConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWClientConnection.h; sourceTree = "<group>"; };
517A53031F4793B200DCDC0A /* WebSWClientConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSWClientConnection.cpp; sourceTree = "<group>"; };
@@ -6168,6 +6180,11 @@
5118E9981F295259003EF9F5 /* Storage */ = {
isa = PBXGroup;
children = (
+ 4131F3D01F96BCC80059995A /* ServiceWorkerClientFetch.cpp */,
+ 4131F3CE1F96A4950059995A /* ServiceWorkerClientFetch.h */,
+ 4131F3CF1F96A9360059995A /* ServiceWorkerClientFetch.messages.in */,
+ 4131F3D31F96E9310059995A /* ServiceWorkerContextManager.cpp */,
+ 4131F3D21F96E9300059995A /* ServiceWorkerContextManager.h */,
51BEB6291F3A5ACD005029B9 /* WebServiceWorkerProvider.cpp */,
51BEB62A1F3A5ACD005029B9 /* WebServiceWorkerProvider.h */,
517A53031F4793B200DCDC0A /* WebSWClientConnection.cpp */,
@@ -8010,6 +8027,7 @@
1BBBE49E19B66C53006B7D81 /* RemoteWebInspectorUIMessageReceiver.cpp */,
E18E6913169B667B009B6670 /* SecItemShimProxyMessageReceiver.cpp */,
E18E6914169B667B009B6670 /* SecItemShimProxyMessages.h */,
+ 617A52D71F43A9B600DCDC0A /* ServiceWorkerClientFetchConnectionMessageReceiver.cpp */,
2DE6943B18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp */,
2DE6943C18BD2A68005C15E5 /* SmartMagnificationControllerMessages.h */,
1A334DEB16DE8F88006A8E38 /* StorageAreaMapMessageReceiver.cpp */,
@@ -8781,6 +8799,7 @@
E18E690C169B563F009B6670 /* SecItemShimProxy.h in Headers */,
E18E6918169B667B009B6670 /* SecItemShimProxyMessages.h in Headers */,
514D9F5719119D35000063A7 /* ServicesController.h in Headers */,
+ 4131F3D51F96E9350059995A /* ServiceWorkerContextManager.h in Headers */,
1AFDE65A1954A42B00C48FFA /* SessionState.h in Headers */,
1A002D49196B345D00B9AD44 /* SessionStateCoding.h in Headers */,
753E3E0E1887398900188496 /* SessionTracker.h in Headers */,
@@ -10370,6 +10389,9 @@
E18E690B169B563F009B6670 /* SecItemShimProxy.cpp in Sources */,
E18E6917169B667B009B6670 /* SecItemShimProxyMessageReceiver.cpp in Sources */,
514D9F5819119D35000063A7 /* ServicesController.mm in Sources */,
+ 4131F3D11F96BCCC0059995A /* ServiceWorkerClientFetch.cpp in Sources */,
+ 617A52D81F43A9DA00DCDC0A /* ServiceWorkerClientFetchConnectionMessageReceiver.cpp in Sources */,
+ 4131F3D41F96E9350059995A /* ServiceWorkerContextManager.cpp in Sources */,
1AFDE6591954A42B00C48FFA /* SessionState.cpp in Sources */,
1A002D48196B345D00B9AD44 /* SessionStateCoding.mm in Sources */,
1A7284481959F8040007BCE5 /* SessionStateConversion.cpp in Sources */,
Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (223649 => 223650)
--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp 2017-10-19 02:26:00 UTC (rev 223650)
@@ -43,6 +43,7 @@
#include "WebPageProxyMessages.h"
#include "WebProcess.h"
#include "WebResourceLoader.h"
+#include "WebServiceWorkerProvider.h"
#include "WebURLSchemeHandlerProxy.h"
#include "WebURLSchemeTaskProxy.h"
#include <WebCore/ApplicationCacheHost.h>
@@ -215,6 +216,29 @@
}
}
+#if ENABLE(SERVICE_WORKER)
+ WebServiceWorkerProvider::singleton().handleFetch(resourceLoader, resource, webPage ? webPage->sessionID() : PAL::SessionID::defaultSessionID(), [trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime = maximumBufferingTime(resource), resourceLoader = makeRef(resourceLoader)] (ServiceWorkerClientFetch::Result result) mutable {
+ if (result != ServiceWorkerClientFetch::Result::Unhandled)
+ return;
+
+ LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be scheduled through ServiceWorker handle fetch algorithm", resourceLoader->url().string().latin1().data());
+ WebProcess::singleton().webLoaderStrategy().scheduleLoadFromNetworkProcess(resourceLoader.get(), resourceLoader->originalRequest(), WTFMove(trackingParameters), shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime);
+ });
+#else
+ LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be scheduled through ServiceWorker handle fetch algorithm", resourceLoader.url().string().latin1().data());
+ scheduleLoadFromNetworkProcess(resourceLoader, resourceLoader.request(), trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime(resource));
+#endif
+}
+
+void WebLoaderStrategy::scheduleLoadFromNetworkProcess(ResourceLoader& resourceLoader, const ResourceRequest& request, const WebResourceLoader::TrackingParameters& trackingParameters, bool shouldClearReferrerOnHTTPSToHTTPRedirect, Seconds maximumBufferingTime)
+{
+ ResourceLoadIdentifier identifier = resourceLoader.identifier();
+ ASSERT(identifier);
+
+ WebFrameLoaderClient* webFrameLoaderClient = toWebFrameLoaderClient(resourceLoader.frameLoader()->client());
+ WebFrame* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr;
+ WebPage* webPage = webFrame ? webFrame->page() : nullptr;
+
LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be scheduled with the NetworkProcess with priority %d", resourceLoader.url().string().latin1().data(), static_cast<int>(resourceLoader.request().priority()));
ContentSniffingPolicy contentSniffingPolicy = resourceLoader.shouldSniffContent() ? SniffContent : DoNotSniffContent;
@@ -225,7 +249,7 @@
loadParameters.webPageID = webPage ? webPage->pageID() : 0;
loadParameters.webFrameID = webFrame ? webFrame->frameID() : 0;
loadParameters.sessionID = webPage ? webPage->sessionID() : PAL::SessionID::defaultSessionID();
- loadParameters.request = resourceLoader.request();
+ loadParameters.request = request;
loadParameters.contentSniffingPolicy = contentSniffingPolicy;
loadParameters.storedCredentialsPolicy = storedCredentialsPolicy;
// If there is no WebFrame then this resource cannot be authenticated with the client.
@@ -233,7 +257,7 @@
loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = shouldClearReferrerOnHTTPSToHTTPRedirect;
loadParameters.defersLoading = resourceLoader.defersLoading();
loadParameters.needsCertificateInfo = resourceLoader.shouldIncludeCertificateInfo();
- loadParameters.maximumBufferingTime = maximumBufferingTime(resource);
+ loadParameters.maximumBufferingTime = maximumBufferingTime;
loadParameters.derivedCachedDataTypesToRetrieve = resourceLoader.options().derivedCachedDataTypesToRetrieve;
ASSERT((loadParameters.webPageID && loadParameters.webFrameID) || loadParameters.clientCredentialPolicy == ClientCredentialPolicy::CannotAskClientForCredentials);
@@ -300,7 +324,12 @@
LOG_ERROR("WebLoaderStrategy removing a ResourceLoader that has no identifier.");
return;
}
-
+
+#if ENABLE(SERVICE_WORKER)
+ if (WebServiceWorkerProvider::singleton().cancelFetch(identifier))
+ return;
+#endif
+
RefPtr<WebResourceLoader> loader = m_webResourceLoaders.take(identifier);
// Loader may not be registered if we created it, but haven't scheduled yet (a bundle client can decide to cancel such request via willSendRequest).
if (!loader)
Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h (223649 => 223650)
--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -77,6 +77,8 @@
void addURLSchemeTaskProxy(WebURLSchemeTaskProxy&);
void removeURLSchemeTaskProxy(WebURLSchemeTaskProxy&);
+ void scheduleLoadFromNetworkProcess(WebCore::ResourceLoader&, const WebCore::ResourceRequest&, const WebResourceLoader::TrackingParameters&, bool shouldClearReferrerOnHTTPSToHTTPRedirect, Seconds maximumBufferingTime);
+
private:
void scheduleLoad(WebCore::ResourceLoader&, WebCore::CachedResource*, bool shouldClearReferrerOnHTTPSToHTTPRedirect);
void scheduleInternallyFailedLoad(WebCore::ResourceLoader&);
Added: trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp (0 => 223650)
--- trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp (rev 0)
+++ trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp 2017-10-19 02:26:00 UTC (rev 223650)
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "ServiceWorkerClientFetch.h"
+
+#if ENABLE(SERVICE_WORKER)
+
+#include "DataReference.h"
+#include "WebServiceWorkerProvider.h"
+#include <WebCore/NotImplemented.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+ServiceWorkerClientFetch::ServiceWorkerClientFetch(WebServiceWorkerProvider& serviceWorkerProvider, Ref<WebCore::ResourceLoader>&& loader, uint64_t identifier, Ref<IPC::Connection>&& connection, Callback&& callback)
+ : m_serviceWorkerProvider(serviceWorkerProvider)
+ , m_loader(WTFMove(loader))
+ , m_identifier(identifier)
+ , m_connection(WTFMove(connection))
+ , m_callback(WTFMove(callback))
+{
+}
+
+void ServiceWorkerClientFetch::didReceiveResponse(const WebCore::ResourceResponse& response)
+{
+ auto protectedThis = makeRef(*this);
+
+ if (!(response.httpStatusCode() <= 300 || response.httpStatusCode() >= 400 || response.httpStatusCode() == 304 || response.httpStatusCode() == 305 || response.httpStatusCode() == 306)) {
+ // FIXME: Support redirections.
+ notImplemented();
+ m_loader->didFail({ });
+ if (auto callback = WTFMove(m_callback))
+ callback(Result::Succeeded);
+ return;
+ }
+
+ if (response.type() == ResourceResponse::Type::Error) {
+ // Add support for a better error.
+ m_loader->didFail({ });
+ if (auto callback = WTFMove(m_callback))
+ callback(Result::Succeeded);
+ return;
+ }
+
+ m_loader->didReceiveResponse(response);
+ if (auto callback = WTFMove(m_callback))
+ callback(Result::Succeeded);
+}
+
+void ServiceWorkerClientFetch::didReceiveData(const IPC::DataReference& data, int64_t encodedDataLength)
+{
+ m_loader->didReceiveData(reinterpret_cast<const char*>(data.data()), data.size(), encodedDataLength, DataPayloadBytes);
+}
+
+void ServiceWorkerClientFetch::didFinish()
+{
+ ASSERT(!m_callback);
+
+ auto protectedThis = makeRef(*this);
+ m_loader->didFinishLoading(NetworkLoadMetrics { });
+ m_serviceWorkerProvider.fetchFinished(m_identifier);
+}
+
+void ServiceWorkerClientFetch::didFail()
+{
+ if (auto callback = WTFMove(m_callback))
+ callback(Result::Unhandled);
+
+ m_serviceWorkerProvider.fetchFinished(m_identifier);
+}
+
+void ServiceWorkerClientFetch::cancel()
+{
+ if (auto callback = WTFMove(m_callback))
+ callback(Result::Cancelled);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(SERVICE_WORKER)
Copied: trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.h (from rev 223649, trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h) (0 => 223650)
--- trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.h (rev 0)
+++ trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -0,0 +1,74 @@
+/*
+ * 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 "MessageReceiver.h"
+#include "MessageSender.h"
+#include <WebCore/ResourceLoader.h>
+#include <wtf/CompletionHandler.h>
+
+namespace WebKit {
+
+class WebServiceWorkerProvider;
+
+class ServiceWorkerClientFetch final : public RefCounted<ServiceWorkerClientFetch>, public IPC::MessageSender, public IPC::MessageReceiver {
+public:
+ enum class Result { Succeeded, Cancelled, Unhandled };
+ using Callback = WTF::CompletionHandler<void(Result)>;
+
+ static Ref<ServiceWorkerClientFetch> create(WebServiceWorkerProvider& serviceWorkerProvider, Ref<WebCore::ResourceLoader>&& loader, uint64_t identifier, Ref<IPC::Connection>&& connection, Callback&& callback)
+ {
+ return adoptRef(*new ServiceWorkerClientFetch { serviceWorkerProvider, WTFMove(loader), identifier, WTFMove(connection), WTFMove(callback) });
+ }
+
+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
+ void cancel();
+
+ bool isOngoing() const { return !!m_callback; }
+
+private:
+ ServiceWorkerClientFetch(WebServiceWorkerProvider&, Ref<WebCore::ResourceLoader>&&, uint64_t identifier, Ref<IPC::Connection>&&, Callback&&);
+
+ void didReceiveResponse(const WebCore::ResourceResponse&);
+ void didReceiveData(const IPC::DataReference&, int64_t encodedDataLength);
+ void didFinish();
+ void didFail();
+
+ IPC::Connection* messageSenderConnection() final { return m_connection.ptr(); }
+ uint64_t messageSenderDestinationID() final { return m_identifier; }
+
+ WebServiceWorkerProvider& m_serviceWorkerProvider;
+ Ref<WebCore::ResourceLoader> m_loader;
+ uint64_t m_identifier { 0 };
+ Ref<IPC::Connection> m_connection;
+ Callback m_callback;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(SERVICE_WORKER)
Copied: trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.messages.in (from rev 223649, trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in) (0 => 223650)
--- trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.messages.in (rev 0)
+++ trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.messages.in 2017-10-19 02:26:00 UTC (rev 223650)
@@ -0,0 +1,32 @@
+# 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.
+
+#if ENABLE(SERVICE_WORKER)
+
+messages -> ServiceWorkerClientFetch {
+ DidReceiveResponse(WebCore::ResourceResponse response)
+ DidReceiveData(IPC::DataReference data, int64_t encodedDataLength)
+ DidFinish()
+ DidFail()
+}
+
+#endif // ENABLE(SERVICE_WORKER)
Added: trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.cpp (0 => 223650)
--- trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.cpp (rev 0)
+++ trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.cpp 2017-10-19 02:26:00 UTC (rev 223650)
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "ServiceWorkerContextManager.h"
+
+#if ENABLE(SERVICE_WORKER)
+
+#include "Logging.h"
+#include "StorageProcessMessages.h"
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/ResourceRequest.h>
+#include <WebCore/ResourceResponse.h>
+#include <pal/SessionID.h>
+
+using namespace PAL;
+using namespace WebCore;
+
+namespace WebKit {
+
+void ServiceWorkerContextManager::startServiceWorkerContext(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data)
+{
+ // FIXME: Provide a sensical session ID.
+ auto thread = ServiceWorkerThread::create(serverConnectionIdentifier, data, SessionID::defaultSessionID());
+ auto threadIdentifier = thread->identifier();
+ auto result = m_workerThreadMap.add(threadIdentifier, WTFMove(thread));
+ ASSERT(result.isNewEntry);
+
+ result.iterator->value->start();
+
+ LOG(ServiceWorker, "Context process PID: %i started worker thread %s\n", getpid(), data.workerID.utf8().data());
+
+ m_connectionToStorageProcess->send(Messages::StorageProcess::ServiceWorkerContextStarted(serverConnectionIdentifier, data.registrationKey, threadIdentifier, data.workerID), 0);
+}
+
+void ServiceWorkerContextManager::startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const ResourceRequest& request, const FetchOptions& options)
+{
+ UNUSED_PARAM(serviceWorkerIdentifier);
+
+ // FIXME: Hard coding some fetches for testing purpose until we implement the creation of fetch event.
+ if (request.url().string().contains("test1")) {
+ ResourceResponse response;
+ response.setURL(request.url());
+ response.setHTTPStatusCode(200);
+ response.setHTTPStatusText(ASCIILiteral("Hello from service worker"));
+ m_connectionToStorageProcess->send(Messages::StorageProcess::DidReceiveFetchResponse(serverConnectionIdentifier, fetchIdentifier, response), 0);
+ m_connectionToStorageProcess->send(Messages::StorageProcess::DidFinishFetch(serverConnectionIdentifier, fetchIdentifier), 0);
+ return;
+ }
+ if (request.url().string().contains("test2")) {
+ ResourceResponse response;
+ response.setURL(request.url());
+ response.setHTTPStatusCode(500);
+ response.setHTTPStatusText(ASCIILiteral("Error from service worker"));
+ m_connectionToStorageProcess->send(Messages::StorageProcess::DidReceiveFetchResponse(serverConnectionIdentifier, fetchIdentifier, response), 0);
+ m_connectionToStorageProcess->send(Messages::StorageProcess::DidFinishFetch(serverConnectionIdentifier, fetchIdentifier), 0);
+ return;
+ }
+ if (request.url().string().contains("test3")) {
+ ResourceResponse response;
+ response.setURL(request.url());
+ response.setHTTPStatusCode(500);
+ response.setHTTPStatusText(ASCIILiteral("Error from service worker"));
+ response.setType(ResourceResponse::Type::Error);
+ m_connectionToStorageProcess->send(Messages::StorageProcess::DidReceiveFetchResponse(serverConnectionIdentifier, fetchIdentifier, response), 0);
+ m_connectionToStorageProcess->send(Messages::StorageProcess::DidFinishFetch(serverConnectionIdentifier, fetchIdentifier), 0);
+ return;
+ }
+
+ m_connectionToStorageProcess->send(Messages::StorageProcess::DidFailFetch(serverConnectionIdentifier, fetchIdentifier), 0);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)
Copied: trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h (from rev 223649, trunk/Source/WebCore/workers/service/context/SWContextManager.h) (0 => 223650)
--- trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h (rev 0)
+++ trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -0,0 +1,59 @@
+/*
+ * 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 "Connection.h"
+#include <WebCore/ServiceWorkerThread.h>
+#include <wtf/HashMap.h>
+
+namespace WebCore {
+struct FetchOptions;
+class ResourceRequest;
+struct ServiceWorkerContextData;
+}
+
+namespace WebKit {
+
+class ServiceWorkerContextManager {
+public:
+ explicit ServiceWorkerContextManager(Ref<IPC::Connection>&& connection)
+ : m_connectionToStorageProcess(WTFMove(connection))
+ {
+ }
+
+ void startServiceWorkerContext(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&);
+ void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&);
+
+private:
+ Ref<IPC::Connection> m_connectionToStorageProcess;
+ HashMap<uint64_t, RefPtr<WebCore::ServiceWorkerThread>> m_workerThreadMap;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp (223649 => 223650)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp 2017-10-19 02:26:00 UTC (rev 223650)
@@ -29,6 +29,7 @@
#if ENABLE(SERVICE_WORKER)
#include "Logging.h"
+#include "ServiceWorkerClientFetch.h"
#include "StorageToWebProcessConnectionMessages.h"
#include "WebCoreArgumentCoders.h"
#include "WebSWOriginTable.h"
@@ -75,6 +76,15 @@
m_swOriginTable->setSharedMemory(handle);
}
+Ref<ServiceWorkerClientFetch> WebSWClientConnection::startFetch(WebServiceWorkerProvider& provider, Ref<WebCore::ResourceLoader>&& loader, uint64_t identifier, ServiceWorkerClientFetch::Callback&& callback)
+{
+ ASSERT(loader->options().serviceWorkersMode == ServiceWorkersMode::All);
+ // FIXME: Decide whether to assert for loader->options().serviceWorkerIdentifier once we have a story for navigation loads.
+
+ send(Messages::WebSWServerConnection::StartFetch(identifier, loader->options().serviceWorkerIdentifier, loader->originalRequest(), loader->options()));
+ return ServiceWorkerClientFetch::create(provider, WTFMove(loader), identifier, m_connection.get(), WTFMove(callback));
+}
+
} // namespace WebKit
#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h (223649 => 223650)
--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -30,6 +30,7 @@
#include "Connection.h"
#include "MessageReceiver.h"
#include "MessageSender.h"
+#include "ServiceWorkerClientFetch.h"
#include "SharedMemory.h"
#include <WebCore/SWClientConnection.h>
#include <pal/SessionID.h>
@@ -37,11 +38,13 @@
namespace WebCore {
struct ExceptionData;
+class ResourceLoader;
}
namespace WebKit {
class WebSWOriginTable;
+class WebServiceWorkerProvider;
class WebSWClientConnection : public WebCore::SWClientConnection, public IPC::MessageSender, public IPC::MessageReceiver {
public:
@@ -58,6 +61,7 @@
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
bool hasServiceWorkerRegisteredForOrigin(const WebCore::SecurityOrigin&) const final;
+ Ref<ServiceWorkerClientFetch> startFetch(WebServiceWorkerProvider&, Ref<WebCore::ResourceLoader>&&, uint64_t identifier, ServiceWorkerClientFetch::Callback&&);
private:
void scheduleStorageJob(const WebCore::ServiceWorkerJobData&);
Modified: trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp (223649 => 223650)
--- trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp 2017-10-19 02:26:00 UTC (rev 223650)
@@ -58,6 +58,60 @@
return WebProcess::singleton().webToStorageProcessConnection()->serviceWorkerConnectionForSession(sessionID);
}
+static inline bool shouldHandleFetch(const WebSWClientConnection& connection, CachedResource* resource, const ResourceLoaderOptions& options)
+{
+ if (options.serviceWorkersMode != ServiceWorkersMode::All)
+ return false;
+
+ // FIXME: We should probably assert that options.serviceWorkersIdentifier is not null.
+ if (isPotentialNavigationOrSubresourceRequest(options.destination))
+ return false;
+
+ // FIXME: Implement non-subresource request loads.
+ if (isNonSubresourceRequest(options.destination))
+ return false;
+
+ if (!resource)
+ return false;
+
+ return connection.hasServiceWorkerRegisteredForOrigin(*resource->origin());
+}
+
+void WebServiceWorkerProvider::handleFetch(ResourceLoader& loader, CachedResource* resource, PAL::SessionID sessionID, ServiceWorkerClientFetch::Callback&& callback)
+{
+ auto& connection = WebProcess::singleton().webToStorageProcessConnection()->serviceWorkerConnectionForSession(sessionID);
+
+ if (!shouldHandleFetch(connection, resource, loader.options())) {
+ // FIXME: Add an option to error resource load for DTL to actually go through preflight.
+ callback(ServiceWorkerClientFetch::Result::Unhandled);
+ return;
+ }
+
+ auto fetch = connection.startFetch(*this, loader, loader.identifier(), WTFMove(callback));
+ ASSERT(fetch->isOngoing());
+
+ m_ongoingFetchTasks.add(loader.identifier(), WTFMove(fetch));
+}
+
+bool WebServiceWorkerProvider::cancelFetch(uint64_t fetchIdentifier)
+{
+ auto fetch = m_ongoingFetchTasks.take(fetchIdentifier);
+ if (fetch)
+ (*fetch)->cancel();
+ return !!fetch;
+}
+
+void WebServiceWorkerProvider::fetchFinished(uint64_t fetchIdentifier)
+{
+ m_ongoingFetchTasks.take(fetchIdentifier);
+}
+
+void WebServiceWorkerProvider::didReceiveServiceWorkerClientFetchMessage(IPC::Connection& connection, IPC::Decoder& decoder)
+{
+ if (auto fetch = m_ongoingFetchTasks.get(decoder.destinationID()))
+ fetch->didReceiveMessage(connection, decoder);
+}
+
} // namespace WebKit
#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.h (223649 => 223650)
--- trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -27,6 +27,7 @@
#if ENABLE(SERVICE_WORKER)
+#include "ServiceWorkerClientFetch.h"
#include <WebCore/ServiceWorkerProvider.h>
#include <wtf/NeverDestroyed.h>
@@ -36,6 +37,12 @@
public:
static WebServiceWorkerProvider& singleton();
+ void handleFetch(WebCore::ResourceLoader&, WebCore::CachedResource*, PAL::SessionID, ServiceWorkerClientFetch::Callback&&);
+ bool cancelFetch(uint64_t fetchIdentifier);
+ void fetchFinished(uint64_t fetchIdentifier);
+
+ void didReceiveServiceWorkerClientFetchMessage(IPC::Connection&, IPC::Decoder&);
+
private:
friend NeverDestroyed<WebServiceWorkerProvider>;
WebServiceWorkerProvider();
@@ -42,6 +49,7 @@
WebCore::SWClientConnection& serviceWorkerConnectionForSession(PAL::SessionID) final;
+ HashMap<uint64_t, Ref<ServiceWorkerClientFetch>> m_ongoingFetchTasks;
}; // class WebServiceWorkerProvider
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.cpp (223649 => 223650)
--- trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.cpp 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.cpp 2017-10-19 02:26:00 UTC (rev 223650)
@@ -27,11 +27,13 @@
#include "config.h"
#include "WebToStorageProcessConnection.h"
+#include "ServiceWorkerClientFetchMessages.h"
#include "StorageToWebProcessConnectionMessages.h"
#include "WebIDBConnectionToServerMessages.h"
#include "WebProcess.h"
#include "WebSWClientConnection.h"
#include "WebSWClientConnectionMessages.h"
+#include "WebServiceWorkerProvider.h"
using namespace PAL;
using namespace WebCore;
@@ -67,6 +69,10 @@
serviceWorkerConnection->didReceiveMessage(connection, decoder);
return;
}
+ if (decoder.messageReceiverName() == Messages::ServiceWorkerClientFetch::messageReceiverName()) {
+ WebServiceWorkerProvider::singleton().didReceiveServiceWorkerClientFetchMessage(connection, decoder);
+ return;
+ }
#endif
ASSERT_NOT_REACHED();
}
Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (223649 => 223650)
--- trunk/Source/WebKit/WebProcess/WebProcess.cpp 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp 2017-10-19 02:26:00 UTC (rev 223650)
@@ -40,6 +40,7 @@
#include "NetworkProcessConnection.h"
#include "NetworkSession.h"
#include "PluginProcessConnectionManager.h"
+#include "ServiceWorkerContextManager.h"
#include "SessionTracker.h"
#include "StatisticsData.h"
#include "StorageProcessMessages.h"
@@ -105,7 +106,6 @@
#include <WebCore/ResourceLoadObserver.h>
#include <WebCore/ResourceLoadStatistics.h>
#include <WebCore/RuntimeApplicationChecks.h>
-#include <WebCore/SWContextManager.h>
#include <WebCore/SchemeRegistry.h>
#include <WebCore/SecurityOrigin.h>
#include <WebCore/ServiceWorkerContextData.h>
@@ -1622,7 +1622,7 @@
#if ENABLE(SERVICE_WORKER)
void WebProcess::getWorkerContextConnection()
{
- ASSERT(!m_workerContextConnection);
+ ASSERT(!m_serviceWorkerManager);
#if USE(UNIX_DOMAIN_SOCKETS)
IPC::Connection::SocketPair socketPair = IPC::Connection::createPlatformConnection();
@@ -1642,22 +1642,29 @@
RELEASE_ASSERT_NOT_REACHED();
#endif
- m_workerContextConnection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
- m_workerContextConnection->open();
-
+ auto workerContextConnection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
+ workerContextConnection->open();
+ m_serviceWorkerManager = ServiceWorkerContextManager(WTFMove(workerContextConnection));
WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::DidGetWorkerContextConnection(connectionClientPort), 0);
}
void WebProcess::startServiceWorkerContext(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data)
{
- auto contextResult = SWContextManager::singleton().startServiceWorkerContext(serverConnectionIdentifier, data);
-
- if (contextResult.hasException())
- m_workerContextConnection->send(Messages::StorageProcess::ServiceWorkerContextFailedToStart(serverConnectionIdentifier, data.registrationKey, data.workerID, contextResult.exception().message()), 0);
- else
- m_workerContextConnection->send(Messages::StorageProcess::ServiceWorkerContextStarted(serverConnectionIdentifier, data.registrationKey, contextResult.returnValue(), data.workerID), 0);
+ ASSERT(m_serviceWorkerManager);
+ if (!m_serviceWorkerManager)
+ return;
+
+ m_serviceWorkerManager->startServiceWorkerContext(serverConnectionIdentifier, data);
}
+void WebProcess::startFetchInServiceWorker(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const ResourceRequest& request, const FetchOptions& options)
+{
+ if (!m_serviceWorkerManager)
+ return;
+
+ m_serviceWorkerManager->startFetch(serverConnectionIdentifier, fetchIdentifier, serviceWorkerIdentifier, request, options);
+}
+
#endif
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (223649 => 223650)
--- trunk/Source/WebKit/WebProcess/WebProcess.h 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h 2017-10-19 02:26:00 UTC (rev 223650)
@@ -30,6 +30,7 @@
#include "PluginProcessConnectionManager.h"
#include "ResourceCachesToClear.h"
#include "SandboxExtension.h"
+#include "ServiceWorkerContextManager.h"
#include "TextCheckerState.h"
#include "ViewUpdateDispatcher.h"
#include "WebInspectorInterruptDispatcher.h"
@@ -300,7 +301,7 @@
#if ENABLE(SERVICE_WORKER)
void getWorkerContextConnection();
void startServiceWorkerContext(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&);
- RefPtr<IPC::Connection> m_workerContextConnection;
+ void startFetchInServiceWorker(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&);
#endif
void releasePageCache();
@@ -438,6 +439,9 @@
#if PLATFORM(WAYLAND)
std::unique_ptr<WaylandCompositorDisplay> m_waylandCompositorDisplay;
#endif
+#if ENABLE(SERVICE_WORKER)
+ std::optional<ServiceWorkerContextManager> m_serviceWorkerManager;
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/WebProcess.messages.in (223649 => 223650)
--- trunk/Source/WebKit/WebProcess/WebProcess.messages.in 2017-10-19 02:22:45 UTC (rev 223649)
+++ trunk/Source/WebKit/WebProcess/WebProcess.messages.in 2017-10-19 02:26:00 UTC (rev 223650)
@@ -117,5 +117,6 @@
#if ENABLE(SERVICE_WORKER)
GetWorkerContextConnection()
StartServiceWorkerContext(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerContextData contextData)
+ StartFetchInServiceWorker(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options)
#endif
}