Unreviewed, revert r223650 as it caused crashes on the bots.
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Oct 2017 17:58:21 +0000 (17:58 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Oct 2017 17:58:21 +0000 (17:58 +0000)
Source/WebCore:

* WebCore.xcodeproj/project.pbxproj:
* dom/ScriptExecutionContext.h:
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
* loader/FetchOptions.h:
* 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/context/SWContextManager.cpp: Copied from Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h.
(WebCore::SWContextManager::singleton):
(WebCore::SWContextManager::SWContextManager):
(WebCore::SWContextManager::startServiceWorkerContext):
* workers/service/context/SWContextManager.h: Renamed from Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h.
* workers/service/context/ServiceWorkerThread.h:

Source/WebKit:

* CMakeLists.txt:
* DerivedSources.make:
* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
* StorageProcess/ServiceWorker/WebSWServerConnection.h:
* StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
* StorageProcess/StorageProcess.cpp:
* StorageProcess/StorageProcess.h:
* StorageProcess/StorageProcess.messages.in:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::scheduleLoad):
(WebKit::WebLoaderStrategy::remove):
* WebProcess/Network/WebLoaderStrategy.h:
* WebProcess/Storage/ServiceWorkerClientFetch.cpp: Removed.
* WebProcess/Storage/ServiceWorkerClientFetch.h: Removed.
* WebProcess/Storage/ServiceWorkerClientFetch.messages.in: Removed.
* WebProcess/Storage/ServiceWorkerContextManager.cpp: Removed.
* WebProcess/Storage/WebSWClientConnection.cpp:
* WebProcess/Storage/WebSWClientConnection.h:
* WebProcess/Storage/WebServiceWorkerProvider.cpp:
* WebProcess/Storage/WebServiceWorkerProvider.h:
* WebProcess/Storage/WebToStorageProcessConnection.cpp:
(WebKit::WebToStorageProcessConnection::didReceiveMessage):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::getWorkerContextConnection):
(WebKit::WebProcess::startServiceWorkerContext):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

LayoutTests:

* http/tests/workers/service/basic-fetch.https-expected.txt: Removed.
* http/tests/workers/service/basic-fetch.https.html: Removed.
* http/tests/workers/service/resources/basic-fetch-worker.js: Removed.
* http/tests/workers/service/resources/basic-fetch.js: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223692 268f45cc-cd09-0410-ab3c-d52691b4dbfc

