Diff
Modified: trunk/LayoutTests/ChangeLog (223276 => 223277)
--- trunk/LayoutTests/ChangeLog 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/LayoutTests/ChangeLog 2017-10-13 06:44:47 UTC (rev 223277)
@@ -1,3 +1,14 @@
+2017-10-12 Brady Eidson <[email protected]>
+
+ SW "Hello world".
+ https://bugs.webkit.org/show_bug.cgi?id=178187
+
+ Reviewed by Andy Estes.
+
+ * http/tests/workers/service/basic-register-exceptions-expected.txt:
+ * http/tests/workers/service/basic-register-expected.txt:
+ * http/tests/workers/service/registration-task-queue-scheduling-1-expected.txt:
+
2017-10-12 Alex Christensen <[email protected]>
Use asynchronous ResourceHandleClient calls for WebKit1
Modified: trunk/LayoutTests/http/tests/workers/service/basic-register-exceptions-expected.txt (223276 => 223277)
--- trunk/LayoutTests/http/tests/workers/service/basic-register-exceptions-expected.txt 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/LayoutTests/http/tests/workers/service/basic-register-exceptions-expected.txt 2017-10-13 06:44:47 UTC (rev 223277)
@@ -4,7 +4,7 @@
CONSOLE MESSAGE: line 50: Registration failed with error: TypeError: serviceWorker.register() must be called with a script URL whose path does not contain '%2f' or '%5c'
CONSOLE MESSAGE: line 60: Registration failed with error: TypeError: Scope URL provided to serviceWorker.register() must be either HTTP or HTTPS
CONSOLE MESSAGE: line 70: Registration failed with error: TypeError: Scope URL provided to serviceWorker.register() cannot have a path that contains '%2f' or '%5c'
-CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Failed to start service worker script of length 0
+CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Worker script successfully started, but it has no way to communicate yet
CONSOLE MESSAGE: line 80: Registration failed with error: SecurityError: Script origin does not match the registering client's origin
CONSOLE MESSAGE: line 91: Registration failed with error: SecurityError: Scope origin does not match the registering client's origin
Modified: trunk/LayoutTests/http/tests/workers/service/basic-register-expected.txt (223276 => 223277)
--- trunk/LayoutTests/http/tests/workers/service/basic-register-expected.txt 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/LayoutTests/http/tests/workers/service/basic-register-expected.txt 2017-10-13 06:44:47 UTC (rev 223277)
@@ -1,3 +1,3 @@
-CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Failed to start service worker script of length 41
-CONSOLE MESSAGE: line 21: Registration failed with error: UnknownError: Failed to start service worker script of length 0
+CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Worker script successfully started, but it has no way to communicate yet
+CONSOLE MESSAGE: line 21: Registration failed with error: UnknownError: Worker script successfully started, but it has no way to communicate yet
Modified: trunk/LayoutTests/http/tests/workers/service/registration-task-queue-scheduling-1-expected.txt (223276 => 223277)
--- trunk/LayoutTests/http/tests/workers/service/registration-task-queue-scheduling-1-expected.txt 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/LayoutTests/http/tests/workers/service/registration-task-queue-scheduling-1-expected.txt 2017-10-13 06:44:47 UTC (rev 223277)
@@ -1,2 +1,2 @@
-ALERT: Unexpected error received from server: UnknownError: Failed to start service worker script of length 41
+ALERT: Unexpected error received from server: UnknownError: Worker script successfully started, but it has no way to communicate yet
Modified: trunk/Source/WebCore/ChangeLog (223276 => 223277)
--- trunk/Source/WebCore/ChangeLog 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/Source/WebCore/ChangeLog 2017-10-13 06:44:47 UTC (rev 223277)
@@ -1,3 +1,60 @@
+2017-10-12 Brady Eidson <[email protected]>
+
+ SW "Hello world".
+ https://bugs.webkit.org/show_bug.cgi?id=178187
+
+ Reviewed by Andy Estes.
+
+ No new tests (Covered by changes to existing tests).
+
+ With this patch, SW scripts are actually compiled and run inside a ServiceWorkerGlobalScope environment
+ in the SW context process.
+
+ * WebCore.xcodeproj/project.pbxproj:
+
+ * bindings/js/WorkerScriptController.cpp:
+ (WebCore::WorkerScriptController::initScript):
+
+ * dom/EventTargetFactory.in:
+
+ * workers/WorkerGlobalScope.h:
+ (WebCore::WorkerGlobalScope::isServiceWorkerGlobalScope const):
+
+ * workers/service/ServiceWorkerContextData.cpp: Copied from Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp.
+ (WebCore::ServiceWorkerContextData::isolatedCopy const):
+ * workers/service/ServiceWorkerContextData.h:
+ (WebCore::ServiceWorkerContextData::encode const):
+ (WebCore::ServiceWorkerContextData::decode):
+
+ * workers/service/ServiceWorkerGlobalScope.cpp:
+ (WebCore::ServiceWorkerGlobalScope::ServiceWorkerGlobalScope):
+ (WebCore::ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope):
+ (WebCore::ServiceWorkerGlobalScope::registration):
+ (WebCore::ServiceWorkerGlobalScope::eventTargetInterface const):
+ * workers/service/ServiceWorkerGlobalScope.h:
+ (WebCore::ServiceWorkerGlobalScope::create):
+ (WebCore::ServiceWorkerGlobalScope::serverConnectionIdentifier const):
+
+ * workers/service/context/SWContextManager.cpp: Copied from Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp.
+ (WebCore::SWContextManager::singleton):
+ (WebCore::SWContextManager::SWContextManager):
+ (WebCore::SWContextManager::startServiceWorkerContext):
+ * workers/service/context/SWContextManager.h: Copied from Source/WebCore/workers/service/ServiceWorkerGlobalScope.h.
+
+ * workers/service/context/ServiceWorkerThread.cpp: Added.
+ (WebCore::ServiceWorkerThreadProxy::sharedDummyProxy):
+ (WebCore::ServiceWorkerThread::ServiceWorkerThread):
+ (WebCore::m_workerObjectProxy):
+ (WebCore::ServiceWorkerThread::~ServiceWorkerThread):
+ (WebCore::ServiceWorkerThread::createWorkerGlobalScope):
+ (WebCore::ServiceWorkerThread::runEventLoop):
+ * workers/service/context/ServiceWorkerThread.h: Copied from Source/WebCore/workers/service/ServiceWorkerGlobalScope.h.
+ (WebCore::ServiceWorkerThread::create):
+ (WebCore::ServiceWorkerThread::workerObjectProxy const):
+
+ * workers/service/server/SWServer.cpp:
+ (WebCore::SWServer::createWorker):
+
2017-10-12 Alex Christensen <[email protected]>
Use asynchronous ResourceHandleClient calls for WebKit1
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (223276 => 223277)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-10-13 06:44:47 UTC (rev 223277)
@@ -2352,6 +2352,9 @@
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, ); }; };
517FBA1E151AB17C00B57959 /* DOMWindowExtension.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517FBA17151AA71B00B57959 /* DOMWindowExtension.cpp */; };
@@ -2454,6 +2457,8 @@
51BA4ACA1BBC5BD900DF3D6D /* MemoryIDBBackingStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51BA4AC81BBC5B9E00DF3D6D /* MemoryIDBBackingStore.cpp */; };
51BA4ACB1BBC5BD900DF3D6D /* MemoryIDBBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BA4AC91BBC5B9E00DF3D6D /* MemoryIDBBackingStore.h */; };
51BA4ACC1BBC5BDD00DF3D6D /* IDBBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BA4AC71BBC5AD600DF3D6D /* IDBBackingStore.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 51BCCE2F1F8F1795006BA0ED /* ServiceWorkerThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517C87111F8EE72F00EB8076 /* ServiceWorkerThread.cpp */; };
+ 51BCCE301F8F179E006BA0ED /* ServiceWorkerThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 517C87101F8EE72E00EB8076 /* ServiceWorkerThread.h */; settings = {ATTRIBUTES = (Private, ); }; };
51BE37E00DAEE00E001085FC /* StorageArea.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BE37DE0DAEE00E001085FC /* StorageArea.h */; settings = {ATTRIBUTES = (Private, ); }; };
51C0AA390F2AA10A001648C2 /* CachedFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 51C0AA380F2AA10A001648C2 /* CachedFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
51C0AA410F2AA15E001648C2 /* CachedFrame.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51C0AA400F2AA15E001648C2 /* CachedFrame.cpp */; };
@@ -10287,6 +10292,11 @@
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>"; };
517DEEE31DE94ADC00B91644 /* ScrollingMomentumCalculatorMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ScrollingMomentumCalculatorMac.mm; sourceTree = "<group>"; };
517DEEE71DE94B0800B91644 /* ScrollingMomentumCalculatorMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollingMomentumCalculatorMac.h; sourceTree = "<group>"; };
517FBA17151AA71B00B57959 /* DOMWindowExtension.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowExtension.cpp; sourceTree = "<group>"; };
@@ -19132,6 +19142,17 @@
path = server;
sourceTree = "<group>";
};
+ 517C87071F8E8FF200EB8076 /* context */ = {
+ isa = PBXGroup;
+ children = (
+ 517C87081F8EB9BF00EB8076 /* SWContextManager.cpp */,
+ 517C87091F8EB9C000EB8076 /* SWContextManager.h */,
+ 517C87111F8EE72F00EB8076 /* ServiceWorkerThread.cpp */,
+ 517C87101F8EE72E00EB8076 /* ServiceWorkerThread.h */,
+ );
+ path = context;
+ sourceTree = "<group>";
+ };
5182C24C1F3142090059BA7C /* ServiceWorkers */ = {
isa = PBXGroup;
children = (
@@ -19212,6 +19233,7 @@
51F175441F3EBBF200C74950 /* service */ = {
isa = PBXGroup;
children = (
+ 517C87071F8E8FF200EB8076 /* context */,
517A52EC1F47532D00DCDC0A /* server */,
51F1755B1F3EBC0C00C74950 /* ServiceWorker.cpp */,
51F1755A1F3EBC0C00C74950 /* ServiceWorker.h */,
@@ -19219,6 +19241,7 @@
51F175581F3EBC0C00C74950 /* ServiceWorkerContainer.cpp */,
51F175571F3EBC0C00C74950 /* ServiceWorkerContainer.h */,
51F175561F3EBC0C00C74950 /* ServiceWorkerContainer.idl */,
+ 517C87161F8FD4D300EB8076 /* ServiceWorkerContextData.cpp */,
51CA7EE71F8832E0003D3131 /* ServiceWorkerContextData.h */,
517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */,
51F175551F3EBC0C00C74950 /* ServiceWorkerGlobalScope.cpp */,
@@ -28627,6 +28650,7 @@
7C8139AA1ED6604B00CE26E8 /* JSDOMCastedThisErrorBehavior.h in Headers */,
413C2C341BC29A8F0075204C /* JSDOMConstructor.h in Headers */,
930841341CDDB15500B0958C /* JSDOMConvert.h in Headers */,
+ 517C870B1F8EBB2500EB8076 /* SWContextManager.h in Headers */,
7C8E34AD1E4A33AF0054CE23 /* JSDOMConvertAny.h in Headers */,
7C8E34AE1E4A33AF0054CE23 /* JSDOMConvertBase.h in Headers */,
7C8E34AF1E4A33AF0054CE23 /* JSDOMConvertBoolean.h in Headers */,
@@ -30413,6 +30437,7 @@
B22279C50D00BF220071B782 /* SVGExternalResourcesRequired.h in Headers */,
B22279C80D00BF220071B782 /* SVGFEBlendElement.h in Headers */,
B22279CB0D00BF220071B782 /* SVGFEColorMatrixElement.h in Headers */,
+ 51BCCE301F8F179E006BA0ED /* ServiceWorkerThread.h in Headers */,
B22279CE0D00BF220071B782 /* SVGFEComponentTransferElement.h in Headers */,
B22279D10D00BF220071B782 /* SVGFECompositeElement.h in Headers */,
1921327511C0E6BB00456238 /* SVGFEConvolveMatrixElement.h in Headers */,
@@ -31589,6 +31614,7 @@
41D129CF1F3D0EFE00D15E47 /* CacheStorageConnection.cpp in Sources */,
E43AF8E61AC5B7E800CA717E /* CacheValidation.cpp in Sources */,
49AE2D96134EE5F90072920A /* CalculationValue.cpp in Sources */,
+ 517C87181F8FD4D900EB8076 /* ServiceWorkerContextData.cpp in Sources */,
952076041F2675FE007D2AAB /* CallTracer.cpp in Sources */,
415CDAF41E6B8F87004F11EE /* CanvasCaptureMediaStreamTrack.cpp in Sources */,
49484FC1102CF23C00187DD3 /* CanvasGradient.cpp in Sources */,
@@ -32231,6 +32257,7 @@
96ABA42314BCB80E00D56204 /* GraphicsContext3DOpenGLCommon.cpp in Sources */,
B2ED97710B1F55CE00257D0F /* GraphicsContextCG.cpp in Sources */,
B277B4040B22F37C0004BEC6 /* GraphicsContextCocoa.mm in Sources */,
+ 51BCCE2F1F8F1795006BA0ED /* ServiceWorkerThread.cpp in Sources */,
0F580B0C0F12A2690051D689 /* GraphicsLayer.cpp in Sources */,
499B3ED6128CD31400E726C2 /* GraphicsLayerCA.cpp in Sources */,
0FA24D79162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp in Sources */,
@@ -33544,6 +33571,7 @@
C96F5EC61B5872260091EA9D /* MediaSessionInterruptionProviderMac.mm in Sources */,
C90F65551B2253B1002163A1 /* MediaSessionManager.cpp in Sources */,
CD669D681D23364B004D1866 /* MediaSessionManagerCocoa.cpp in Sources */,
+ 517C870A1F8EBB2500EB8076 /* SWContextManager.cpp in Sources */,
07638A9A1884487200E15A1B /* MediaSessionManagerIOS.mm in Sources */,
07EDC3EE1AACB75D00983EB5 /* MediaSessionManagerMac.mm in Sources */,
CD3A495E17A9D01B00274E42 /* MediaSource.cpp in Sources */,
Modified: trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp (223276 => 223277)
--- trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp 2017-10-13 06:44:47 UTC (rev 223277)
@@ -30,6 +30,7 @@
#include "JSDOMBinding.h"
#include "JSDedicatedWorkerGlobalScope.h"
#include "JSEventTarget.h"
+#include "JSServiceWorkerGlobalScope.h"
#include "ScriptSourceCode.h"
#include "WebCoreJSClientData.h"
#include "WorkerConsoleClient.h"
@@ -92,7 +93,26 @@
proxy->setTarget(*m_vm, m_workerGlobalScopeWrapper.get());
proxy->structure()->setGlobalObject(*m_vm, m_workerGlobalScopeWrapper.get());
+#if ENABLE(SERVICE_WORKER)
+ } else if (m_workerGlobalScope->isServiceWorkerGlobalScope()) {
+ Structure* contextPrototypeStructure = JSServiceWorkerGlobalScopePrototype::createStructure(*m_vm, nullptr, jsNull());
+ Strong<JSServiceWorkerGlobalScopePrototype> contextPrototype(*m_vm, JSServiceWorkerGlobalScopePrototype::create(*m_vm, nullptr, contextPrototypeStructure));
+ Structure* structure = JSServiceWorkerGlobalScope::createStructure(*m_vm, nullptr, contextPrototype.get());
+ auto* proxyStructure = JSProxy::createStructure(*m_vm, nullptr, jsNull(), PureForwardingProxyType);
+ auto* proxy = JSProxy::create(*m_vm, proxyStructure);
+
+ m_workerGlobalScopeWrapper.set(*m_vm, JSServiceWorkerGlobalScope::create(*m_vm, structure, static_cast<ServiceWorkerGlobalScope&>(*m_workerGlobalScope), proxy));
+ contextPrototypeStructure->setGlobalObject(*m_vm, m_workerGlobalScopeWrapper.get());
+ ASSERT(structure->globalObject() == m_workerGlobalScopeWrapper);
+ ASSERT(m_workerGlobalScopeWrapper->structure()->globalObject() == m_workerGlobalScopeWrapper);
+ contextPrototype->structure()->setGlobalObject(*m_vm, m_workerGlobalScopeWrapper.get());
+ contextPrototype->structure()->setPrototypeWithoutTransition(*m_vm, JSWorkerGlobalScope::prototype(*m_vm, *m_workerGlobalScopeWrapper.get()));
+
+ proxy->setTarget(*m_vm, m_workerGlobalScopeWrapper.get());
+ proxy->structure()->setGlobalObject(*m_vm, m_workerGlobalScopeWrapper.get());
+#endif
}
+
ASSERT(m_workerGlobalScopeWrapper->globalObject() == m_workerGlobalScopeWrapper);
ASSERT(asObject(m_workerGlobalScopeWrapper->getPrototypeDirect())->globalObject() == m_workerGlobalScopeWrapper);
Modified: trunk/Source/WebCore/dom/EventTargetFactory.in (223276 => 223277)
--- trunk/Source/WebCore/dom/EventTargetFactory.in 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/Source/WebCore/dom/EventTargetFactory.in 2017-10-13 06:44:47 UTC (rev 223277)
@@ -32,6 +32,7 @@
RTCPeerConnection conditional=WEB_RTC
ServiceWorker conditional=SERVICE_WORKER
ServiceWorkerContainer conditional=SERVICE_WORKER
+ServiceWorkerGlobalScope conditional=SERVICE_WORKER
ServiceWorkerRegistration conditional=SERVICE_WORKER
SourceBuffer conditional=MEDIA_SOURCE
SourceBufferList conditional=MEDIA_SOURCE
Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.h (223276 => 223277)
--- trunk/Source/WebCore/workers/WorkerGlobalScope.h 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.h 2017-10-13 06:44:47 UTC (rev 223277)
@@ -59,6 +59,7 @@
virtual ~WorkerGlobalScope();
virtual bool isDedicatedWorkerGlobalScope() const { return false; }
+ virtual bool isServiceWorkerGlobalScope() const { return false; }
const URL& url() const final { return m_url; }
String origin() const;
Copied: trunk/Source/WebCore/workers/service/ServiceWorkerContextData.cpp (from rev 223274, trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp) (0 => 223277)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContextData.cpp (rev 0)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContextData.cpp 2017-10-13 06:44:47 UTC (rev 223277)
@@ -0,0 +1,40 @@
+/*
+ * 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 "ServiceWorkerContextData.h"
+
+#if ENABLE(SERVICE_WORKER)
+
+namespace WebCore {
+
+ServiceWorkerContextData ServiceWorkerContextData::isolatedCopy() const
+{
+ return { registrationKey.isolatedCopy(), workerID.isolatedCopy(), script.isolatedCopy(), scriptURL.isolatedCopy() };
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h (223276 => 223277)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContextData.h 2017-10-13 06:44:47 UTC (rev 223277)
@@ -26,6 +26,7 @@
#pragma once
#include "ServiceWorkerRegistrationKey.h"
+#include "URL.h"
#if ENABLE(SERVICE_WORKER)
@@ -35,15 +36,18 @@
ServiceWorkerRegistrationKey registrationKey;
String workerID;
String script;
+ URL scriptURL;
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static std::optional<ServiceWorkerContextData> decode(Decoder&);
+
+ ServiceWorkerContextData isolatedCopy() const;
};
template<class Encoder>
void ServiceWorkerContextData::encode(Encoder& encoder) const
{
- encoder << registrationKey << workerID << script;
+ encoder << registrationKey << workerID << script << scriptURL;
}
template<class Decoder>
@@ -61,7 +65,11 @@
if (!decoder.decode(script))
return std::nullopt;
- return {{ WTFMove(*registrationKey), WTFMove(workerID), WTFMove(script) }};
+ URL scriptURL;
+ if (!decoder.decode(scriptURL))
+ return std::nullopt;
+
+ return {{ WTFMove(*registrationKey), WTFMove(workerID), WTFMove(script), WTFMove(scriptURL) }};
}
} // namespace WebCore
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp (223276 => 223277)
--- trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp 2017-10-13 06:44:47 UTC (rev 223277)
@@ -28,11 +28,25 @@
#if ENABLE(SERVICE_WORKER)
+#include "ServiceWorkerThread.h"
+
namespace WebCore {
+ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data, const URL& url, const String& identifier, const String& userAgent, ServiceWorkerThread& thread, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider, PAL::SessionID sessionID)
+ : WorkerGlobalScope(url, identifier, userAgent, thread, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, connectionProxy, socketProvider, sessionID)
+ , m_serverConnectionIdentifier(serverConnectionIdentifier)
+ , m_contextData(crossThreadCopy(data))
+{
+}
+
+ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope()
+{
+}
+
ServiceWorkerRegistration& ServiceWorkerGlobalScope::registration()
{
- return m_registration;
+ // FIXME: Is this method still needed?
+ RELEASE_ASSERT_NOT_REACHED();
}
void ServiceWorkerGlobalScope::skipWaiting(Ref<DeferredPromise>&&)
@@ -39,6 +53,11 @@
{
}
+EventTargetInterface ServiceWorkerGlobalScope::eventTargetInterface() const
+{
+ return ServiceWorkerGlobalScopeEventTargetInterfaceType;
+}
+
} // namespace WebCore
#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h (223276 => 223277)
--- trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h 2017-10-13 06:44:47 UTC (rev 223277)
@@ -27,6 +27,7 @@
#if ENABLE(SERVICE_WORKER)
+#include "ServiceWorkerContextData.h"
#include "ServiceWorkerRegistration.h"
#include "WorkerGlobalScope.h"
@@ -33,16 +34,32 @@
namespace WebCore {
class DeferredPromise;
-class ServiceWorkerRegistration;
+class ServiceWorkerThread;
class ServiceWorkerGlobalScope : public WorkerGlobalScope {
public:
+ template<typename... Args> static Ref<ServiceWorkerGlobalScope> create(Args&&... args)
+ {
+ return adoptRef(*new ServiceWorkerGlobalScope(std::forward<Args>(args)...));
+ }
+
+ virtual ~ServiceWorkerGlobalScope();
+
+ bool isServiceWorkerGlobalScope() const final { return true; }
+
ServiceWorkerRegistration& registration();
+
+ uint64_t serverConnectionIdentifier() const { return m_serverConnectionIdentifier; }
void skipWaiting(Ref<DeferredPromise>&&);
+ EventTargetInterface eventTargetInterface() const final;
+
private:
- ServiceWorkerRegistration m_registration;
+ ServiceWorkerGlobalScope(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, const URL&, const String& identifier, const String& userAgent, ServiceWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID);
+
+ uint64_t m_serverConnectionIdentifier;
+ ServiceWorkerContextData m_contextData;
};
} // namespace WebCore
Copied: trunk/Source/WebCore/workers/service/context/SWContextManager.cpp (from rev 223274, trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp) (0 => 223277)
--- trunk/Source/WebCore/workers/service/context/SWContextManager.cpp (rev 0)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.cpp 2017-10-13 06:44:47 UTC (rev 223277)
@@ -0,0 +1,69 @@
+/*
+ * 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 result = m_workerThreadMap.add(thread->identifier(), 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());
+
+ // FIXME: For testing purposes we need to signal a failure with an exception payload.
+ // Later with more APIs and infrastructure filled in, testing will be much easier.
+
+ return Exception { UnknownError, "Worker script successfully started, but it has no way to communicate yet" };
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)
Copied: trunk/Source/WebCore/workers/service/context/SWContextManager.h (from rev 223274, trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h) (0 => 223277)
--- trunk/Source/WebCore/workers/service/context/SWContextManager.h (rev 0)
+++ trunk/Source/WebCore/workers/service/context/SWContextManager.h 2017-10-13 06:44:47 UTC (rev 223277)
@@ -0,0 +1,52 @@
+/*
+ * 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)
Added: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp (0 => 223277)
--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp (rev 0)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp 2017-10-13 06:44:47 UTC (rev 223277)
@@ -0,0 +1,96 @@
+/*
+ * 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 "ServiceWorkerThread.h"
+
+#if ENABLE(SERVICE_WORKER)
+
+#include "ContentSecurityPolicyResponseHeaders.h"
+#include "SecurityOrigin.h"
+#include "ServiceWorkerGlobalScope.h"
+#include "WorkerLoaderProxy.h"
+#include "WorkerObjectProxy.h"
+#include <pal/SessionID.h>
+#include <runtime/RuntimeFlags.h>
+#include <wtf/NeverDestroyed.h>
+
+using namespace PAL;
+
+namespace WebCore {
+
+class ServiceWorkerThreadProxy : public WorkerLoaderProxy, public WorkerObjectProxy {
+public:
+ static ServiceWorkerThreadProxy& sharedDummyProxy()
+ {
+ static NeverDestroyed<ServiceWorkerThreadProxy> proxy;
+ return proxy;
+ }
+
+private:
+ void postTaskToLoader(ScriptExecutionContext::Task&&) final { };
+ bool postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task&&, const String&) final { return false; };
+ void postExceptionToWorkerObject(const String&, int, int, const String&) final { };
+ void postMessageToPageInspector(const String&) final { };
+ void workerGlobalScopeDestroyed() final { };
+ void postMessageToWorkerObject(RefPtr<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>) final { };
+ void confirmMessageFromWorkerObject(bool) final { };
+ void reportPendingActivity(bool) final { };
+};
+
+// FIXME: Use a valid WorkerLoaderProxy
+// FIXME: Use a valid WorkerReportingProxy
+// FIXME: Use a valid WorkerObjectProxy
+// FIXME: Use a valid IDBConnection
+// FIXME: Use a valid SocketProvider
+// FIXME: Use a valid user agent
+// FIXME: Use valid runtime flags
+
+ServiceWorkerThread::ServiceWorkerThread(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data, PAL::SessionID)
+ : WorkerThread(data.scriptURL, data.workerID, ASCIILiteral("WorkerUserAgent"), data.script, ServiceWorkerThreadProxy::sharedDummyProxy(), ServiceWorkerThreadProxy::sharedDummyProxy(), WorkerThreadStartMode::Normal, ContentSecurityPolicyResponseHeaders { }, false, SecurityOrigin::create(data.scriptURL).get(), MonotonicTime::now(), nullptr, nullptr, JSC::RuntimeFlags::createAllEnabled(), SessionID::defaultSessionID())
+ , m_serverConnectionIdentifier(serverConnectionIdentifier)
+ , m_data(data.isolatedCopy())
+ , m_workerObjectProxy(ServiceWorkerThreadProxy::sharedDummyProxy())
+{
+}
+
+ServiceWorkerThread::~ServiceWorkerThread()
+{
+}
+
+Ref<WorkerGlobalScope> ServiceWorkerThread::createWorkerGlobalScope(const URL& url, const String& identifier, const String& userAgent, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID sessionID)
+{
+ return ServiceWorkerGlobalScope::create(m_serverConnectionIdentifier, m_data, url, identifier, userAgent, *this, shouldBypassMainWorldContentSecurityPolicy, WTFMove(topOrigin), timeOrigin, idbConnectionProxy(), socketProvider(), sessionID);
+}
+
+void ServiceWorkerThread::runEventLoop()
+{
+ // FIXME: There will be ServiceWorker specific things to do here.
+ WorkerThread::runEventLoop();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)
Copied: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h (from rev 223274, trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h) (0 => 223277)
--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h (rev 0)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h 2017-10-13 06:44:47 UTC (rev 223277)
@@ -0,0 +1,64 @@
+/*
+ * 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 "ServiceWorkerContextData.h"
+#include "WorkerThread.h"
+#include <wtf/Identified.h>
+
+namespace WebCore {
+
+class ContentSecurityPolicyResponseHeaders;
+class WorkerObjectProxy;
+struct ServiceWorkerContextData;
+
+class ServiceWorkerThread : public WorkerThread, public ThreadSafeIdentified<ServiceWorkerThread> {
+public:
+ template<typename... Args> static Ref<ServiceWorkerThread> create(Args&&... args)
+ {
+ return adoptRef(*new ServiceWorkerThread(std::forward<Args>(args)...));
+ }
+ virtual ~ServiceWorkerThread();
+
+ WorkerObjectProxy& workerObjectProxy() const { return m_workerObjectProxy; }
+
+protected:
+ Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, const String& identifier, const String& userAgent, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) final;
+ void runEventLoop() override;
+
+private:
+ ServiceWorkerThread(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID);
+
+ uint64_t m_serverConnectionIdentifier;
+ ServiceWorkerContextData m_data;
+ WorkerObjectProxy& m_workerObjectProxy;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)
Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (223276 => 223277)
--- trunk/Source/WebCore/workers/service/server/SWServer.cpp 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp 2017-10-13 06:44:47 UTC (rev 223277)
@@ -164,7 +164,7 @@
auto result = m_workersByID.add(workerID, SWServerWorker::create(registrationKey, url, script, type, workerID));
ASSERT(result.isNewEntry);
- connection.startServiceWorkerContext({ registrationKey, workerID, script });
+ connection.startServiceWorkerContext({ registrationKey, workerID, script, url });
return result.iterator->value.get();
}
Modified: trunk/Source/WebKit/ChangeLog (223276 => 223277)
--- trunk/Source/WebKit/ChangeLog 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/Source/WebKit/ChangeLog 2017-10-13 06:44:47 UTC (rev 223277)
@@ -1,3 +1,13 @@
+2017-10-12 Brady Eidson <[email protected]>
+
+ SW "Hello world".
+ https://bugs.webkit.org/show_bug.cgi?id=178187
+
+ Reviewed by Andy Estes.
+
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::startServiceWorkerContext):
+
2017-10-12 Alex Christensen <[email protected]>
Remove unnecessary includes in WebKit
Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (223276 => 223277)
--- trunk/Source/WebKit/WebProcess/WebProcess.cpp 2017-10-13 05:35:47 UTC (rev 223276)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp 2017-10-13 06:44:47 UTC (rev 223277)
@@ -105,6 +105,7 @@
#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>
@@ -1649,11 +1650,10 @@
void WebProcess::startServiceWorkerContext(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data)
{
- // FIXME: Here is where we will actually start the script.
- // For now we bounce back a failure message to the requesting process for test coverage.
-
- auto message = makeString("Failed to start service worker script of length ", String::number(data.script.length()));
- m_workerContextConnection->send(Messages::StorageProcess::ServiceWorkerContextFailedToStart(serverConnectionIdentifier, data.registrationKey, data.workerID, message), 0);
+ 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);
}
#endif