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

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: clean up tests Created 4 years, 9 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 283cccab835df5a8292ece4833a2051db57adcba..08eff3f8310d504091f53fec400eed03c4032afd 100644
--- a/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
+++ b/third_party/WebKit/Source/web/ServiceWorkerGlobalScopeProxy.cpp
@@ -56,7 +56,9 @@
#include "modules/serviceworkers/ExtendableMessageEvent.h"
#include "modules/serviceworkers/FetchEvent.h"
#include "modules/serviceworkers/InstallEvent.h"
+#include "modules/serviceworkers/ServiceWorkerClient.h"
#include "modules/serviceworkers/ServiceWorkerGlobalScope.h"
+#include "modules/serviceworkers/ServiceWorkerWindowClient.h"
#include "modules/serviceworkers/WaitUntilObserver.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "public/platform/WebCrossOriginServiceWorkerClient.h"
@@ -102,18 +104,39 @@ 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 WebSecurityOrigin& sourceOrigin, 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)
+ 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);
+
+ RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(value, origin, ports, source, observer));
+ workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
+}
+void ServiceWorkerGlobalScopeProxy::dispatchExtendableMessageEvent(int eventID, const WebString& message, const WebSecurityOrigin& sourceOrigin, const WebMessagePortChannelArray& webChannels, WebPassOwnPtr<WebServiceWorker::Handle> handle)
+{
+ ASSERT(RuntimeEnabledFeatures::serviceWorkerExtendableMessageEventEnabled());
+
+ 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(), handle.release());
WaitUntilObserver* observer = WaitUntilObserver::create(workerGlobalScope(), WaitUntilObserver::Message, eventID);
- RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(value, String(), ports, observer));
+ RefPtrWillBeRawPtr<Event> event(ExtendableMessageEvent::create(value, origin, ports, source, observer));
workerGlobalScope()->dispatchExtendableEvent(event.release(), observer);
}

Powered by Google App Engine
This is Rietveld 408576698