44 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/workers/service/basic-fetch.https-expected.txt [deleted file]
LayoutTests/http/tests/workers/service/basic-fetch.https.html [deleted file]
LayoutTests/http/tests/workers/service/resources/basic-fetch-worker.js [deleted file]
LayoutTests/http/tests/workers/service/resources/basic-fetch.js [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/ScriptExecutionContext.h
Source/WebCore/loader/DocumentThreadableLoader.cpp
Source/WebCore/loader/FetchOptions.h
Source/WebCore/loader/ResourceLoaderOptions.h
Source/WebCore/loader/WorkerThreadableLoader.cpp
Source/WebCore/loader/WorkerThreadableLoader.h
Source/WebCore/platform/network/ResourceRequestBase.h
Source/WebCore/platform/network/ResourceResponseBase.h
Source/WebCore/workers/WorkerThread.h
Source/WebCore/workers/service/ServiceWorkerContainer.cpp
Source/WebCore/workers/service/context/SWContextManager.cpp [new file with mode: 0644]
Source/WebCore/workers/service/context/SWContextManager.h [moved from Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h with 66% similarity]
Source/WebCore/workers/service/context/ServiceWorkerThread.h
Source/WebKit/CMakeLists.txt
Source/WebKit/ChangeLog
Source/WebKit/DerivedSources.make
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in
Source/WebKit/StorageProcess/StorageProcess.cpp
Source/WebKit/StorageProcess/StorageProcess.h
Source/WebKit/StorageProcess/StorageProcess.messages.in
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
Source/WebKit/WebProcess/Network/WebLoaderStrategy.h
Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp [deleted file]
Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.h [deleted file]
Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.messages.in [deleted file]
Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.cpp [deleted file]
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp
Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.h
Source/WebKit/WebProcess/Storage/WebToStorageProcessConnection.cpp
Source/WebKit/WebProcess/WebProcess.cpp
Source/WebKit/WebProcess/WebProcess.h
Source/WebKit/WebProcess/WebProcess.messages.in

index cf3d4a2..040da04 100644 (file)
@@ -1,3 +1,12 @@
+2017-10-19  Chris Dumez  <cdumez@apple.com>
+
+        Unreviewed, revert r223650 as it caused crashes on the bots.
+
+        * http/tests/workers/service/basic-fetch.https-expected.txt: Removed.
+        * http/tests/workers/service/basic-fetch.https.html: Removed.
+        * http/tests/workers/service/resources/basic-fetch-worker.js: Removed.
+        * http/tests/workers/service/resources/basic-fetch.js: Removed.
+
 2017-10-19  Antti Koivisto  <antti@apple.com>
 
         Overlapping text on all CSS fonts specs
diff --git a/LayoutTests/http/tests/workers/service/basic-fetch.https-expected.txt b/LayoutTests/http/tests/workers/service/basic-fetch.https-expected.txt
deleted file mode 100644 (file)
index ffd649f..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-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
-
diff --git a/LayoutTests/http/tests/workers/service/basic-fetch.https.html b/LayoutTests/http/tests/workers/service/basic-fetch.https.html
deleted file mode 100644 (file)
index 62a066a..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-<html>
-<head>
-<script src="resources/sw-test-pre.js"></script>
-</head>
-<body>
-
-<script src="resources/basic-fetch.js"></script>
-</body>
-</html>
diff --git a/LayoutTests/http/tests/workers/service/resources/basic-fetch-worker.js b/LayoutTests/http/tests/workers/service/resources/basic-fetch-worker.js
deleted file mode 100644 (file)
index 29d8a2b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-// FIXME: register an onfetch event handler and handle "test1", "test2" and "test3" URLs
diff --git a/LayoutTests/http/tests/workers/service/resources/basic-fetch.js b/LayoutTests/http/tests/workers/service/resources/basic-fetch.js
deleted file mode 100644 (file)
index 28743a2..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-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();
index b9287d5..332459d 100644 (file)
@@ -1,3 +1,29 @@
+2017-10-19  Chris Dumez  <cdumez@apple.com>
+
+        Unreviewed, revert r223650 as it caused crashes on the bots.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/ScriptExecutionContext.h:
+        * loader/DocumentThreadableLoader.cpp:
+        (WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
+        * loader/FetchOptions.h:
+        * 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/context/SWContextManager.cpp: Copied from Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h.
+        (WebCore::SWContextManager::singleton):
+        (WebCore::SWContextManager::SWContextManager):
+        (WebCore::SWContextManager::startServiceWorkerContext):
+        * workers/service/context/SWContextManager.h: Renamed from Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h.
+        * workers/service/context/ServiceWorkerThread.h:
+
 2017-10-19  Zalan Bujtas  <zalan@apple.com>
 
         [FrameView::layout cleanup] Replace m_nestedLayoutCount with isLayoutNested()
index 0215189..bdf324b 100644 (file)
                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, ); }; };
                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>"; };
                        children = (
                                517C87111F8EE72F00EB8076 /* ServiceWorkerThread.cpp */,
                                517C87101F8EE72E00EB8076 /* ServiceWorkerThread.h */,
+                               517C87081F8EB9BF00EB8076 /* SWContextManager.cpp */,
+                               517C87091F8EB9C000EB8076 /* SWContextManager.h */,
                        );
                        path = context;
                        sourceTree = "<group>";
                                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 */,
                                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 */,
index 96ddd62..32f19c3 100644 (file)
@@ -230,11 +230,6 @@ public:
 
     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:
@@ -302,10 +297,6 @@ private:
 #if !ASSERT_DISABLED || ENABLE(SECURITY_ASSERTIONS)
     bool m_activeDOMObjectRemovalForbidden { false };
 #endif
