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

Unified Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.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: address falken's comments 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/modules/serviceworkers/ServiceWorker.cpp
diff --git a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp
index 16d287892bc8d21b2b1d550f3473cf21fe7da29f..a3a1933757e7a17869aca70df7193e50d7abe781 100644
--- a/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp
+++ b/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.cpp
@@ -36,6 +36,7 @@
#include "core/events/Event.h"
#include "core/inspector/ConsoleMessage.h"
#include "modules/EventTargetModules.h"
+#include "modules/serviceworkers/ServiceWorkerContainerClient.h"
#include "public/platform/WebMessagePortChannel.h"
#include "public/platform/WebString.h"
#include "public/platform/modules/serviceworker/WebServiceWorkerState.h"
@@ -49,6 +50,12 @@ const AtomicString& ServiceWorker::interfaceName() const
void ServiceWorker::postMessage(ExecutionContext* context, PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionState& exceptionState)
{
+ ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::from(executionContext());
+ if (!client || !client->provider()) {
+ exceptionState.throwDOMException(InvalidStateError, "Failed to post a message: No associated provider is available.");
+ return;
+ }
+
// Disentangle the port in preparation for sending it to the remote context.
OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(context, ports, exceptionState);
if (exceptionState.hadException())
@@ -63,7 +70,7 @@ void ServiceWorker::postMessage(ExecutionContext* context, PassRefPtr<Serialized
WebString messageString = message->toWireString();
OwnPtr<WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePortChannelArray(channels.release());
- m_handle->serviceWorker()->postMessage(messageString, webChannels.leakPtr());
+ m_handle->serviceWorker()->postMessage(client->provider(), messageString, webChannels.leakPtr());
}
void ServiceWorker::internalsTerminate()

Powered by Google App Engine
This is Rietveld 408576698