Chromium Code Reviews| 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/12 23:51:52
link to crbug/351753 too
jsbell
2014/03/13 00:06:22
Actually, I'll delete this FIXME. When I was first
|
| + |
| + 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); |
| +} |
| + |
| } // namespace WebCore |