-
-#if ENABLE(SERVICE_WORKER)
-    uint64_t m_serviceWorkerIdentifier { 0 };
-#endif
 };
 
 } // namespace WebCore
index 4b48f51..902c89e 100644 (file)
@@ -103,11 +103,6 @@ DocumentThreadableLoader::DocumentThreadableLoader(Document& document, Threadabl
 {
     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());
 
index 73b9624..a404203 100644 (file)
@@ -69,21 +69,6 @@ inline FetchOptions::FetchOptions(Destination destination, Mode mode, Credential
 {
 }
 
-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 {
index 5c5a0d4..d2a92c3 100644 (file)
@@ -92,11 +92,6 @@ enum class InitiatorContext {
     Worker,
 };
 
-enum class ServiceWorkersMode {
-    All,
-    None,
-};
-
 struct ResourceLoaderOptions : public FetchOptions {
     ResourceLoaderOptions() { }
 
@@ -129,8 +124,6 @@ struct ResourceLoaderOptions : public FetchOptions {
     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 };
index e27aaa8..33bb12e 100644 (file)
@@ -55,7 +55,7 @@ static const char loadResourceSynchronouslyMode[] = "loadResourceSynchronouslyMo
 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))
+    , m_bridge(*new MainThreadBridge(m_workerClientWrapper.get(), workerGlobalScope.thread().workerLoaderProxy(), taskMode, WTFMove(request), options, referrer.isEmpty() ? workerGlobalScope.url().strippedForUseAsReferrer() : referrer, workerGlobalScope.securityOrigin(), workerGlobalScope.contentSecurityPolicy()))
 {
 }
 
@@ -101,15 +101,12 @@ LoaderTaskOptions::LoaderTaskOptions(const ThreadableLoaderOptions& options, con
 }
 
 WorkerThreadableLoader::MainThreadBridge::MainThreadBridge(ThreadableLoaderClientWrapper& workerClientWrapper, WorkerLoaderProxy& loaderProxy, const String& taskMode,
-    ResourceRequest&& request, const ThreadableLoaderOptions& options, const String& outgoingReferrer, WorkerGlobalScope& globalScope)
+    ResourceRequest&& request, const ThreadableLoaderOptions& options, const String& outgoingReferrer,
+    const SecurityOrigin* securityOrigin, const ContentSecurityPolicy* contentSecurityPolicy)
     : m_workerClientWrapper(&workerClientWrapper)
     , m_loaderProxy(loaderProxy)
     , m_taskMode(taskMode.isolatedCopy())
 {
-
-    auto* securityOrigin = globalScope.securityOrigin();
-    auto* contentSecurityPolicy = globalScope.contentSecurityPolicy();
-
     ASSERT(securityOrigin);
     ASSERT(contentSecurityPolicy);
 
@@ -124,11 +121,6 @@ WorkerThreadableLoader::MainThreadBridge::MainThreadBridge(ThreadableLoaderClien
     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());
index 22ab149..97ec2d4 100644 (file)
@@ -88,7 +88,7 @@ namespace WebCore {
         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, WorkerGlobalScope&);
+            MainThreadBridge(ThreadableLoaderClientWrapper&, WorkerLoaderProxy&, const String& taskMode, ResourceRequest&&, const ThreadableLoaderOptions&, const String& outgoingReferrer, const SecurityOrigin*, const ContentSecurityPolicy*);
             void cancel();
             void destroy();
 
index da6ad65..b5e948e 100644 (file)
@@ -100,7 +100,7 @@ public:
 
     WEBCORE_EXPORT String httpContentType() const;
     WEBCORE_EXPORT void setHTTPContentType(const String&);
-    WEBCORE_EXPORT void clearHTTPContentType();
+    void clearHTTPContentType();
 
     bool hasHTTPHeader(HTTPHeaderName) const;
 
index ee373dd..abcdcea 100644 (file)
@@ -153,7 +153,7 @@ public:
         return 1280;
     }
 
-    WEBCORE_EXPORT void setType(Type);
+    void setType(Type);
     Type type() const { return m_type; }
 
     void setRedirected(bool isRedirected) { m_isRedirected = isRedirected; }
index 395fd80..cfe343e 100644 (file)
@@ -61,7 +61,7 @@ class WorkerThread : public RefCounted<WorkerThread> {
 public:
     virtual ~WorkerThread();
 
-    WEBCORE_EXPORT bool start();
+    bool start();
     void stop();
 
     ThreadIdentifier threadID() const { return m_thread ? m_thread->id() : 0; }
index e830a8d..218a64a 100644 (file)
@@ -179,9 +179,6 @@ void ServiceWorkerContainer::jobResolvedWithRegistration(ServiceWorkerJob& job,
         return;
     }
 
-    // FIXME: Implement proper selection of service workers.
-    context->setSelectedServiceWorkerIdentifier(data.identifier);
-
     auto registration = ServiceWorkerRegistration::create(*context, WTFMove(data));
     job.promise().resolve<IDLInterface<ServiceWorkerRegistration>>(registration.get());
 }
diff --git a/Source/WebCore/workers/service/context/SWContextManager.cpp b/Source/WebCore/workers/service/context/SWContextManager.cpp
new file mode 100644 (file)
index 0000000..94fe57e
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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)
 
 #if ENABLE(SERVICE_WORKER)
 
