void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent( int eventID, const WebString& message, const WebSecurityOrigin& sourceOrigin, const WebMessagePortChannelArray& webChannels, const WebServiceWorkerClientInfo& client) { WebSerializedScriptValue value = WebSerializedScriptValue::fromString(message); MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScope, webChannels); String origin; if (!sourceOrigin.isUnique()) origin = sourceOrigin.toString(); ServiceWorkerClient* source = nullptr; if (client.clientType == WebServiceWorkerClientTypeWindow) source = ServiceWorkerWindowClient::create(client); else source = ServiceWorkerClient::create(client); WaitUntilObserver* observer = WaitUntilObserver::create( workerGlobalScope(), WaitUntilObserver::Message, eventID); Event* event = ExtendableMessageEvent::create(value, origin, ports, source, observer); workerGlobalScope()->dispatchExtendableEvent(event, observer); }
void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent( int eventID, const WebString& message, const WebSecurityOrigin& sourceOrigin, const WebMessagePortChannelArray& webChannels, std::unique_ptr<WebServiceWorker::Handle> handle) { WebSerializedScriptValue value = WebSerializedScriptValue::fromString(message); MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScope, webChannels); String origin; if (!sourceOrigin.isUnique()) origin = sourceOrigin.toString(); ServiceWorker* source = ServiceWorker::from(m_workerGlobalScope->getExecutionContext(), WTF::wrapUnique(handle.release())); WaitUntilObserver* observer = WaitUntilObserver::create( workerGlobalScope(), WaitUntilObserver::Message, eventID); Event* event = ExtendableMessageEvent::create(value, origin, ports, source, observer); workerGlobalScope()->dispatchExtendableEvent(event, observer); }