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

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: remove local test remnant 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
« no previous file with comments | « Source/modules/serviceworkers/Client.h ('k') | Source/modules/serviceworkers/Client.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/serviceworkers/Client.cpp
diff --git a/Source/modules/serviceworkers/Client.cpp b/Source/modules/serviceworkers/Client.cpp
index 77890687d12702f277cc362f647c92579bbcdb0d..1ddf95d3fd1dde0036d52cafb1f0755641f3bcab 100644
--- a/Source/modules/serviceworkers/Client.cpp
+++ b/Source/modules/serviceworkers/Client.cpp
@@ -5,6 +5,10 @@
#include "config.h"
#include "modules/serviceworkers/Client.h"
+#include "bindings/v8/ExceptionState.h"
+#include "bindings/v8/SerializedScriptValue.h"
+#include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
+#include "public/platform/WebString.h"
#include "wtf/RefPtr.h"
namespace WebCore {
@@ -24,4 +28,16 @@ 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;
+
+ blink::WebString messageString = message->toWireString();
+ OwnPtr<blink::WebMessagePortChannelArray> webChannels = MessagePort::toWebMessagePortChannelArray(channels.release());
+ ServiceWorkerGlobalScopeClient::from(context)->postMessageToClient(m_id, messageString, webChannels.release());
+}
+
} // namespace WebCore
« no previous file with comments | « Source/modules/serviceworkers/Client.h ('k') | Source/modules/serviceworkers/Client.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698