-#include "Connection.h"
-#include <WebCore/ServiceWorkerThread.h>
+#include "ExceptionOr.h"
+#include "ServiceWorkerThread.h"
 #include <wtf/HashMap.h>
 
 namespace WebCore {
-struct FetchOptions;
-class ResourceRequest;
-struct ServiceWorkerContextData;
-}
 
-namespace WebKit {
+struct ServiceWorkerContextData;
 
-class ServiceWorkerContextManager {
+class SWContextManager {
 public:
-    explicit ServiceWorkerContextManager(Ref<IPC::Connection>&& connection)
-        : m_connectionToStorageProcess(WTFMove(connection))
-    {
-    }
+    WEBCORE_EXPORT static SWContextManager& singleton();
 
-    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&);
+    WEBCORE_EXPORT ExceptionOr<uint64_t> startServiceWorkerContext(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&);
 
 private:
-    Ref<IPC::Connection> m_connectionToStorageProcess;
-    HashMap<uint64_t, RefPtr<WebCore::ServiceWorkerThread>> m_workerThreadMap;
+    SWContextManager();
+    
+    HashMap<uint64_t, RefPtr<ServiceWorkerThread>> m_workerThreadMap;
 };
 
-} // namespace WebKit
+} // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)
index 8dba489..22a07b8 100644 (file)
@@ -52,7 +52,7 @@ protected:
     void runEventLoop() override;
 
 private:
-    WEBCORE_EXPORT ServiceWorkerThread(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID);
+    ServiceWorkerThread(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID);
 
     uint64_t m_serverConnectionIdentifier;
     ServiceWorkerContextData m_data;
index 5fa361e..d41edbf 100644 (file)
@@ -683,7 +683,6 @@ set(WebKit_MESSAGES_IN_FILES
     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
index 352acea..c15ebe4 100644 (file)
@@ -1,5 +1,38 @@
 2017-10-19  Chris Dumez  <cdumez@apple.com>
 
+        Unreviewed, revert r223650 as it caused crashes on the bots.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
+        * StorageProcess/StorageProcess.cpp:
+        * StorageProcess/StorageProcess.h:
+        * StorageProcess/StorageProcess.messages.in:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/Network/WebLoaderStrategy.cpp:
+        (WebKit::WebLoaderStrategy::scheduleLoad):
+        (WebKit::WebLoaderStrategy::remove):
+        * WebProcess/Network/WebLoaderStrategy.h:
+        * WebProcess/Storage/ServiceWorkerClientFetch.cpp: Removed.
+        * WebProcess/Storage/ServiceWorkerClientFetch.h: Removed.
+        * WebProcess/Storage/ServiceWorkerClientFetch.messages.in: Removed.
+        * WebProcess/Storage/ServiceWorkerContextManager.cpp: Removed.
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        * WebProcess/Storage/WebSWClientConnection.h:
+        * WebProcess/Storage/WebServiceWorkerProvider.cpp:
+        * WebProcess/Storage/WebServiceWorkerProvider.h:
+        * WebProcess/Storage/WebToStorageProcessConnection.cpp:
+        (WebKit::WebToStorageProcessConnection::didReceiveMessage):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::getWorkerContextConnection):
+        (WebKit::WebProcess::startServiceWorkerContext):
+        * WebProcess/WebProcess.h:
+        * WebProcess/WebProcess.messages.in:
+
+2017-10-19  Chris Dumez  <cdumez@apple.com>
+
         http/tests/workers/service/basic-register.html is a flaky failure.
         https://bugs.webkit.org/show_bug.cgi?id=178494
         <rdar://problem/35065315>
