Changeset 224113 in webkit
- Timestamp:
- Oct 27, 2017 9:35:45 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 38 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r224112 r224113 1 2017-10-27 Chris Dumez <cdumez@apple.com> 2 3 Add initial support for serviceWorkerClient.postMessage() 4 https://bugs.webkit.org/show_bug.cgi?id=178794 5 6 Reviewed by Youenn Fablet. 7 8 Add layout test coverage. 9 10 * http/tests/workers/service/basic-ServiceWorker-postMessage.https-expected.txt: 11 * http/tests/workers/service/resources/basic-ServiceWorker-postMessage-worker.js: 12 * http/tests/workers/service/resources/basic-ServiceWorker-postMessage.js: 13 (then): 14 1 15 2017-10-27 Ryan Haddad <ryanhaddad@apple.com> 2 16 -
trunk/LayoutTests/http/tests/workers/service/basic-ServiceWorker-postMessage.https-expected.txt
r223922 r224113 1 PASS: Status code is 200 2 PASS: Status text is Worker received the message event. messageEvent.origin was https://127.0.0.1:8443 3 PASS: Source is Service worker 1 PASS: Client received message from service worker, origin: https://127.0.0.1:8443 2 PASS: Service worker received message 'Message 1' from origin 'https://127.0.0.1:8443' 3 PASS: Client received message from service worker, origin: https://127.0.0.1:8443 4 PASS: Service worker received message 'Message 2' from origin 'https://127.0.0.1:8443' 4 5 -
trunk/LayoutTests/http/tests/workers/service/resources/basic-ServiceWorker-postMessage-worker.js
r223922 r224113 1 let responseToSend = { status: 404, statusText: "Not Found" };2 3 1 self.addEventListener("message", (event) => { 4 responseToSend = event.data; 5 responseToSend.statusText += " messageEvent.origin was " + event.origin; 2 event.source.postMessage("Service worker received message '" + event.data + "' from origin '" + event.origin + "'"); 6 3 }); 7 4 8 self.addEventListener("fetch", (event) => {9 if (event.request.url.indexOf("test1") !== -1) {10 event.respondWith(new Response(null, responseToSend));11 return;12 }13 event.respondWith(Response.error());14 }); -
trunk/LayoutTests/http/tests/workers/service/resources/basic-ServiceWorker-postMessage.js
r223922 r224113 1 function done() 2 { 3 finishSWTest(); 4 } 1 var messageNumber = 1; 2 navigator.serviceWorker.addEventListener("message", function(event) { 3 log("PASS: Client received message from service worker, origin: " + event.origin); 4 log("PASS: " + event.data); 5 if (messageNumber == 1) { 6 event.source.postMessage("Message 2"); 7 messageNumber++; 8 } else 9 finishSWTest(); 10 }); 5 11 6 async function test() 7 { 8 try { 9 await navigator.serviceWorker.register("resources/basic-ServiceWorker-postMessage-worker.js", { }); 10 11 navigator.serviceWorker.controller.postMessage({ status: 200, statusText: "Worker received the message event." }); 12 13 let response = await fetch("test1"); 14 if (response.status == 200) 15 log("PASS: Status code is " + response.status); 16 else 17 log("FAIL: Status code is " + response.status); 18 19 if (response.statusText.startsWith("Worker received the message")) 20 log("PASS: Status text is " + response.statusText); 21 else 22 log("FAIL: Status text is " + response.statusText); 23 24 if (window.internals) { 25 let source = internals.fetchResponseSource(response); 26 if (source === "Service worker") 27 log("PASS: Source is " + source); 28 else 29 log("FAIL: Source is " + source); 30 } 31 } catch(e) { 32 log("Got exception: " + e); 33 } 34 finishSWTest(); 35 } 36 37 test(); 12 navigator.serviceWorker.register("resources/basic-ServiceWorker-postMessage-worker.js", { }).then(function() { 13 navigator.serviceWorker.controller.postMessage("Message 1"); 14 }); -
trunk/Source/WebCore/ChangeLog
r224110 r224113 1 2017-10-27 Chris Dumez <cdumez@apple.com> 2 3 Add initial support for serviceWorkerClient.postMessage() 4 https://bugs.webkit.org/show_bug.cgi?id=178794 5 6 Reviewed by Youenn Fablet. 7 8 Add initial support for serviceWorkerClient.postMessage(): 9 - https://w3c.github.io/ServiceWorker/#client-postmessage 10 11 It is now possible to do bi-directional communication with a service worker 12 via postMessage(). 13 14 No new tests, updated existing test. 15 16 * WebCore.xcodeproj/project.pbxproj: 17 * dom/Document.cpp: 18 (WebCore::generateDocumentIdentifier): 19 (WebCore::Document::allDocumentsMap): 20 (WebCore::Document::allDocuments): 21 (WebCore::m_identifier): 22 (WebCore::Document::~Document): 23 * dom/Document.h: 24 (WebCore::Document::identifier const): 25 * dom/ScriptExecutionContext.cpp: 26 (WebCore::ScriptExecutionContext::serviceWorkerContainer): 27 * dom/ScriptExecutionContext.h: 28 * workers/service/ServiceWorker.cpp: 29 (WebCore::ServiceWorker::postMessage): 30 * workers/service/ServiceWorkerClient.cpp: 31 (WebCore::ServiceWorkerClient::ServiceWorkerClient): 32 (WebCore::ServiceWorkerClient::~ServiceWorkerClient): 33 (WebCore::ServiceWorkerClient::id const): 34 (WebCore::ServiceWorkerClient::postMessage): 35 * workers/service/ServiceWorkerClient.h: 36 (WebCore::ServiceWorkerClient::create): 37 * workers/service/ServiceWorkerClient.idl: 38 * workers/service/ServiceWorkerClientIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerClient.idl. 39 (WebCore::ServiceWorkerClientIdentifier::toString const): 40 * workers/service/ServiceWorkerRegistration.cpp: 41 (WebCore::ServiceWorkerRegistration::unregister): 42 * workers/service/ServiceWorkerWindowClient.cpp: 43 (WebCore::ServiceWorkerWindowClient::ServiceWorkerWindowClient): 44 * workers/service/ServiceWorkerWindowClient.h: 45 * workers/service/context/SWContextManager.cpp: 46 (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): 47 * workers/service/context/SWContextManager.h: 48 * workers/service/context/ServiceWorkerThread.cpp: 49 (WebCore::ServiceWorkerThread::postMessageToServiceWorkerGlobalScope): 50 * workers/service/context/ServiceWorkerThread.h: 51 * workers/service/server/SWClientConnection.cpp: 52 (WebCore::SWClientConnection::postMessageToServiceWorkerClient): 53 * workers/service/server/SWClientConnection.h: 54 1 55 2017-10-27 Frederic Wang <fwang@igalia.com> 2 56 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r224061 r224113 2244 2244 837A80131E1E127300026B9F /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 837A80111E1E127300026B9F /* Localizable.stringsdict */; }; 2245 2245 837B7D201DC3F55000D051FC /* ValidationBubbleIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 837B7D1F1DC3F54C00D051FC /* ValidationBubbleIOS.mm */; }; 2246 837D46271FA2A8CE0054E1FA /* ServiceWorkerClientIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 837D46251FA2A8C50054E1FA /* ServiceWorkerClientIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2246 2247 837FB3451F9EA06D00D0FC31 /* ExtendableMessageEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 837FB3401F9EA06600D0FC31 /* ExtendableMessageEvent.h */; }; 2247 2248 8386A96D19F61B2E00E1EC4A /* StyleBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 8386A96C19F61B2E00E1EC4A /* StyleBuilder.h */; }; … … 9522 9523 837A80121E1E127300026B9F /* English */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = English; path = English.lproj/Localizable.stringsdict; sourceTree = SOURCE_ROOT; }; 9523 9524 837B7D1F1DC3F54C00D051FC /* ValidationBubbleIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ValidationBubbleIOS.mm; sourceTree = "<group>"; }; 9525 837D46251FA2A8C50054E1FA /* ServiceWorkerClientIdentifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerClientIdentifier.h; sourceTree = "<group>"; }; 9524 9526 837DFB341EBFEA7000601385 /* ElementCSSInlineStyle.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ElementCSSInlineStyle.idl; sourceTree = "<group>"; }; 9525 9527 837FB3401F9EA06600D0FC31 /* ExtendableMessageEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtendableMessageEvent.h; sourceTree = "<group>"; }; … … 17314 17316 46EF14241F97B7BA00C2A524 /* ServiceWorkerClient.h */, 17315 17317 46EF14281F97B7BA00C2A524 /* ServiceWorkerClient.idl */, 17318 837D46251FA2A8C50054E1FA /* ServiceWorkerClientIdentifier.h */, 17316 17319 46EF14211F97B7BA00C2A524 /* ServiceWorkerClients.cpp */, 17317 17320 46EF14221F97B7BA00C2A524 /* ServiceWorkerClients.h */, … … 28881 28884 51F1755D1F3EBC8300C74950 /* ServiceWorker.h in Headers */, 28882 28885 46EF142D1F97B7D800C2A524 /* ServiceWorkerClient.h in Headers */, 28886 837D46271FA2A8CE0054E1FA /* ServiceWorkerClientIdentifier.h in Headers */, 28883 28887 46EF142C1F97B7D800C2A524 /* ServiceWorkerClients.h in Headers */, 28884 28888 8369FDFC1FA102E300C1FF1F /* ServiceWorkerClientType.h in Headers */, -
trunk/Source/WebCore/dom/Document.cpp
r224053 r224113 435 435 uint64_t Document::s_globalTreeVersion = 0; 436 436 437 HashSet<Document*>& Document::allDocuments() 438 { 439 static NeverDestroyed<HashSet<Document*>> documents; 437 static uint64_t generateDocumentIdentifier() 438 { 439 static uint64_t identifier = 0; 440 return ++identifier; 441 } 442 443 auto Document::allDocumentsMap() -> DocumentsMap& 444 { 445 static NeverDestroyed<DocumentsMap> documents; 440 446 return documents; 447 } 448 449 auto Document::allDocuments() -> DocumentsMap::ValuesIteratorRange 450 { 451 return allDocumentsMap().values(); 441 452 } 442 453 … … 497 508 , m_isNonRenderedPlaceholder(constructionFlags & NonRenderedPlaceholder) 498 509 , m_orientationNotifier(currentOrientation(frame)) 499 { 500 allDocuments().add(this); 510 , m_identifier(generateDocumentIdentifier()) 511 { 512 auto addResult = allDocumentsMap().add(m_identifier, this); 513 ASSERT_UNUSED(addResult, addResult.isNewEntry); 501 514 502 515 // We depend on the url getting immediately set in subframes, but we … … 548 561 Document::~Document() 549 562 { 550 allDocuments().remove(this); 563 bool wasRemoved = allDocumentsMap().remove(m_identifier); 564 ASSERT_UNUSED(wasRemoved, wasRemoved); 551 565 552 566 ASSERT(!renderView()); -
trunk/Source/WebCore/dom/Document.h
r224053 r224113 348 348 void removedLastRef(); 349 349 350 WEBCORE_EXPORT static HashSet<Document*>& allDocuments(); 350 uint64_t identifier() const { return m_identifier; } 351 352 using DocumentsMap = HashMap<uint64_t, Document*>; 353 WEBCORE_EXPORT static DocumentsMap::ValuesIteratorRange allDocuments(); 354 WEBCORE_EXPORT static DocumentsMap& allDocumentsMap(); 351 355 352 356 MediaQueryMatcher& mediaQueryMatcher(); … … 1836 1840 1837 1841 RefPtr<DocumentTimeline> m_timeline; 1842 uint64_t m_identifier; 1838 1843 }; 1839 1844 -
trunk/Source/WebCore/dom/ScriptExecutionContext.cpp
r223476 r224113 39 39 #include "JSDOMWindow.h" 40 40 #include "MessagePort.h" 41 #include "Navigator.h" 41 42 #include "NoEventDispatchAssertion.h" 42 43 #include "PublicURLManager.h" … … 46 47 #include "Settings.h" 47 48 #include "WorkerGlobalScope.h" 49 #include "WorkerNavigator.h" 48 50 #include "WorkerThread.h" 49 51 #include <heap/StrongInlines.h> … … 526 528 } 527 529 530 #if ENABLE(SERVICE_WORKER) 531 ServiceWorkerContainer* ScriptExecutionContext::serviceWorkerContainer() 532 { 533 NavigatorBase* navigator = nullptr; 534 if (is<Document>(*this)) { 535 if (auto* window = downcast<Document>(*this).domWindow()) 536 navigator = window->navigator(); 537 } else 538 navigator = &downcast<WorkerGlobalScope>(*this).navigator(); 539 540 return navigator ? navigator->serviceWorker() : nullptr; 541 } 542 #endif 543 528 544 } // namespace WebCore -
trunk/Source/WebCore/dom/ScriptExecutionContext.h
r223922 r224113 69 69 class URL; 70 70 71 #if ENABLE(SERVICE_WORKER) 72 class ServiceWorkerContainer; 73 #endif 74 71 75 namespace IDBClient { 72 76 class IDBConnectionProxy; … … 235 239 uint64_t selectedServiceWorkerIdentifier() const { return m_serviceWorkerIdentifier; } 236 240 void setSelectedServiceWorkerIdentifier(uint64_t identifier) { m_serviceWorkerIdentifier = identifier; } 241 242 ServiceWorkerContainer* serviceWorkerContainer(); 237 243 #endif 238 244 -
trunk/Source/WebCore/workers/service/ServiceWorker.cpp
r223922 r224113 70 70 71 71 auto& swConnection = ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(context.sessionID()); 72 swConnection.postMessageToServiceWorkerGlobalScope(m_identifier, message.releaseReturnValue(), context .origin());72 swConnection.postMessageToServiceWorkerGlobalScope(m_identifier, message.releaseReturnValue(), context); 73 73 74 74 return { }; -
trunk/Source/WebCore/workers/service/ServiceWorkerClient.cpp
r223985 r224113 29 29 #include "ServiceWorkerClient.h" 30 30 31 #include "MessagePort.h" 32 #include "SWContextManager.h" 33 #include "ScriptExecutionContext.h" 34 #include "SerializedScriptValue.h" 35 #include "ServiceWorkerGlobalScope.h" 36 #include "ServiceWorkerThread.h" 37 31 38 namespace WebCore { 32 39 33 ServiceWorkerClient::ServiceWorkerClient(ScriptExecutionContext& context, Type type)40 ServiceWorkerClient::ServiceWorkerClient(ScriptExecutionContext& context, const Identifier& identifier, Type type) 34 41 : ContextDestructionObserver(&context) 42 , m_identifier(identifier) 35 43 , m_type(type) 44 { 45 } 46 47 ServiceWorkerClient::~ServiceWorkerClient() 36 48 { 37 49 } … … 49 61 String ServiceWorkerClient::id() const 50 62 { 51 return { };63 return m_identifier.toString(); 52 64 } 53 65 54 ExceptionOr<void> ServiceWorkerClient::postMessage( JSC::ExecState&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&& transfer)66 ExceptionOr<void> ServiceWorkerClient::postMessage(ScriptExecutionContext& context, JSC::JSValue messageValue, Vector<JSC::Strong<JSC::JSObject>>&& transfer) 55 67 { 56 UNUSED_PARAM(message); 57 UNUSED_PARAM(transfer); 58 return Exception { NotSupportedError, ASCIILiteral("client.postMessage() is not yet supported") }; 68 auto* execState = context.execState(); 69 ASSERT(execState); 70 71 Vector<RefPtr<MessagePort>> ports; 72 auto message = SerializedScriptValue::create(*execState, messageValue, WTFMove(transfer), ports, SerializationContext::WorkerPostMessage); 73 if (message.hasException()) 74 return message.releaseException(); 75 76 // Disentangle the port in preparation for sending it to the remote context. 77 auto channelsOrException = MessagePort::disentanglePorts(WTFMove(ports)); 78 if (channelsOrException.hasException()) 79 return channelsOrException.releaseException(); 80 81 // FIXME: Support sending the channels. 82 auto channels = channelsOrException.releaseReturnValue(); 83 if (channels && !channels->isEmpty()) 84 return Exception { NotSupportedError, ASCIILiteral("Passing MessagePort objects to postMessage is not yet supported") }; 85 86 uint64_t sourceIdentifier = downcast<ServiceWorkerGlobalScope>(context).thread().identifier(); 87 callOnMainThread([message = message.releaseReturnValue(), destinationIdentifier = m_identifier, sourceIdentifier, sourceOrigin = context.origin().isolatedCopy()] () mutable { 88 if (auto* connection = SWContextManager::singleton().connection()) 89 connection->postMessageToServiceWorkerClient(destinationIdentifier, WTFMove(message), sourceIdentifier, sourceOrigin); 90 }); 91 92 return { }; 59 93 } 60 94 -
trunk/Source/WebCore/workers/service/ServiceWorkerClient.h
r223985 r224113 30 30 #include "ContextDestructionObserver.h" 31 31 #include "ExceptionOr.h" 32 #include "ServiceWorkerClientIdentifier.h" 32 33 #include "ServiceWorkerClientType.h" 33 34 #include <heap/Strong.h> … … 35 36 36 37 namespace JSC { 37 class ExecState;38 38 class JSValue; 39 39 } … … 43 43 class ServiceWorkerClient : public RefCounted<ServiceWorkerClient>, public ContextDestructionObserver { 44 44 public: 45 using Identifier = ServiceWorkerClientIdentifier; 46 45 47 using Type = ServiceWorkerClientType; 46 48 enum class FrameType { … … 51 53 }; 52 54 53 static Ref<ServiceWorkerClient> create(ScriptExecutionContext& context, Type type)55 static Ref<ServiceWorkerClient> create(ScriptExecutionContext& context, const Identifier& identifier, Type type) 54 56 { 55 return adoptRef(*new ServiceWorkerClient(context, type));57 return adoptRef(*new ServiceWorkerClient(context, identifier, type)); 56 58 } 59 60 ~ServiceWorkerClient(); 57 61 58 62 String url() const; … … 61 65 String id() const; 62 66 63 ExceptionOr<void> postMessage( JSC::ExecState&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&& transfer);67 ExceptionOr<void> postMessage(ScriptExecutionContext&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&& transfer); 64 68 65 69 protected: 66 ServiceWorkerClient(ScriptExecutionContext&, Type);70 ServiceWorkerClient(ScriptExecutionContext&, const Identifier&, Type); 67 71 72 Identifier m_identifier; 68 73 Type m_type; 69 74 }; -
trunk/Source/WebCore/workers/service/ServiceWorkerClient.idl
r223985 r224113 36 36 readonly attribute DOMString id; 37 37 38 [CallWith=Script State, MayThrowException] void postMessage(any message, optional sequence<object> transfer = []);38 [CallWith=ScriptExecutionContext, MayThrowException] void postMessage(any message, optional sequence<object> transfer = []); 39 39 }; 40 40 -
trunk/Source/WebCore/workers/service/ServiceWorkerClientIdentifier.h
r224112 r224113 24 24 */ 25 25 26 [ 27 Conditional=SERVICE_WORKER, 28 CustomToJSObject, 29 EnabledAtRuntime=ServiceWorker, 30 Exposed=ServiceWorker, 31 InterfaceName=Client, 32 ] interface ServiceWorkerClient { 33 readonly attribute USVString url; 34 readonly attribute FrameType frameType; 35 readonly attribute ServiceWorkerClientType type; 36 readonly attribute DOMString id; 26 #pragma once 37 27 38 [CallWith=ScriptState, MayThrowException] void postMessage(any message, optional sequence<object> transfer = []); 28 #include <wtf/text/WTFString.h> 29 30 namespace WebCore { 31 32 struct ServiceWorkerClientIdentifier { 33 uint64_t serverConnectionIdentifier; 34 uint64_t scriptExecutionContextIdentifier; 35 36 String toString() const { return String::number(serverConnectionIdentifier) + "-" + String::number(scriptExecutionContextIdentifier); } 39 37 }; 40 38 41 enum FrameType { 42 "auxiliary", 43 "top-level", 44 "nested", 45 "none" 46 }; 39 } -
trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp
r223964 r224113 30 30 #include "DOMWindow.h" 31 31 #include "Document.h" 32 #include "Navigator.h"33 32 #include "ServiceWorkerContainer.h" 34 33 #include "WorkerGlobalScope.h" 35 #include "WorkerNavigator.h"36 34 37 35 namespace WebCore { 38 39 static ServiceWorkerContainer* containerForScriptExecutionContext(ScriptExecutionContext& context)40 {41 NavigatorBase* navigator = nullptr;42 if (is<Document>(context)) {43 if (auto* window = downcast<Document>(context).domWindow())44 navigator = window->navigator();45 } else46 navigator = &downcast<WorkerGlobalScope>(context).navigator();47 48 return navigator ? navigator->serviceWorker() : nullptr;49 }50 36 51 37 ServiceWorkerRegistration::ServiceWorkerRegistration(ScriptExecutionContext& context, ServiceWorkerRegistrationData&& registrationData) … … 95 81 } 96 82 97 auto* container = cont ainerForScriptExecutionContext(*context);83 auto* container = context->serviceWorkerContainer(); 98 84 if (!container) { 99 85 promise->reject(Exception(InvalidStateError)); -
trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.cpp
r223985 r224113 33 33 namespace WebCore { 34 34 35 ServiceWorkerWindowClient::ServiceWorkerWindowClient(ScriptExecutionContext& context )36 : ServiceWorkerClient(context, Type::Window)35 ServiceWorkerWindowClient::ServiceWorkerWindowClient(ScriptExecutionContext& context, const Identifier& identifier) 36 : ServiceWorkerClient(context, identifier, Type::Window) 37 37 { 38 38 } -
trunk/Source/WebCore/workers/service/ServiceWorkerWindowClient.h
r223985 r224113 37 37 class ServiceWorkerWindowClient final : public ServiceWorkerClient { 38 38 public: 39 static Ref<ServiceWorkerWindowClient> create(ScriptExecutionContext& context )39 static Ref<ServiceWorkerWindowClient> create(ScriptExecutionContext& context, const Identifier& identifier) 40 40 { 41 return adoptRef(*new ServiceWorkerWindowClient(context ));41 return adoptRef(*new ServiceWorkerWindowClient(context, identifier)); 42 42 } 43 43 … … 49 49 50 50 private: 51 explicit ServiceWorkerWindowClient(ScriptExecutionContext&);51 ServiceWorkerWindowClient(ScriptExecutionContext&, const Identifier&); 52 52 }; 53 53 -
trunk/Source/WebCore/workers/service/context/SWContextManager.cpp
r224041 r224113 60 60 } 61 61 62 void SWContextManager::postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, Ref<SerializedScriptValue>&& message, const String& sourceOrigin)62 void SWContextManager::postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, Ref<SerializedScriptValue>&& message, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin) 63 63 { 64 auto* serviceWorker = m_workerMap.get( serviceWorkerIdentifier);64 auto* serviceWorker = m_workerMap.get(destinationServiceWorkerIdentifier); 65 65 if (!serviceWorker) 66 66 return; 67 67 68 68 // FIXME: We should pass valid MessagePortChannels. 69 serviceWorker->thread().postMessageToServiceWorkerGlobalScope(WTFMove(message), nullptr, source Origin);69 serviceWorker->thread().postMessageToServiceWorkerGlobalScope(WTFMove(message), nullptr, sourceIdentifier, sourceOrigin); 70 70 } 71 71 -
trunk/Source/WebCore/workers/service/context/SWContextManager.h
r224041 r224113 35 35 36 36 class SerializedScriptValue; 37 struct ServiceWorkerClientIdentifier; 37 38 38 39 class SWContextManager { … … 43 44 public: 44 45 virtual ~Connection() { } 46 47 virtual void postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destinationIdentifier, Ref<SerializedScriptValue>&& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin) = 0; 45 48 }; 46 49 … … 50 53 WEBCORE_EXPORT void registerServiceWorkerThread(Ref<ServiceWorkerThreadProxy>&&); 51 54 WEBCORE_EXPORT ServiceWorkerThreadProxy* serviceWorkerThreadProxy(uint64_t) const; 52 WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, Ref<SerializedScriptValue>&& message, const String& sourceOrigin);55 WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, Ref<SerializedScriptValue>&& message, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin); 53 56 54 57 private: -
trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp
r223981 r224113 35 35 #include "ServiceWorkerFetch.h" 36 36 #include "ServiceWorkerGlobalScope.h" 37 #include "ServiceWorkerWindowClient.h" 37 38 #include "WorkerLoaderProxy.h" 38 39 #include "WorkerObjectProxy.h" … … 100 101 } 101 102 102 void ServiceWorkerThread::postMessageToServiceWorkerGlobalScope(Ref<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray>&& channels, const S tring& sourceOrigin)103 void ServiceWorkerThread::postMessageToServiceWorkerGlobalScope(Ref<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray>&& channels, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin) 103 104 { 104 ScriptExecutionContext::Task task([channels = WTFMove(channels), message = WTFMove(message), source Origin = sourceOrigin.isolatedCopy()] (ScriptExecutionContext& context) mutable {105 ScriptExecutionContext::Task task([channels = WTFMove(channels), message = WTFMove(message), sourceIdentifier, sourceOrigin = sourceOrigin.isolatedCopy()] (ScriptExecutionContext& context) mutable { 105 106 auto& serviceWorkerGlobalScope = downcast<ServiceWorkerGlobalScope>(context); 106 107 auto ports = MessagePort::entanglePorts(serviceWorkerGlobalScope, WTFMove(channels)); 107 serviceWorkerGlobalScope.dispatchEvent(ExtendableMessageEvent::create(WTFMove(ports), WTFMove(message), sourceOrigin)); 108 ExtendableMessageEventSource source = RefPtr<ServiceWorkerClient> { ServiceWorkerWindowClient::create(context, sourceIdentifier) }; 109 serviceWorkerGlobalScope.dispatchEvent(ExtendableMessageEvent::create(WTFMove(ports), WTFMove(message), sourceOrigin, { }, WTFMove(source))); 108 110 serviceWorkerGlobalScope.thread().workerObjectProxy().confirmMessageFromWorkerObject(serviceWorkerGlobalScope.hasPendingActivity()); 109 111 }); -
trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h
r223981 r224113 41 41 class WorkerLoaderProxy; 42 42 class WorkerObjectProxy; 43 struct ServiceWorkerClientIdentifier; 43 44 struct ServiceWorkerContextData; 44 45 … … 56 57 57 58 WEBCORE_EXPORT void postFetchTask(Ref<ServiceWorkerFetch::Client>&&, ResourceRequest&&, FetchOptions&&); 58 WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>&&, const S tring& sourceOrigin);59 WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>&&, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin); 59 60 60 61 protected: -
trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp
r223964 r224113 29 29 #if ENABLE(SERVICE_WORKER) 30 30 31 #include "Document.h" 31 32 #include "ExceptionData.h" 33 #include "MessageEvent.h" 34 #include "ServiceWorkerContainer.h" 32 35 #include "ServiceWorkerFetchResult.h" 33 36 #include "ServiceWorkerJobData.h" … … 110 113 } 111 114 115 void SWClientConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, Ref<SerializedScriptValue>&& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin) 116 { 117 // FIXME: destinationScriptExecutionContextIdentifier can only identify a Document at the moment. 118 auto* destinationDocument = Document::allDocumentsMap().get(destinationScriptExecutionContextIdentifier); 119 if (!destinationDocument) 120 return; 121 122 auto* container = destinationDocument->serviceWorkerContainer(); 123 if (!container) 124 return; 125 126 std::optional<MessageEventSource> source; 127 if (destinationDocument->selectedServiceWorkerIdentifier() == sourceServiceWorkerIdentifier) { 128 ASSERT(container->controller()->identifier() == sourceServiceWorkerIdentifier); 129 source = MessageEventSource { RefPtr<ServiceWorker> { container->controller() } }; 130 } else 131 source = MessageEventSource { RefPtr<ServiceWorker> { ServiceWorker::create(*destinationDocument, sourceServiceWorkerIdentifier) } }; 132 133 // FIXME: We should pass in ports. 134 auto messageEvent = MessageEvent::create({ }, WTFMove(message), sourceOrigin, { }, WTFMove(source)); 135 container->dispatchEvent(messageEvent); 136 } 137 112 138 } // namespace WebCore 113 139 -
trunk/Source/WebCore/workers/service/server/SWClientConnection.h
r223964 r224113 50 50 void finishedFetchingScript(ServiceWorkerJob&, const String&); 51 51 void failedFetchingScript(ServiceWorkerJob&, const ResourceError&); 52 virtual void postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, Ref<SerializedScriptValue>&&, const String& sourceOrigin) = 0;52 virtual void postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, Ref<SerializedScriptValue>&&, ScriptExecutionContext& source) = 0; 53 53 54 54 virtual uint64_t identifier() const = 0; … … 60 60 WEBCORE_EXPORT void unregistrationJobResolvedInServer(uint64_t jobIdentifier, bool unregistrationResult); 61 61 WEBCORE_EXPORT void startScriptFetchForServer(uint64_t jobIdentifier); 62 WEBCORE_EXPORT void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, Ref<SerializedScriptValue>&& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin); 62 63 63 64 private: -
trunk/Source/WebKit/ChangeLog
r224095 r224113 1 2017-10-27 Chris Dumez <cdumez@apple.com> 2 3 Add initial support for serviceWorkerClient.postMessage() 4 https://bugs.webkit.org/show_bug.cgi?id=178794 5 6 Reviewed by Youenn Fablet. 7 8 Add initial support for serviceWorkerClient.postMessage(): 9 - https://w3c.github.io/ServiceWorker/#client-postmessage 10 11 It is now possible to do bi-directional communication with a service worker 12 via postMessage(). 13 14 * Shared/WebCoreArgumentCoders.cpp: 15 (IPC::ArgumentCoder<ServiceWorkerClientIdentifier>::encode): 16 (IPC::ArgumentCoder<ServiceWorkerClientIdentifier>::decode): 17 * Shared/WebCoreArgumentCoders.h: 18 * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: 19 (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): 20 (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): 21 * StorageProcess/ServiceWorker/WebSWServerConnection.h: 22 * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: 23 * StorageProcess/StorageProcess.cpp: 24 (WebKit::StorageProcess::postMessageToServiceWorkerClient): 25 * StorageProcess/StorageProcess.h: 26 * StorageProcess/StorageProcess.messages.in: 27 * WebProcess/Storage/WebSWClientConnection.cpp: 28 (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): 29 (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): 30 * WebProcess/Storage/WebSWClientConnection.h: 31 * WebProcess/Storage/WebSWClientConnection.messages.in: 32 * WebProcess/Storage/WebSWContextManagerConnection.cpp: 33 (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): 34 (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): 35 * WebProcess/Storage/WebSWContextManagerConnection.h: 36 * WebProcess/Storage/WebSWContextManagerConnection.messages.in: 37 1 38 2017-10-27 David Kilzer <ddkilzer@apple.com> 2 39 -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
r223678 r224113 66 66 #include <WebCore/ScrollingCoordinator.h> 67 67 #include <WebCore/SearchPopupMenu.h> 68 #include <WebCore/ServiceWorkerClientIdentifier.h> 68 69 #include <WebCore/TextCheckerClient.h> 69 70 #include <WebCore/TextIndicator.h> … … 1901 1902 return true; 1902 1903 } 1904 1905 #if ENABLE(SERVICE_WORKER) 1906 void ArgumentCoder<ServiceWorkerClientIdentifier>::encode(Encoder& encoder, const ServiceWorkerClientIdentifier& identifier) 1907 { 1908 encoder << identifier.serverConnectionIdentifier << identifier.scriptExecutionContextIdentifier; 1909 } 1910 1911 bool ArgumentCoder<ServiceWorkerClientIdentifier>::decode(Decoder& decoder, ServiceWorkerClientIdentifier& identifier) 1912 { 1913 uint64_t serverConnectionIdentifier; 1914 if (!decoder.decode(serverConnectionIdentifier)) 1915 return false; 1916 1917 uint64_t scriptExecutionContextIdentifier; 1918 if (!decoder.decode(scriptExecutionContextIdentifier)) 1919 return false; 1920 1921 identifier = { serverConnectionIdentifier, scriptExecutionContextIdentifier }; 1922 return true; 1923 } 1924 #endif 1903 1925 1904 1926 void ArgumentCoder<TextCheckingResult>::encode(Encoder& encoder, const TextCheckingResult& result) -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h
r223652 r224113 158 158 using IDBKeyPath = Variant<String, Vector<String>>; 159 159 #endif 160 161 #if ENABLE(SERVICE_WORKER) 162 struct ServiceWorkerClientIdentifier; 163 #endif 160 164 } 161 165 … … 477 481 static bool decode(Decoder&, WebCore::TextCheckingRequestData&); 478 482 }; 483 484 #if ENABLE(SERVICE_WORKER) 485 template<> struct ArgumentCoder<WebCore::ServiceWorkerClientIdentifier> { 486 static void encode(Encoder&, const WebCore::ServiceWorkerClientIdentifier&); 487 static bool decode(Decoder&, WebCore::ServiceWorkerClientIdentifier&); 488 }; 489 #endif 479 490 480 491 template<> struct ArgumentCoder<WebCore::TextCheckingResult> { -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp
r224041 r224113 45 45 #include <WebCore/NotImplemented.h> 46 46 #include <WebCore/SecurityOrigin.h> 47 #include <WebCore/ServiceWorkerClientIdentifier.h> 47 48 #include <WebCore/ServiceWorkerContextData.h> 48 49 #include <WebCore/ServiceWorkerJobData.h> … … 109 110 } 110 111 111 void WebSWServerConnection::postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin)112 void WebSWServerConnection::postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, const IPC::DataReference& message, uint64_t sourceScriptExecutionContextIdentifier, const String& sourceOrigin) 112 113 { 113 sendToContextProcess(Messages::WebSWContextManagerConnection::PostMessageToServiceWorkerGlobalScope(serviceWorkerIdentifier, message, sourceOrigin)); 114 ServiceWorkerClientIdentifier sourceIdentifier { identifier(), sourceScriptExecutionContextIdentifier }; 115 sendToContextProcess(Messages::WebSWContextManagerConnection::PostMessageToServiceWorkerGlobalScope { destinationServiceWorkerIdentifier, message, sourceIdentifier, sourceOrigin }); 114 116 } 115 117 … … 139 141 } 140 142 143 void WebSWServerConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin) 144 { 145 send(Messages::WebSWClientConnection::PostMessageToServiceWorkerClient { destinationScriptExecutionContextIdentifier, message, sourceServiceWorkerIdentifier, sourceOrigin }); 146 } 147 141 148 template<typename U> bool WebSWServerConnection::sendToContextProcess(U&& message) 142 149 { -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h
r223964 r224113 58 58 void didNotHandleFetch(uint64_t fetchIdentifier); 59 59 60 void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin); 61 60 62 private: 61 63 // Implement SWServer::Connection (Messages to the client WebProcess) … … 67 69 void startFetch(uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&); 68 70 69 void postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin);71 void postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, const IPC::DataReference& message, uint64_t sourceScriptExecutionContextIdentifier, const String& sourceOrigin); 70 72 71 73 // Messages to the SW context WebProcess -
trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in
r223922 r224113 29 29 30 30 StartFetch(uint64_t identifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options) 31 PostMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, IPC::DataReference message, String sourceOrigin)31 PostMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, IPC::DataReference message, uint64_t sourceScriptExecutionContextIdentifier, String sourceOrigin) 32 32 } 33 33 -
trunk/Source/WebKit/StorageProcess/StorageProcess.cpp
r223951 r224113 39 39 #include <WebCore/NotImplemented.h> 40 40 #include <WebCore/SecurityOrigin.h> 41 #include <WebCore/ServiceWorkerClientIdentifier.h> 41 42 #include <WebCore/TextEncoding.h> 42 43 #include <pal/SessionID.h> … … 436 437 } 437 438 439 void StorageProcess::postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destinationIdentifier, const IPC::DataReference& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin) 440 { 441 if (auto* connection = m_swServerConnections.get(destinationIdentifier.serverConnectionIdentifier)) 442 connection->postMessageToServiceWorkerClient(destinationIdentifier.scriptExecutionContextIdentifier, message, sourceServiceWorkerIdentifier, sourceOrigin); 443 } 444 438 445 void StorageProcess::registerSWServerConnection(WebSWServerConnection& connection) 439 446 { -
trunk/Source/WebKit/StorageProcess/StorageProcess.h
r223951 r224113 38 38 class SWServer; 39 39 struct SecurityOriginData; 40 struct ServiceWorkerClientIdentifier; 40 41 struct ServiceWorkerRegistrationKey; 41 42 } … … 126 127 void didFailFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier); 127 128 void didNotHandleFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier); 129 130 void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, const IPC::DataReference& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin); 128 131 #endif 129 132 #if ENABLE(INDEXED_DATABASE) -
trunk/Source/WebKit/StorageProcess/StorageProcess.messages.in
r223839 r224113 47 47 DidReceiveFetchData(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, IPC::DataReference data, int64_t encodedDataLength) 48 48 DidFinishFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier) 49 PostMessageToServiceWorkerClient(struct WebCore::ServiceWorkerClientIdentifier destinationIdentifier, IPC::DataReference message, uint64_t sourceServiceWorkerIdentifier, String sourceOrigin) 49 50 #endif 50 51 } -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
r223922 r224113 36 36 #include "WebSWOriginTable.h" 37 37 #include "WebSWServerConnectionMessages.h" 38 #include <WebCore/Document.h> 38 39 #include <WebCore/SerializedScriptValue.h> 39 40 #include <WebCore/ServiceWorkerFetchResult.h> … … 69 70 } 70 71 71 void WebSWClientConnection::postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, Ref<SerializedScriptValue>&& scriptValue, const String& sourceOrigin)72 void WebSWClientConnection::postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, Ref<SerializedScriptValue>&& scriptValue, ScriptExecutionContext& source) 72 73 { 73 send(Messages::WebSWServerConnection::PostMessageToServiceWorkerGlobalScope(serviceWorkerIdentifier, IPC::DataReference { scriptValue->data() }, sourceOrigin)); 74 // FIXME: Add support for posting messages from workers. 75 if (!is<Document>(source)) 76 return; 77 78 send(Messages::WebSWServerConnection::PostMessageToServiceWorkerGlobalScope(destinationServiceWorkerIdentifier, IPC::DataReference { scriptValue->data() }, downcast<Document>(source).identifier(), source.origin())); 74 79 } 75 80 … … 93 98 } 94 99 100 void WebSWClientConnection::postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin) 101 { 102 SWClientConnection::postMessageToServiceWorkerClient(destinationScriptExecutionContextIdentifier, SerializedScriptValue::adopt(message.vector()), sourceServiceWorkerIdentifier, sourceOrigin); 103 } 104 95 105 } // namespace WebKit 96 106 -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
r223922 r224113 57 57 void scheduleJobInServer(const WebCore::ServiceWorkerJobData&) final; 58 58 void finishFetchingScriptInServer(const WebCore::ServiceWorkerFetchResult&) final; 59 void postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, Ref<WebCore::SerializedScriptValue>&&, const String& sourceOrigin) final;59 void postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, Ref<WebCore::SerializedScriptValue>&&, WebCore::ScriptExecutionContext& source) final; 60 60 61 61 void disconnectedFromWebProcess(); … … 64 64 bool hasServiceWorkerRegisteredForOrigin(const WebCore::SecurityOrigin&) const final; 65 65 Ref<ServiceWorkerClientFetch> startFetch(WebServiceWorkerProvider&, Ref<WebCore::ResourceLoader>&&, uint64_t identifier, ServiceWorkerClientFetch::Callback&&); 66 67 void postMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, const IPC::DataReference& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin); 66 68 67 69 private: -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in
r223964 r224113 31 31 32 32 SetSWOriginTableSharedMemory(WebKit::SharedMemory::Handle handle) 33 PostMessageToServiceWorkerClient(uint64_t destinationScriptExecutionContextIdentifier, IPC::DataReference message, uint64_t sourceServiceWorkerIdentifier, String sourceOrigin) 33 34 } 34 35 -
trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
r224041 r224113 131 131 } 132 132 133 void WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin)133 void WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, const IPC::DataReference& message, const ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin) 134 134 { 135 SWContextManager::singleton().postMessageToServiceWorkerGlobalScope(serviceWorkerIdentifier, SerializedScriptValue::adopt(message.vector()), sourceOrigin); 135 SWContextManager::singleton().postMessageToServiceWorkerGlobalScope(destinationServiceWorkerIdentifier, SerializedScriptValue::adopt(message.vector()), sourceIdentifier, sourceOrigin); 136 } 137 138 void WebSWContextManagerConnection::postMessageToServiceWorkerClient(const ServiceWorkerClientIdentifier& destinationIdentifier, Ref<SerializedScriptValue>&& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin) 139 { 140 m_connectionToStorageProcess->send(Messages::StorageProcess::PostMessageToServiceWorkerClient(destinationIdentifier, IPC::DataReference { message->data() }, sourceServiceWorkerIdentifier, sourceOrigin), 0); 136 141 } 137 142 -
trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h
r224041 r224113 42 42 struct WebPreferencesStore; 43 43 44 class WebSWContextManagerConnection : public WebCore::SWContextManager::Connection, public IPC::MessageReceiver {44 class WebSWContextManagerConnection final : public WebCore::SWContextManager::Connection, public IPC::MessageReceiver { 45 45 public: 46 46 WebSWContextManagerConnection(Ref<IPC::Connection>&&, uint64_t pageID, const WebPreferencesStore&); … … 48 48 void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final; 49 49 50 void postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin);51 52 50 private: 53 51 void updatePreferences(const WebPreferencesStore&); 54 52 53 // WebCore::SWContextManager::Connection. 54 void postMessageToServiceWorkerClient(const WebCore::ServiceWorkerClientIdentifier& destinationIdentifier, Ref<WebCore::SerializedScriptValue>&& message, uint64_t sourceServiceWorkerIdentifier, const String& sourceOrigin) final; 55 56 // IPC messages. 55 57 void startServiceWorker(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&); 56 58 void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest&&, WebCore::FetchOptions&&); 59 void postMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, const IPC::DataReference& message, const WebCore::ServiceWorkerClientIdentifier& sourceIdentifier, const String& sourceOrigin); 57 60 58 61 Ref<IPC::Connection> m_connectionToStorageProcess; -
trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in
r224041 r224113 26 26 StartServiceWorker(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerContextData contextData) 27 27 StartFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options) 28 PostMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, IPC::DataReference message, String sourceOrigin)28 PostMessageToServiceWorkerGlobalScope(uint64_t destinationServiceWorkerIdentifier, IPC::DataReference message, struct WebCore::ServiceWorkerClientIdentifier sourceIdentifier, String sourceOrigin) 29 29 } 30 30
Note: See TracChangeset
for help on using the changeset viewer.