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

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

Issue 185643009: Implement ServiceWorker::postMessage() [Blink] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add test to verify IndexedDB in ServiceWorker, via postMessage 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..93f57ed9ea6b64ce2aa977a2df5fcbedc1c10ab1 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,23 @@ 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;
+
+ // FIXME: Any filtering of MessagePorts or other Transferrables?
michaeln 2014/03/11 23:29:20 good question?
+
+ blink::WebString messageString = message->toWireString();
+ blink::WebMessagePortChannelArray* webChannels = 0;
+ if (channels && channels->size()) {
+ webChannels = new blink::WebMessagePortChannelArray(channels->size());
+ for (size_t i = 0; i < channels->size(); ++i)
+ (*webChannels)[i] = (*channels)[i].leakPtr();
+ }
+ m_outerWorker->postMessage(messageString, webChannels);
michaeln 2014/03/11 23:29:20 I'll point out a dead body here and see if we care
+}
+
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698