index 08b809a..ba44cba 100644 (file)
@@ -125,7 +125,6 @@ MESSAGE_RECEIVERS = \
     RemoteWebInspectorProxy \
     RemoteWebInspectorUI \
     SecItemShimProxy \
-    ServiceWorkerClientFetch \
     SmartMagnificationController \
     StorageAreaMap \
     StorageManager \
index 10ccba5..7297f4b 100644 (file)
 
 #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"
@@ -94,31 +92,6 @@ void WebSWServerConnection::startServiceWorkerContext(const ServiceWorkerContext
     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)
index ae3a25d..dcc4961 100644 (file)
@@ -51,22 +51,15 @@ public:
 
     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;
     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(); }
 
index f3db3b9..e4cfb96 100644 (file)
@@ -26,8 +26,6 @@ messages -> WebSWServerConnection {
     # 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)
index 2c97acc..28b22c2 100644 (file)
@@ -405,30 +405,6 @@ void StorageProcess::serviceWorkerContextStarted(uint64_t serverConnectionIdenti
         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()));
index cfd4bc1..d4ce511 100644 (file)
@@ -119,11 +119,6 @@ private:
     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);
index 2064d69..ee628d5 100644 (file)
@@ -37,13 +37,7 @@ messages -> StorageProcess LegacyReceiver {
 
 #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
 }
index a1cb7cc..8b86950 100644 (file)
                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 */; };
                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 */; };
                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>"; };
                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>"; };
                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 */,
                                1BBBE49E19B66C53006B7D81 /* RemoteWebInspectorUIMessageReceiver.cpp */,
                                E18E6913169B667B009B6670 /* SecItemShimProxyMessageReceiver.cpp */,
                                E18E6914169B667B009B6670 /* SecItemShimProxyMessages.h */,
-                               617A52D71F43A9B600DCDC0A /* ServiceWorkerClientFetchConnectionMessageReceiver.cpp */,
                                2DE6943B18BD2A68005C15E5 /* SmartMagnificationControllerMessageReceiver.cpp */,
                                2DE6943C18BD2A68005C15E5 /* SmartMagnificationControllerMessages.h */,
                                1A334DEB16DE8F88006A8E38 /* StorageAreaMapMessageReceiver.cpp */,
                                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 */,
                                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 */,
index 45077a4..b895d0b 100644 (file)
@@ -43,7 +43,6 @@
 #include "WebPageProxyMessages.h"
 #include "WebProcess.h"
 #include "WebResourceLoader.h"
-#include "WebServiceWorkerProvider.h"
 #include "WebURLSchemeHandlerProxy.h"
 #include "WebURLSchemeTaskProxy.h"
 #include <WebCore/ApplicationCacheHost.h>
@@ -216,29 +215,6 @@ void WebLoaderStrategy::scheduleLoad(ResourceLoader& resourceLoader, CachedResou
         }
     }
 
