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

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

Issue 264233003: Add blink-side binding code and tests for ServiceWorker -> Document postMessage (3/3) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: added message port tests Created 6 years, 7 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/Client.cpp
diff --git a/Source/modules/serviceworkers/Client.cpp b/Source/modules/serviceworkers/Client.cpp
index 77890687d12702f277cc362f647c92579bbcdb0d..854fdbb5123e1ee2f6509dee3392b4d82e8a986e 100644
--- a/Source/modules/serviceworkers/Client.cpp
+++ b/Source/modules/serviceworkers/Client.cpp
@@ -5,6 +5,8 @@
#include "config.h"
#include "modules/serviceworkers/Client.h"
+#include "bindings/v8/ExceptionState.h"
+#include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
#include "wtf/RefPtr.h"
namespace WebCore {
@@ -24,4 +26,14 @@ Client::~Client()
{
}
+void Client::postMessage(ExecutionContext* context, 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;
+
+ ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_id, message, channels.release());
+}
+
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698