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

Unified Diff: Source/modules/serviceworkers/ServiceWorker.cpp

Issue 185643009: Implement ServiceWorker::postMessage() [Blink] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Factor out leaky loops Created 6 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: Source/modules/serviceworkers/ServiceWorker.cpp
diff --git a/Source/modules/serviceworkers/ServiceWorker.cpp b/Source/modules/serviceworkers/ServiceWorker.cpp
index 0bbd5048335f6378f29b09f09f09a8b053a96b5d..51f062d177bb80982f52cfd4a699d5413901e62d 100644
--- a/Source/modules/serviceworkers/ServiceWorker.cpp
+++ b/Source/modules/serviceworkers/ServiceWorker.cpp
@@ -31,6 +31,10 @@
#include "config.h"
#include "ServiceWorker.h"
+#include "bindings/v8/ExceptionState.h"
+#include "core/dom/MessagePort.h"
+#include "public/platform/WebMessagePortChannel.h"
+#include "public/platform/WebString.h"
namespace WebCore {
@@ -39,4 +43,16 @@ ServiceWorker::ServiceWorker(PassOwnPtr<blink::WebServiceWorker> worker)
{
}
+void ServiceWorker::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionState& exceptionState)
+{
+ // Disentangle the port in preparation for sending it to the remote context.
+ OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, exceptionState);
+ if (exceptionState.hadException())
+ return;
+
+ blink::WebString messageString = message->toWireString();
+ OwnPtr<blink::WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePortChannelArray(channels.get());
+ m_outerWorker->postMessage(messageString, webChannels.leakPtr());
+}
+
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698