-#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;
@@ -249,7 +225,7 @@ void WebLoaderStrategy::scheduleLoadFromNetworkProcess(ResourceLoader& resourceL
     loadParameters.webPageID = webPage ? webPage->pageID() : 0;
     loadParameters.webFrameID = webFrame ? webFrame->frameID() : 0;
     loadParameters.sessionID = webPage ? webPage->sessionID() : PAL::SessionID::defaultSessionID();
-    loadParameters.request = request;
+    loadParameters.request = resourceLoader.request();
     loadParameters.contentSniffingPolicy = contentSniffingPolicy;
     loadParameters.storedCredentialsPolicy = storedCredentialsPolicy;
     // If there is no WebFrame then this resource cannot be authenticated with the client.
@@ -257,7 +233,7 @@ void WebLoaderStrategy::scheduleLoadFromNetworkProcess(ResourceLoader& resourceL
     loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = shouldClearReferrerOnHTTPSToHTTPRedirect;
     loadParameters.defersLoading = resourceLoader.defersLoading();
     loadParameters.needsCertificateInfo = resourceLoader.shouldIncludeCertificateInfo();
-    loadParameters.maximumBufferingTime = maximumBufferingTime;
+    loadParameters.maximumBufferingTime = maximumBufferingTime(resource);
     loadParameters.derivedCachedDataTypesToRetrieve = resourceLoader.options().derivedCachedDataTypesToRetrieve;
 
     ASSERT((loadParameters.webPageID && loadParameters.webFrameID) || loadParameters.clientCredentialPolicy == ClientCredentialPolicy::CannotAskClientForCredentials);
@@ -324,12 +300,7 @@ void WebLoaderStrategy::remove(ResourceLoader* resourceLoader)
         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)
index 2792ab9..b48f681 100644 (file)
@@ -77,8 +77,6 @@ public:
     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&);
diff --git a/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp b/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp
deleted file mode 100644 (file)
index 3071559..0000000
+++ /dev/null
@@ -1,104 +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 "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)
diff --git a/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.h b/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.h
deleted file mode 100644 (file)
index d052096..0000000
+++ /dev/null
@@ -1,74 +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 "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)
diff --git a/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.messages.in b/Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.messages.in
deleted file mode 100644 (file)
index a1081b4..0000000
+++ /dev/null
@@ -1,32 +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.
-
-#if ENABLE(SERVICE_WORKER)
-
-messages -> ServiceWorkerClientFetch {
-    DidReceiveResponse(WebCore::ResourceResponse response)
-    DidReceiveData(IPC::DataReference data, int64_t encodedDataLength)
-    DidFinish()
-    DidFail()
-}
-
-#endif // ENABLE(SERVICE_WORKER)
diff --git a/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.cpp b/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.cpp
deleted file mode 100644 (file)
index 4371392..0000000
+++ /dev/null
@@ -1,97 +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 "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)
index bb1e1cc..76ae7b5 100644 (file)
@@ -29,7 +29,6 @@
 #if ENABLE(SERVICE_WORKER)
 
 #include "Logging.h"
-#include "ServiceWorkerClientFetch.h"
 #include "StorageToWebProcessConnectionMessages.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebSWOriginTable.h"
@@ -76,15 +75,6 @@ void WebSWClientConnection::setSWOriginTableSharedMemory(const SharedMemory::Han
     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)
index 91b9f8c..2617ec2 100644 (file)
@@ -30,7 +30,6 @@
 #include "Connection.h"
 #include "MessageReceiver.h"
 #include "MessageSender.h"
-#include "ServiceWorkerClientFetch.h"
 #include "SharedMemory.h"
 #include <WebCore/SWClientConnection.h>
 #include <pal/SessionID.h>
 
 namespace WebCore {
 struct ExceptionData;
-class ResourceLoader;
 }
 
 namespace WebKit {
 
 class WebSWOriginTable;
-class WebServiceWorkerProvider;
 
 class WebSWClientConnection : public WebCore::SWClientConnection, public IPC::MessageSender, public IPC::MessageReceiver {
 public:
@@ -61,7 +58,6 @@ public:
     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&);
index 3aba491..61d8ce5 100644 (file)
@@ -58,60 +58,6 @@ WebCore::SWClientConnection& WebServiceWorkerProvider::serviceWorkerConnectionFo
     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)
index 098b73d..775f5ee 100644 (file)
@@ -27,7 +27,6 @@
 
 #if ENABLE(SERVICE_WORKER)
 
