Index: third_party/WebKit/Source/core/dom/MessagePort.cpp |
diff --git a/third_party/WebKit/Source/core/dom/MessagePort.cpp b/third_party/WebKit/Source/core/dom/MessagePort.cpp |
index 17fc8bb34158352ab78408b5fdfc3ca45dacac78..59fce934a79d9c58fa21f281327cfb4db6de5c66 100644 |
--- a/third_party/WebKit/Source/core/dom/MessagePort.cpp |
+++ b/third_party/WebKit/Source/core/dom/MessagePort.cpp |
@@ -39,7 +39,9 @@ |
#include "core/workers/WorkerGlobalScope.h" |
#include "public/platform/WebString.h" |
#include "wtf/Functional.h" |
+#include "wtf/PtrUtil.h" |
#include "wtf/text/AtomicString.h" |
+#include <memory> |
namespace blink { |
@@ -79,7 +81,7 @@ void MessagePort::postMessage(ExecutionContext* context, PassRefPtr<SerializedSc |
return; |
} |
} |
- OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(context, ports, exceptionState); |
+ std::unique_ptr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(context, ports, exceptionState); |
if (exceptionState.hadException()) |
return; |
@@ -87,16 +89,16 @@ void MessagePort::postMessage(ExecutionContext* context, PassRefPtr<SerializedSc |
getExecutionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSource, WarningMessageLevel, "MessagePort cannot send an ArrayBuffer as a transferable object yet. See http://crbug.com/334408")); |
WebString messageString = message->toWireString(); |
- OwnPtr<WebMessagePortChannelArray> webChannels = toWebMessagePortChannelArray(std::move(channels)); |
- m_entangledChannel->postMessage(messageString, webChannels.leakPtr()); |
+ std::unique_ptr<WebMessagePortChannelArray> webChannels = toWebMessagePortChannelArray(std::move(channels)); |
+ m_entangledChannel->postMessage(messageString, webChannels.release()); |
} |
// static |
-PassOwnPtr<WebMessagePortChannelArray> MessagePort::toWebMessagePortChannelArray(PassOwnPtr<MessagePortChannelArray> channels) |
+std::unique_ptr<WebMessagePortChannelArray> MessagePort::toWebMessagePortChannelArray(std::unique_ptr<MessagePortChannelArray> channels) |
{ |
- OwnPtr<WebMessagePortChannelArray> webChannels; |
+ std::unique_ptr<WebMessagePortChannelArray> webChannels; |
if (channels && channels->size()) { |
- webChannels = adoptPtr(new WebMessagePortChannelArray(channels->size())); |
+ webChannels = wrapUnique(new WebMessagePortChannelArray(channels->size())); |
for (size_t i = 0; i < channels->size(); ++i) |
(*webChannels)[i] = (*channels)[i].release(); |
} |
@@ -106,7 +108,7 @@ PassOwnPtr<WebMessagePortChannelArray> MessagePort::toWebMessagePortChannelArray |
// static |
MessagePortArray* MessagePort::toMessagePortArray(ExecutionContext* context, const WebMessagePortChannelArray& webChannels) |
{ |
- OwnPtr<MessagePortChannelArray> channels = adoptPtr(new MessagePortChannelArray(webChannels.size())); |
+ std::unique_ptr<MessagePortChannelArray> channels = wrapUnique(new MessagePortChannelArray(webChannels.size())); |
for (size_t i = 0; i < webChannels.size(); ++i) |
(*channels)[i] = WebMessagePortChannelUniquePtr(webChannels[i]); |
return MessagePort::entanglePorts(*context, std::move(channels)); |
@@ -163,7 +165,7 @@ const AtomicString& MessagePort::interfaceName() const |
return EventTargetNames::MessagePort; |
} |
-static bool tryGetMessageFrom(WebMessagePortChannel& webChannel, RefPtr<SerializedScriptValue>& message, OwnPtr<MessagePortChannelArray>& channels) |
+static bool tryGetMessageFrom(WebMessagePortChannel& webChannel, RefPtr<SerializedScriptValue>& message, std::unique_ptr<MessagePortChannelArray>& channels) |
{ |
WebString messageString; |
WebMessagePortChannelArray webChannels; |
@@ -171,7 +173,7 @@ static bool tryGetMessageFrom(WebMessagePortChannel& webChannel, RefPtr<Serializ |
return false; |
if (webChannels.size()) { |
- channels = adoptPtr(new MessagePortChannelArray(webChannels.size())); |
+ channels = wrapUnique(new MessagePortChannelArray(webChannels.size())); |
for (size_t i = 0; i < webChannels.size(); ++i) |
(*channels)[i] = WebMessagePortChannelUniquePtr(webChannels[i]); |
} |
@@ -179,7 +181,7 @@ static bool tryGetMessageFrom(WebMessagePortChannel& webChannel, RefPtr<Serializ |
return true; |
} |
-bool MessagePort::tryGetMessage(RefPtr<SerializedScriptValue>& message, OwnPtr<MessagePortChannelArray>& channels) |
+bool MessagePort::tryGetMessage(RefPtr<SerializedScriptValue>& message, std::unique_ptr<MessagePortChannelArray>& channels) |
{ |
if (!m_entangledChannel) |
return false; |
@@ -198,7 +200,7 @@ void MessagePort::dispatchMessages() |
return; |
RefPtr<SerializedScriptValue> message; |
- OwnPtr<MessagePortChannelArray> channels; |
+ std::unique_ptr<MessagePortChannelArray> channels; |
while (tryGetMessage(message, channels)) { |
// close() in Worker onmessage handler should prevent next message from dispatching. |
if (getExecutionContext()->isWorkerGlobalScope() && toWorkerGlobalScope(getExecutionContext())->isClosing()) |
@@ -218,7 +220,7 @@ bool MessagePort::hasPendingActivity() const |
return m_started && isEntangled(); |
} |
-PassOwnPtr<MessagePortChannelArray> MessagePort::disentanglePorts(ExecutionContext* context, const MessagePortArray& ports, ExceptionState& exceptionState) |
+std::unique_ptr<MessagePortChannelArray> MessagePort::disentanglePorts(ExecutionContext* context, const MessagePortArray& ports, ExceptionState& exceptionState) |
{ |
if (!ports.size()) |
return nullptr; |
@@ -245,13 +247,13 @@ PassOwnPtr<MessagePortChannelArray> MessagePort::disentanglePorts(ExecutionConte |
UseCounter::count(context, UseCounter::MessagePortsTransferred); |
// Passed-in ports passed validity checks, so we can disentangle them. |
- OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelArray(ports.size())); |
+ std::unique_ptr<MessagePortChannelArray> portArray = wrapUnique(new MessagePortChannelArray(ports.size())); |
for (unsigned i = 0; i < ports.size(); ++i) |
(*portArray)[i] = ports[i]->disentangle(); |
return portArray; |
} |
-MessagePortArray* MessagePort::entanglePorts(ExecutionContext& context, PassOwnPtr<MessagePortChannelArray> channels) |
+MessagePortArray* MessagePort::entanglePorts(ExecutionContext& context, std::unique_ptr<MessagePortChannelArray> channels) |
{ |
// https://html.spec.whatwg.org/multipage/comms.html#message-ports |
// |ports| should be an empty array, not null even when there is no ports. |