Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(728)

Unified Diff: third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp

Issue 1701843002: ServiceWorker: Implement 'source' and 'origin' attributes of ExtendableMessageEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_focus_into_utils
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
diff --git a/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp b/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
index 3849642296520f9df72c9311426cbfbdce725001..ba90b75de830df1b89cf4f228735a9a263befe39 100644
--- a/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
+++ b/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
@@ -102,18 +102,31 @@ void ServiceWorkerGlobalScopeProxy::dispatchActivateEvent(int eventID)
workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
}
-void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebMessagePortChannelArray& webChannels)
+void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebMessagePortChannelArray& webChannels, const WebServiceWorkerClientInfo& client)
{
ASSERT(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled());
WebSerializedScriptValue value = WebSerializedScriptValue::fromString(message);
MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScope, webChannels);
- // TODO(nhiroki): Support |origin| and |source| attributes.
- // (http://crbug.com/543198)
+ ServiceWorkerClient* source = ServiceWorkerClient::create(client);
+ RefPtr<SecurityOrigin> origin = SecurityOrigin::create(KURL(KURL(), source->url()));
+ WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID);
+ RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(value, origin->toString(), ports, source, observer));
+ workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
+}
+
+void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebMessagePortChannelArray& webChannels, WebPassOwnPtr<WebServiceWorker::Handle> handle)
+{
+ ASSERT(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled());
+
+ WebSerializedScriptValue value = WebSerializedScriptValue::fromString(message);
+ MessagePortArray* ports = MessagePort::toMessagePortArray(m_workerGlobalScope, webChannels);
+ ServiceWorker* source = ServiceWorker::from(m_workerGlobalScope->executionContext(), handle.release());
+ RefPtr<SecurityOrigin> origin = SecurityOrigin::create(KURL(KURL(), source->scriptURL()));
WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID);
- RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(value, String(), ports, observer));
+ RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(value, origin->toString(), ports, source, observer));
workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
}

Powered by Google App Engine
This is Rietveld 408576698