-#include "ServiceWorkerClientFetch.h"
 #include <WebCore/ServiceWorkerProvider.h>
 #include <wtf/NeverDestroyed.h>
 
@@ -37,19 +36,12 @@ class WebServiceWorkerProvider final : public WebCore::ServiceWorkerProvider {
 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();
 
     WebCore::SWClientConnection& serviceWorkerConnectionForSession(PAL::SessionID) final;
 
-    HashMap<uint64_t, Ref<ServiceWorkerClientFetch>> m_ongoingFetchTasks;
 }; // class WebServiceWorkerProvider
 
 } // namespace WebKit
index b2df837..5a12d04 100644 (file)
 #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;
@@ -69,10 +67,6 @@ void WebToStorageProcessConnection::didReceiveMessage(IPC::Connection& connectio
             serviceWorkerConnection->didReceiveMessage(connection, decoder);
         return;
     }
-    if (decoder.messageReceiverName() == Messages::ServiceWorkerClientFetch::messageReceiverName()) {
-        WebServiceWorkerProvider::singleton().didReceiveServiceWorkerClientFetchMessage(connection, decoder);
-        return;
-    }
 #endif
     ASSERT_NOT_REACHED();
 }
index 1f7b204..6e27671 100644 (file)
@@ -40,7 +40,6 @@
 #include "NetworkProcessConnection.h"
 #include "NetworkSession.h"
 #include "PluginProcessConnectionManager.h"
-#include "ServiceWorkerContextManager.h"
 #include "SessionTracker.h"
 #include "StatisticsData.h"
 #include "StorageProcessMessages.h"
 #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 @@ LibWebRTCNetwork& WebProcess::libWebRTCNetwork()
 #if ENABLE(SERVICE_WORKER)
 void WebProcess::getWorkerContextConnection()
 {
-    ASSERT(!m_serviceWorkerManager);
+    ASSERT(!m_workerContextConnection);
 
 #if USE(UNIX_DOMAIN_SOCKETS)
     IPC::Connection::SocketPair socketPair = IPC::Connection::createPlatformConnection();
@@ -1642,27 +1642,20 @@ void WebProcess::getWorkerContextConnection()
     RELEASE_ASSERT_NOT_REACHED();
 #endif
 
-    auto workerContextConnection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
-    workerContextConnection->open();
-    m_serviceWorkerManager =  ServiceWorkerContextManager(WTFMove(workerContextConnection));
+    m_workerContextConnection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
+    m_workerContextConnection->open();
+
     WebProcess::singleton().parentProcessConnection()->send(Messages::WebProcessProxy::DidGetWorkerContextConnection(connectionClientPort), 0);
 }
 
 void WebProcess::startServiceWorkerContext(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data)
 {
-    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);
+    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);
 }
 
 #endif
index fee1436..5c2e6c7 100644 (file)
@@ -30,7 +30,6 @@
 #include "PluginProcessConnectionManager.h"
 #include "ResourceCachesToClear.h"
 #include "SandboxExtension.h"
-#include "ServiceWorkerContextManager.h"
 #include "TextCheckerState.h"
 #include "ViewUpdateDispatcher.h"
 #include "WebInspectorInterruptDispatcher.h"
@@ -301,7 +300,7 @@ private:
 #if ENABLE(SERVICE_WORKER)
     void getWorkerContextConnection();
     void startServiceWorkerContext(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&);
-    void startFetchInServiceWorker(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&);
+    RefPtr<IPC::Connection> m_workerContextConnection;
 #endif
 
     void releasePageCache();
@@ -439,9 +438,6 @@ private:
 #if PLATFORM(WAYLAND)
     std::unique_ptr<WaylandCompositorDisplay> m_waylandCompositorDisplay;
 #endif
-#if ENABLE(SERVICE_WORKER)
-    std::optional<ServiceWorkerContextManager> m_serviceWorkerManager;
-#endif
 };
 
 } // namespace WebKit
index fa5472c..2206360 100644 (file)
@@ -117,6 +117,5 @@ messages -> WebProcess LegacyReceiver {
 #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
 }