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

Unified Diff: Source/core/dom/MessagePort.cpp

Issue 185643009: Implement ServiceWorker::postMessage() [Blink] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Pass raw pointer -> PassOwnPtr 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
« no previous file with comments | « Source/core/dom/MessagePort.h ('k') | Source/modules/serviceworkers/ServiceWorker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/MessagePort.cpp
diff --git a/Source/core/dom/MessagePort.cpp b/Source/core/dom/MessagePort.cpp
index b5e171446d784b353627a8ccaf637dd3deeab2eb..99aab7c6fdafd35bf9d9604958060477727b281f 100644
--- a/Source/core/dom/MessagePort.cpp
+++ b/Source/core/dom/MessagePort.cpp
@@ -87,13 +87,33 @@ void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const M
}
blink::WebString messageString = message->toWireString();
- blink::WebMessagePortChannelArray* webChannels = 0;
+ OwnPtr<blink::WebMessagePortChannelArray> webChannels = toWebMessagePortChannelArray(channels.release());
+ m_entangledChannel->postMessage(messageString, webChannels.leakPtr());
+}
+
+// static
+PassOwnPtr<blink::WebMessagePortChannelArray> MessagePort::toWebMessagePortChannelArray(PassOwnPtr<MessagePortChannelArray> channels)
+{
+ OwnPtr<blink::WebMessagePortChannelArray> webChannels;
if (channels && channels->size()) {
- webChannels = new blink::WebMessagePortChannelArray(channels->size());
+ webChannels = adoptPtr(new blink::WebMessagePortChannelArray(channels->size()));
for (size_t i = 0; i < channels->size(); ++i)
(*webChannels)[i] = (*channels)[i].leakPtr();
}
- m_entangledChannel->postMessage(messageString, webChannels);
+ return webChannels.release();
+}
+
+// static
+PassOwnPtr<MessagePortArray> MessagePort::toMessagePortArray(ExecutionContext* context, const blink::WebMessagePortChannelArray& webChannels)
+{
+ OwnPtr<MessagePortArray> ports;
+ if (!webChannels.isEmpty()) {
+ OwnPtr<MessagePortChannelArray> channels = adoptPtr(new MessagePortChannelArray(webChannels.size()));
+ for (size_t i = 0; i < webChannels.size(); ++i)
+ (*channels)[i] = adoptPtr(webChannels[i]);
+ ports = MessagePort::entanglePorts(*context, channels.release());
+ }
+ return ports.release();
}
PassOwnPtr<blink::WebMessagePortChannel> MessagePort::disentangle()
« no previous file with comments | « Source/core/dom/MessagePort.h ('k') | Source/modules/serviceworkers/ServiceWorker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698