Manage MessagePort, MessagePortChannel and friends through std::unique_ptr
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Feb 2014 08:18:11 +0000 (08:18 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Feb 2014 08:18:11 +0000 (08:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=128467

Reviewed by Andreas Kling.

Use std::unique_ptr instead of OwnPtr to manage MessagePort, MessagePortArray, MessagePortChannel
and MessagePortChannelArray objects.

* bindings/js/JSMessageEventCustom.cpp:
(WebCore::handleInitMessageEvent):
* dom/MessageEvent.cpp:
(WebCore::MessageEvent::MessageEvent):
(WebCore::MessageEvent::initMessageEvent):
* dom/MessageEvent.h:
(WebCore::MessageEvent::create):
* dom/MessagePort.cpp:
(WebCore::MessagePort::postMessage):
(WebCore::MessagePort::disentangle):
(WebCore::MessagePort::entangle):
(WebCore::MessagePort::dispatchMessages):
(WebCore::MessagePort::disentanglePorts):
(WebCore::MessagePort::entanglePorts):
* dom/MessagePort.h:
* dom/MessagePortChannel.h:
* dom/default/PlatformMessagePortChannel.cpp:
(WebCore::PlatformMessagePortChannel::EventData::EventData):
(WebCore::MessagePortChannel::createChannel):
(WebCore::MessagePortChannel::postMessageToRemote):
(WebCore::MessagePortChannel::tryGetMessageFromRemote):
* dom/default/PlatformMessagePortChannel.h:
(WebCore::PlatformMessagePortChannel::EventData::channels):
* page/DOMWindow.cpp:
(WebCore::PostMessageTimer::PostMessageTimer):
(WebCore::PostMessageTimer::event):
(WebCore::DOMWindow::postMessage):
* workers/DedicatedWorkerGlobalScope.cpp:
(WebCore::DedicatedWorkerGlobalScope::postMessage):
* workers/DefaultSharedWorkerRepository.cpp:
(WebCore::SharedWorkerConnectTask::create):
(WebCore::SharedWorkerConnectTask::SharedWorkerConnectTask):
(WebCore::SharedWorkerConnectTask::performTask):
(WebCore::SharedWorkerScriptLoader::SharedWorkerScriptLoader):
(WebCore::SharedWorkerScriptLoader::notifyFinished):
(WebCore::DefaultSharedWorkerRepository::workerScriptLoaded):
(WebCore::DefaultSharedWorkerRepository::connectToWorker):
* workers/DefaultSharedWorkerRepository.h:
* workers/SharedWorker.cpp:
(WebCore::SharedWorker::create):
* workers/SharedWorkerGlobalScope.cpp:
(WebCore::createConnectEvent):
* workers/SharedWorkerRepository.cpp:
(WebCore::SharedWorkerRepository::connect):
* workers/SharedWorkerRepository.h:
* workers/Worker.cpp:
(WebCore::Worker::postMessage):
* workers/WorkerGlobalScopeProxy.h:
* workers/WorkerMessagingProxy.cpp:
(WebCore::MessageWorkerGlobalScopeTask::create):
(WebCore::MessageWorkerGlobalScopeTask::MessageWorkerGlobalScopeTask):
(WebCore::MessageWorkerGlobalScopeTask::performTask):
(WebCore::MessageWorkerTask::create):
(WebCore::MessageWorkerTask::MessageWorkerTask):
(WebCore::MessageWorkerTask::performTask):
(WebCore::WorkerMessagingProxy::postMessageToWorkerObject):
(WebCore::WorkerMessagingProxy::postMessageToWorkerGlobalScope):
* workers/WorkerMessagingProxy.h:
* workers/WorkerObjectProxy.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@163744 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSMessageEventCustom.cpp
Source/WebCore/dom/MessageEvent.cpp
Source/WebCore/dom/MessageEvent.h
Source/WebCore/dom/MessagePort.cpp
Source/WebCore/dom/MessagePort.h
Source/WebCore/dom/MessagePortChannel.h
Source/WebCore/dom/default/PlatformMessagePortChannel.cpp
Source/WebCore/dom/default/PlatformMessagePortChannel.h
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp
Source/WebCore/workers/DefaultSharedWorkerRepository.cpp
Source/WebCore/workers/DefaultSharedWorkerRepository.h
Source/WebCore/workers/SharedWorker.cpp
Source/WebCore/workers/SharedWorkerGlobalScope.cpp
Source/WebCore/workers/SharedWorkerRepository.cpp
Source/WebCore/workers/SharedWorkerRepository.h
Source/WebCore/workers/Worker.cpp
Source/WebCore/workers/WorkerGlobalScopeProxy.h
Source/WebCore/workers/WorkerMessagingProxy.cpp
Source/WebCore/workers/WorkerMessagingProxy.h
Source/WebCore/workers/WorkerObjectProxy.h

index b84ca0d..948a1f7 100644 (file)
@@ -1,3 +1,73 @@
+2014-02-09  Zan Dobersek  <zdobersek@igalia.com>
+
+        Manage MessagePort, MessagePortChannel and friends through std::unique_ptr
+        https://bugs.webkit.org/show_bug.cgi?id=128467
+
+        Reviewed by Andreas Kling.
+
+        Use std::unique_ptr instead of OwnPtr to manage MessagePort, MessagePortArray, MessagePortChannel
+        and MessagePortChannelArray objects.
+
+        * bindings/js/JSMessageEventCustom.cpp:
+        (WebCore::handleInitMessageEvent):
+        * dom/MessageEvent.cpp:
+        (WebCore::MessageEvent::MessageEvent):
+        (WebCore::MessageEvent::initMessageEvent):
+        * dom/MessageEvent.h:
+        (WebCore::MessageEvent::create):
+        * dom/MessagePort.cpp:
+        (WebCore::MessagePort::postMessage):
+        (WebCore::MessagePort::disentangle):
+        (WebCore::MessagePort::entangle):
+        (WebCore::MessagePort::dispatchMessages):
+        (WebCore::MessagePort::disentanglePorts):
+        (WebCore::MessagePort::entanglePorts):
+        * dom/MessagePort.h:
+        * dom/MessagePortChannel.h:
+        * dom/default/PlatformMessagePortChannel.cpp:
+        (WebCore::PlatformMessagePortChannel::EventData::EventData):
+        (WebCore::MessagePortChannel::createChannel):
+        (WebCore::MessagePortChannel::postMessageToRemote):
+        (WebCore::MessagePortChannel::tryGetMessageFromRemote):
+        * dom/default/PlatformMessagePortChannel.h:
+        (WebCore::PlatformMessagePortChannel::EventData::channels):
+        * page/DOMWindow.cpp:
+        (WebCore::PostMessageTimer::PostMessageTimer):
+        (WebCore::PostMessageTimer::event):
+        (WebCore::DOMWindow::postMessage):
+        * workers/DedicatedWorkerGlobalScope.cpp:
+        (WebCore::DedicatedWorkerGlobalScope::postMessage):
+        * workers/DefaultSharedWorkerRepository.cpp:
+        (WebCore::SharedWorkerConnectTask::create):
+        (WebCore::SharedWorkerConnectTask::SharedWorkerConnectTask):
+        (WebCore::SharedWorkerConnectTask::performTask):
+        (WebCore::SharedWorkerScriptLoader::SharedWorkerScriptLoader):
+        (WebCore::SharedWorkerScriptLoader::notifyFinished):
+        (WebCore::DefaultSharedWorkerRepository::workerScriptLoaded):
+        (WebCore::DefaultSharedWorkerRepository::connectToWorker):
+        * workers/DefaultSharedWorkerRepository.h:
+        * workers/SharedWorker.cpp:
+        (WebCore::SharedWorker::create):
+        * workers/SharedWorkerGlobalScope.cpp:
+        (WebCore::createConnectEvent):
+        * workers/SharedWorkerRepository.cpp:
+        (WebCore::SharedWorkerRepository::connect):
+        * workers/SharedWorkerRepository.h:
+        * workers/Worker.cpp:
+        (WebCore::Worker::postMessage):
+        * workers/WorkerGlobalScopeProxy.h:
+        * workers/WorkerMessagingProxy.cpp:
+        (WebCore::MessageWorkerGlobalScopeTask::create):
+        (WebCore::MessageWorkerGlobalScopeTask::MessageWorkerGlobalScopeTask):
+        (WebCore::MessageWorkerGlobalScopeTask::performTask):
+        (WebCore::MessageWorkerTask::create):
+        (WebCore::MessageWorkerTask::MessageWorkerTask):
+        (WebCore::MessageWorkerTask::performTask):
+        (WebCore::WorkerMessagingProxy::postMessageToWorkerObject):
+        (WebCore::WorkerMessagingProxy::postMessageToWorkerGlobalScope):
+        * workers/WorkerMessagingProxy.h:
+        * workers/WorkerObjectProxy.h:
+
 2014-02-08  Ryosuke Niwa  <rniwa@webkit.org>
 
         Cleanup the interface of FrameSelection
index c84ca0d..5615a08 100644 (file)
@@ -96,10 +96,10 @@ static JSC::JSValue handleInitMessageEvent(JSMessageEvent* jsEvent, JSC::ExecSta
     const String originArg = exec->argument(4).toString(exec)->value(exec);
     const String lastEventIdArg = exec->argument(5).toString(exec)->value(exec);
     DOMWindow* sourceArg = toDOMWindow(exec->argument(6));
-    OwnPtr<MessagePortArray> messagePorts;
+    std::unique_ptr<MessagePortArray> messagePorts;
     OwnPtr<ArrayBufferArray> arrayBuffers;
     if (!exec->argument(7).isUndefinedOrNull()) {
-        messagePorts = adoptPtr(new MessagePortArray);
+        messagePorts = std::make_unique<MessagePortArray>();
         arrayBuffers = adoptPtr(new ArrayBufferArray);
         fillMessagePortArray(exec, exec->argument(7), *messagePorts, *arrayBuffers);
         if (exec->hadException())
@@ -110,7 +110,7 @@ static JSC::JSValue handleInitMessageEvent(JSMessageEvent* jsEvent, JSC::ExecSta
         return jsUndefined();
 
     MessageEvent& event = jsEvent->impl();
-    event.initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, sourceArg, messagePorts.release());
+    event.initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, sourceArg, std::move(messagePorts));
     jsEvent->m_data.set(exec->vm(), jsEvent, dataArg.jsValue());
     return jsUndefined();
 }
index 4388c9f..5816d0a 100644 (file)
@@ -51,30 +51,30 @@ MessageEvent::MessageEvent(const AtomicString& type, const MessageEventInit& ini
     , m_origin(initializer.origin)
     , m_lastEventId(initializer.lastEventId)
     , m_source(isValidSource(initializer.source.get()) ? initializer.source : 0)
-    , m_ports(adoptPtr(new MessagePortArray(initializer.ports)))
+    , m_ports(std::make_unique<MessagePortArray>(initializer.ports))
 {
 }
 
-MessageEvent::MessageEvent(const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, PassRefPtr<EventTarget> source, PassOwnPtr<MessagePortArray> ports)
+MessageEvent::MessageEvent(const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, PassRefPtr<EventTarget> source, std::unique_ptr<MessagePortArray> ports)
     : Event(eventNames().messageEvent, false, false)
     , m_dataType(DataTypeScriptValue)
     , m_dataAsScriptValue(data)
     , m_origin(origin)
     , m_lastEventId(lastEventId)
     , m_source(source)
-    , m_ports(ports)
+    , m_ports(std::move(ports))
 {
     ASSERT(isValidSource(m_source.get()));
 }
 
-MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<EventTarget> source, PassOwnPtr<MessagePortArray> ports)
+MessageEvent::MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<EventTarget> source, std::unique_ptr<MessagePortArray> ports)
     : Event(eventNames().messageEvent, false, false)
     , m_dataType(DataTypeSerializedScriptValue)
     , m_dataAsSerializedScriptValue(data)
     , m_origin(origin)
     , m_lastEventId(lastEventId)
     , m_source(source)
-    , m_ports(ports)
+    , m_ports(std::move(ports))
 {
     ASSERT(isValidSource(m_source.get()));
 }
@@ -107,7 +107,7 @@ MessageEvent::~MessageEvent()
 {
 }
 
-void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray> ports)
+void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, DOMWindow* source, std::unique_ptr<MessagePortArray> ports)
 {
     if (dispatched())
         return;
@@ -119,10 +119,10 @@ void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bo
     m_origin = origin;
     m_lastEventId = lastEventId;
     m_source = source;
-    m_ports = ports;
+    m_ports = std::move(ports);
 }
 
-void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray> ports)
+void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, std::unique_ptr<MessagePortArray> ports)
 {
     if (dispatched())
         return;
@@ -134,7 +134,7 @@ void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bo
     m_origin = origin;
     m_lastEventId = lastEventId;
     m_source = source;
-    m_ports = ports;
+    m_ports = std::move(ports);
 }
 
 // FIXME: Remove this when we have custom ObjC binding support.
@@ -155,12 +155,12 @@ MessagePort* MessageEvent::messagePort()
 
 void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, MessagePort* port)
 {
-    OwnPtr<MessagePortArray> ports;
+    std::unique_ptr<MessagePortArray> ports;
     if (port) {
-        ports = adoptPtr(new MessagePortArray);
+        ports = std::make_unique<MessagePortArray>();
         ports->append(port);
     }
-    initMessageEvent(type, canBubble, cancelable, data, origin, lastEventId, source, ports.release());
+    initMessageEvent(type, canBubble, cancelable, data, origin, lastEventId, source, std::move(ports));
 }
 
 EventInterface MessageEvent::eventInterface() const
index cfb2fa4..5be9020 100644 (file)
@@ -34,6 +34,7 @@
 #include "MessagePort.h"
 #include "SerializedScriptValue.h"
 #include <bindings/ScriptValue.h>
+#include <memory>
 #include <runtime/ArrayBuffer.h>
 
 namespace WebCore {
@@ -56,13 +57,13 @@ public:
     {
         return adoptRef(new MessageEvent);
     }
-    static PassRefPtr<MessageEvent> create(PassOwnPtr<MessagePortArray> ports, const Deprecated::ScriptValue& data = Deprecated::ScriptValue(), const String& origin = String(), const String& lastEventId = String(), PassRefPtr<EventTarget> source = 0)
+    static PassRefPtr<MessageEvent> create(std::unique_ptr<MessagePortArray> ports, const Deprecated::ScriptValue& data = Deprecated::ScriptValue(), const String& origin = String(), const String& lastEventId = String(), PassRefPtr<EventTarget> source = 0)
     {
-        return adoptRef(new MessageEvent(data, origin, lastEventId, source, ports));
+        return adoptRef(new MessageEvent(data, origin, lastEventId, source, std::move(ports)));
     }
-    static PassRefPtr<MessageEvent> create(PassOwnPtr<MessagePortArray> ports, PassRefPtr<SerializedScriptValue> data, const String& origin = String(), const String& lastEventId = String(), PassRefPtr<EventTarget> source = 0)
+    static PassRefPtr<MessageEvent> create(std::unique_ptr<MessagePortArray> ports, PassRefPtr<SerializedScriptValue> data, const String& origin = String(), const String& lastEventId = String(), PassRefPtr<EventTarget> source = 0)
     {
-        return adoptRef(new MessageEvent(data, origin, lastEventId, source, ports));
+        return adoptRef(new MessageEvent(data, origin, lastEventId, source, std::move(ports)));
     }
     static PassRefPtr<MessageEvent> create(const String& data, const String& origin = String())
     {
@@ -82,8 +83,8 @@ public:
     }
     virtual ~MessageEvent();
 
-    void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray>);
-    void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, PassOwnPtr<MessagePortArray>);
+    void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, DOMWindow* source, std::unique_ptr<MessagePortArray>);
+    void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, std::unique_ptr<MessagePortArray>);
 
     const String& origin() const { return m_origin; }
     const String& lastEventId() const { return m_lastEventId; }
@@ -116,8 +117,8 @@ public:
 private:
     MessageEvent();
     MessageEvent(const AtomicString&, const MessageEventInit&);
-    MessageEvent(const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, PassRefPtr<EventTarget> source, PassOwnPtr<MessagePortArray>);
-    MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<EventTarget> source, PassOwnPtr<MessagePortArray>);
+    MessageEvent(const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, PassRefPtr<EventTarget> source, std::unique_ptr<MessagePortArray>);
+    MessageEvent(PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, PassRefPtr<EventTarget> source, std::unique_ptr<MessagePortArray>);
 
     explicit MessageEvent(const String& data, const String& origin);
     explicit MessageEvent(PassRefPtr<Blob> data, const String& origin);
@@ -132,7 +133,7 @@ private:
     String m_origin;
     String m_lastEventId;
     RefPtr<EventTarget> m_source;
-    OwnPtr<MessagePortArray> m_ports;
+    std::unique_ptr<MessagePortArray> m_ports;
 };
 
 } // namespace WebCore
index 6416723..8e5b29d 100644 (file)
@@ -66,7 +66,7 @@ void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const M
         return;
     ASSERT(m_scriptExecutionContext);
 
-    OwnPtr<MessagePortChannelArray> channels;
+    std::unique_ptr<MessagePortChannelArray> channels;
     // Make sure we aren't connected to any of the passed-in ports.
     if (ports) {
         for (unsigned int i = 0; i < ports->size(); ++i) {
@@ -80,10 +80,10 @@ void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const M
         if (ec)
             return;
     }
-    m_entangledChannel->postMessageToRemote(message, channels.release());
+    m_entangledChannel->postMessageToRemote(message, std::move(channels));
 }
 
-PassOwnPtr<MessagePortChannel> MessagePort::disentangle()
+std::unique_ptr<MessagePortChannel> MessagePort::disentangle()
 {
     ASSERT(m_entangledChannel);
 
@@ -94,7 +94,7 @@ PassOwnPtr<MessagePortChannel> MessagePort::disentangle()
     m_scriptExecutionContext->destroyedMessagePort(this);
     m_scriptExecutionContext = 0;
 
-    return m_entangledChannel.release();
+    return std::move(m_entangledChannel);
 }
 
 // Invoked to notify us that there are messages available for this port.
@@ -126,7 +126,7 @@ void MessagePort::close()
     m_closed = true;
 }
 
-void MessagePort::entangle(PassOwnPtr<MessagePortChannel> remote)
+void MessagePort::entangle(std::unique_ptr<MessagePortChannel> remote)
 {
     // Only invoked to set our initial entanglement.
     ASSERT(!m_entangledChannel);
@@ -134,7 +134,7 @@ void MessagePort::entangle(PassOwnPtr<MessagePortChannel> remote)
 
     // Don't entangle the ports if the channel is closed.
     if (remote->entangleIfOpen(this))
-        m_entangledChannel = remote;
+        m_entangledChannel = std::move(remote);
 }
 
 void MessagePort::contextDestroyed()
@@ -153,15 +153,15 @@ void MessagePort::dispatchMessages()
     ASSERT(started());
 
     RefPtr<SerializedScriptValue> message;
-    OwnPtr<MessagePortChannelArray> channels;
+    std::unique_ptr<MessagePortChannelArray> channels;
     while (m_entangledChannel && m_entangledChannel->tryGetMessageFromRemote(message, channels)) {
 
         // close() in Worker onmessage handler should prevent next message from dispatching.
         if (m_scriptExecutionContext->isWorkerGlobalScope() && static_cast<WorkerGlobalScope*>(m_scriptExecutionContext)->isClosing())
             return;
 
-        OwnPtr<MessagePortArray> ports = MessagePort::entanglePorts(*m_scriptExecutionContext, channels.release());
-        RefPtr<Event> evt = MessageEvent::create(ports.release(), message.release());
+        std::unique_ptr<MessagePortArray> ports = MessagePort::entanglePorts(*m_scriptExecutionContext, std::move(channels));
+        RefPtr<Event> evt = MessageEvent::create(std::move(ports), message.release());
 
         dispatchEvent(evt.release(), ASSERT_NO_EXCEPTION);
     }
@@ -183,7 +183,7 @@ MessagePort* MessagePort::locallyEntangledPort()
     return m_entangledChannel ? m_entangledChannel->locallyEntangledPort(m_scriptExecutionContext) : 0;
 }
 
-PassOwnPtr<MessagePortChannelArray> MessagePort::disentanglePorts(const MessagePortArray* ports, ExceptionCode& ec)
+std::unique_ptr<MessagePortChannelArray> MessagePort::disentanglePorts(const MessagePortArray* ports, ExceptionCode& ec)
 {
     if (!ports || !ports->size())
         return nullptr;
@@ -202,26 +202,26 @@ PassOwnPtr<MessagePortChannelArray> MessagePort::disentanglePorts(const MessageP
     }
 
     // Passed-in ports passed validity checks, so we can disentangle them.
-    OwnPtr<MessagePortChannelArray> portArray = adoptPtr(new MessagePortChannelArray(ports->size()));
+    auto portArray = std::make_unique<MessagePortChannelArray>(ports->size());
     for (unsigned int i = 0 ; i < ports->size() ; ++i) {
-        OwnPtr<MessagePortChannel> channel = (*ports)[i]->disentangle();
-        (*portArray)[i] = channel.release();
+        std::unique_ptr<MessagePortChannel> channel = (*ports)[i]->disentangle();
+        (*portArray)[i] = std::move(channel);
     }
-    return portArray.release();
+    return portArray;
 }
 
-PassOwnPtr<MessagePortArray> MessagePort::entanglePorts(ScriptExecutionContext& context, PassOwnPtr<MessagePortChannelArray> channels)
+std::unique_ptr<MessagePortArray> MessagePort::entanglePorts(ScriptExecutionContext& context, std::unique_ptr<MessagePortChannelArray> channels)
 {
     if (!channels || !channels->size())
         return nullptr;
 
-    OwnPtr<MessagePortArray> portArray = adoptPtr(new MessagePortArray(channels->size()));
+    auto portArray = std::make_unique<MessagePortArray>(channels->size());
     for (unsigned int i = 0; i < channels->size(); ++i) {
         RefPtr<MessagePort> port = MessagePort::create(context);
-        port->entangle((*channels)[i].release());
+        port->entangle(std::move((*channels)[i]));
         (*portArray)[i] = port.release();
     }
-    return portArray.release();
+    return portArray;
 }
 
 } // namespace WebCore
index 9e04374..0fd3e41 100644 (file)
@@ -30,9 +30,8 @@
 #include "EventListener.h"
 #include "EventTarget.h"
 #include "MessagePortChannel.h"
+#include <memory>
 #include <wtf/Forward.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/PassOwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
@@ -59,14 +58,14 @@ namespace WebCore {
         void start();
         void close();
 
-        void entangle(PassOwnPtr<MessagePortChannel>);
-        PassOwnPtr<MessagePortChannel> disentangle();
+        void entangle(std::unique_ptr<MessagePortChannel>);
+        std::unique_ptr<MessagePortChannel> disentangle();
 
         // Returns 0 if there is an exception, or if the passed-in array is 0/empty.
-        static PassOwnPtr<MessagePortChannelArray> disentanglePorts(const MessagePortArray*, ExceptionCode&);
+        static std::unique_ptr<MessagePortChannelArray> disentanglePorts(const MessagePortArray*, ExceptionCode&);
 
         // Returns 0 if the passed array is 0/empty.
-        static PassOwnPtr<MessagePortArray> entanglePorts(ScriptExecutionContext&, PassOwnPtr<MessagePortChannelArray>);
+        static std::unique_ptr<MessagePortArray> entanglePorts(ScriptExecutionContext&, std::unique_ptr<MessagePortChannelArray>);
 
         void messageAvailable();
         bool started() const { return m_started; }
@@ -108,7 +107,7 @@ namespace WebCore {
         virtual void refEventTarget() override { ref(); }
         virtual void derefEventTarget() override { deref(); }
 
-        OwnPtr<MessagePortChannel> m_entangledChannel;
+        std::unique_ptr<MessagePortChannel> m_entangledChannel;
 
         bool m_started;
         bool m_closed;
index 9e1b7cb..a711eff 100644 (file)
@@ -32,9 +32,8 @@
 #define MessagePortChannel_h
 
 #include "SerializedScriptValue.h"
-#include <wtf/OwnPtr.h>
+#include <memory>
 #include <wtf/Forward.h>
-#include <wtf/PassOwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
@@ -49,13 +48,14 @@ namespace WebCore {
     class SerializedScriptValue;
 
     // The overwhelmingly common case is sending a single port, so handle that efficiently with an inline buffer of size 1.
-    typedef Vector<OwnPtr<MessagePortChannel>, 1> MessagePortChannelArray;
+    typedef Vector<std::unique_ptr<MessagePortChannel>, 1> MessagePortChannelArray;
 
     // MessagePortChannel is a platform-independent interface to the remote side of a message channel.
     // It acts as a wrapper around the platform-dependent PlatformMessagePortChannel implementation which ensures that the platform-dependent close() method is invoked before destruction.
     class MessagePortChannel {
         WTF_MAKE_NONCOPYABLE(MessagePortChannel); WTF_MAKE_FAST_ALLOCATED;
     public:
+        explicit MessagePortChannel(PassRefPtr<PlatformMessagePortChannel>);
         static void createChannel(PassRefPtr<MessagePort>, PassRefPtr<MessagePort>);
 
         // Entangles the channel with a port (called when a port has been cloned, after the clone has been marshaled to its new owning thread and is ready to receive messages).
@@ -75,10 +75,10 @@ namespace WebCore {
         bool hasPendingActivity();
 
         // Sends a message and optional cloned port to the remote port.
-        void postMessageToRemote(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>);
+        void postMessageToRemote(PassRefPtr<SerializedScriptValue>, std::unique_ptr<MessagePortChannelArray>);
 
         // Extracts a message from the message queue for this port.
-        bool tryGetMessageFromRemote(RefPtr<SerializedScriptValue>&, OwnPtr<MessagePortChannelArray>&);
+        bool tryGetMessageFromRemote(RefPtr<SerializedScriptValue>&, std::unique_ptr<MessagePortChannelArray>&);
 
         // Returns the entangled port if run by the same thread (see MessagePort::locallyEntangledPort() for more details).
         MessagePort* locallyEntangledPort(const ScriptExecutionContext*);
@@ -86,7 +86,6 @@ namespace WebCore {
         ~MessagePortChannel();
 
     private:
-        explicit MessagePortChannel(PassRefPtr<PlatformMessagePortChannel>);
         RefPtr<PlatformMessagePortChannel> m_channel;
     };
 
index 902da18..342ef67 100644 (file)
 
 namespace WebCore {
 
-std::unique_ptr<PlatformMessagePortChannel::EventData> PlatformMessagePortChannel::EventData::create(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels)
-{
-    return std::unique_ptr<EventData>(new EventData(message, channels));
-}
-
-PlatformMessagePortChannel::EventData::EventData(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels)
+PlatformMessagePortChannel::EventData::EventData(PassRefPtr<SerializedScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels)
     : m_message(message)
-    , m_channels(channels)
+    , m_channels(std::move(channels))
 {
 }
 
@@ -53,14 +48,14 @@ void MessagePortChannel::createChannel(PassRefPtr<MessagePort> port1, PassRefPtr
     RefPtr<PlatformMessagePortChannel::MessagePortQueue> queue1 = PlatformMessagePortChannel::MessagePortQueue::create();
     RefPtr<PlatformMessagePortChannel::MessagePortQueue> queue2 = PlatformMessagePortChannel::MessagePortQueue::create();
 
-    OwnPtr<MessagePortChannel> channel1 = adoptPtr(new MessagePortChannel(PlatformMessagePortChannel::create(queue1, queue2)));
-    OwnPtr<MessagePortChannel> channel2 = adoptPtr(new MessagePortChannel(PlatformMessagePortChannel::create(queue2, queue1)));
+    auto channel1 = std::make_unique<MessagePortChannel>(PlatformMessagePortChannel::create(queue1, queue2));
+    auto channel2 = std::make_unique<MessagePortChannel>(PlatformMessagePortChannel::create(queue2, queue1));
 
     channel1->m_channel->m_entangledChannel = channel2->m_channel;
     channel2->m_channel->m_entangledChannel = channel1->m_channel;
 
-    port1->entangle(channel2.release());
-    port2->entangle(channel1.release());
+    port1->entangle(std::move(channel2));
+    port2->entangle(std::move(channel1));
 }
 
 MessagePortChannel::MessagePortChannel(PassRefPtr<PlatformMessagePortChannel> channel)
@@ -91,17 +86,17 @@ void MessagePortChannel::disentangle()
         remote->setRemotePort(0);
 }
 
-void MessagePortChannel::postMessageToRemote(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels)
+void MessagePortChannel::postMessageToRemote(PassRefPtr<SerializedScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels)
 {
     MutexLocker lock(m_channel->m_mutex);
     if (!m_channel->m_outgoingQueue)
         return;
-    bool wasEmpty = m_channel->m_outgoingQueue->appendAndCheckEmpty(PlatformMessagePortChannel::EventData::create(message, channels));
+    bool wasEmpty = m_channel->m_outgoingQueue->appendAndCheckEmpty(std::make_unique<PlatformMessagePortChannel::EventData>(message, std::move(channels)));
     if (wasEmpty && m_channel->m_remotePort)
         m_channel->m_remotePort->messageAvailable();
 }
 
-bool MessagePortChannel::tryGetMessageFromRemote(RefPtr<SerializedScriptValue>& message, OwnPtr<MessagePortChannelArray>& channels)
+bool MessagePortChannel::tryGetMessageFromRemote(RefPtr<SerializedScriptValue>& message, std::unique_ptr<MessagePortChannelArray>& channels)
 {
     MutexLocker lock(m_channel->m_mutex);
     auto result = m_channel->m_incomingQueue->tryGetMessage();
index 6eb89d4..50984f9 100644 (file)
@@ -49,15 +49,14 @@ namespace WebCore {
         class EventData {
             WTF_MAKE_NONCOPYABLE(EventData); WTF_MAKE_FAST_ALLOCATED;
         public:
-            static std::unique_ptr<EventData> create(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>);
+            EventData(PassRefPtr<SerializedScriptValue> message, std::unique_ptr<MessagePortChannelArray>);
 
             PassRefPtr<SerializedScriptValue> message() { return m_message; }
-            PassOwnPtr<MessagePortChannelArray> channels() { return m_channels.release(); }
+            std::unique_ptr<MessagePortChannelArray> channels() { return std::move(m_channels); }
 
         private:
-            EventData(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray>);
             RefPtr<SerializedScriptValue> m_message;
-            OwnPtr<MessagePortChannelArray> m_channels;
+            std::unique_ptr<MessagePortChannelArray> m_channels;
         };
 
         // Wrapper for MessageQueue that allows us to do thread safe sharing by two proxies.
index 3df2cc4..4fa4330 100644 (file)
@@ -131,12 +131,12 @@ namespace WebCore {
 
 class PostMessageTimer : public TimerBase {
 public:
-    PostMessageTimer(DOMWindow* window, PassRefPtr<SerializedScriptValue> message, const String& sourceOrigin, PassRefPtr<DOMWindow> source, PassOwnPtr<MessagePortChannelArray> channels, SecurityOrigin* targetOrigin, PassRefPtr<ScriptCallStack> stackTrace)
+    PostMessageTimer(DOMWindow* window, PassRefPtr<SerializedScriptValue> message, const String& sourceOrigin, PassRefPtr<DOMWindow> source, std::unique_ptr<MessagePortChannelArray> channels, SecurityOrigin* targetOrigin, PassRefPtr<ScriptCallStack> stackTrace)
         : m_window(window)
         , m_message(message)
         , m_origin(sourceOrigin)
         , m_source(source)
-        , m_channels(channels)
+        , m_channels(std::move(channels))
         , m_targetOrigin(targetOrigin)
         , m_stackTrace(stackTrace)
     {
@@ -144,8 +144,8 @@ public:
 
     PassRefPtr<MessageEvent> event(ScriptExecutionContext* context)
     {
-        OwnPtr<MessagePortArray> messagePorts = MessagePort::entanglePorts(*context, m_channels.release());
-        return MessageEvent::create(messagePorts.release(), m_message, m_origin, String(), m_source);
+        std::unique_ptr<MessagePortArray> messagePorts = MessagePort::entanglePorts(*context, std::move(m_channels));
+        return MessageEvent::create(std::move(messagePorts), m_message, m_origin, String(), m_source);
     }
     SecurityOrigin* targetOrigin() const { return m_targetOrigin.get(); }
     ScriptCallStack* stackTrace() const { return m_stackTrace.get(); }
@@ -161,7 +161,7 @@ private:
     RefPtr<SerializedScriptValue> m_message;
     String m_origin;
     RefPtr<DOMWindow> m_source;
-    OwnPtr<MessagePortChannelArray> m_channels;
+    std::unique_ptr<MessagePortChannelArray> m_channels;
     RefPtr<SecurityOrigin> m_targetOrigin;
     RefPtr<ScriptCallStack> m_stackTrace;
 };
@@ -833,7 +833,7 @@ void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const Mes
         }
     }
 
-    OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, ec);
+    std::unique_ptr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, ec);
     if (ec)
         return;
 
@@ -849,7 +849,7 @@ void DOMWindow::postMessage(PassRefPtr<SerializedScriptValue> message, const Mes
         stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture, true);
 
     // Schedule the message.
-    PostMessageTimer* timer = new PostMessageTimer(this, message, sourceOrigin, &source, channels.release(), target.get(), stackTrace.release());
+    PostMessageTimer* timer = new PostMessageTimer(this, message, sourceOrigin, &source, std::move(channels), target.get(), stackTrace.release());
     timer->startOneShot(0);
 }
 
index 701569f..a2b2bcd 100644 (file)
@@ -71,10 +71,10 @@ void DedicatedWorkerGlobalScope::postMessage(PassRefPtr<SerializedScriptValue> m
 void DedicatedWorkerGlobalScope::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionCode& ec)
 {
     // Disentangle the port in preparation for sending it to the remote context.
-    OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, ec);
+    std::unique_ptr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, ec);
     if (ec)
         return;
-    thread()->workerObjectProxy().postMessageToWorkerObject(message, channels.release());
+    thread()->workerObjectProxy().postMessageToWorkerObject(message, std::move(channels));
 }
 
 void DedicatedWorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionCode& ec)
index d3a369f..a675f13 100644 (file)
@@ -254,21 +254,21 @@ void SharedWorkerProxy::close()
 
 class SharedWorkerConnectTask : public ScriptExecutionContext::Task {
 public:
-    static PassOwnPtr<SharedWorkerConnectTask> create(PassOwnPtr<MessagePortChannel> channel)
+    static PassOwnPtr<SharedWorkerConnectTask> create(std::unique_ptr<MessagePortChannel> channel)
     {
-        return adoptPtr(new SharedWorkerConnectTask(channel));
+        return adoptPtr(new SharedWorkerConnectTask(std::move(channel)));
     }
 
 private:
-    SharedWorkerConnectTask(PassOwnPtr<MessagePortChannel> channel)
-        : m_channel(channel)
+    SharedWorkerConnectTask(std::unique_ptr<MessagePortChannel> channel)
+        : m_channel(std::move(channel))
     {
     }
 
     virtual void performTask(ScriptExecutionContext* scriptContext)
     {
         RefPtr<MessagePort> port = MessagePort::create(*scriptContext);
-        port->entangle(m_channel.release());
+        port->entangle(std::move(m_channel));
         ASSERT_WITH_SECURITY_IMPLICATION(scriptContext->isWorkerGlobalScope());
         WorkerGlobalScope* workerGlobalScope = static_cast<WorkerGlobalScope*>(scriptContext);
         // Since close() stops the thread event loop, this should not ever get called while closing.
@@ -277,13 +277,13 @@ private:
         workerGlobalScope->dispatchEvent(createConnectEvent(port));
     }
 
-    OwnPtr<MessagePortChannel> m_channel;
+    std::unique_ptr<MessagePortChannel> m_channel;
 };
 
 // Loads the script on behalf of a worker.
 class SharedWorkerScriptLoader : public RefCounted<SharedWorkerScriptLoader>, private WorkerScriptLoaderClient {
 public:
-    SharedWorkerScriptLoader(PassRefPtr<SharedWorker>, PassOwnPtr<MessagePortChannel>, PassRefPtr<SharedWorkerProxy>);
+    SharedWorkerScriptLoader(PassRefPtr<SharedWorker>, std::unique_ptr<MessagePortChannel>, PassRefPtr<SharedWorkerProxy>);
     void load(const URL&);
 
 private:
@@ -292,14 +292,14 @@ private:
     virtual void notifyFinished();
 
     RefPtr<SharedWorker> m_worker;
-    OwnPtr<MessagePortChannel> m_port;
+    std::unique_ptr<MessagePortChannel> m_port;
     RefPtr<SharedWorkerProxy> m_proxy;
     RefPtr<WorkerScriptLoader> m_scriptLoader;
 };
 
-SharedWorkerScriptLoader::SharedWorkerScriptLoader(PassRefPtr<SharedWorker> worker, PassOwnPtr<MessagePortChannel> port, PassRefPtr<SharedWorkerProxy> proxy)
+SharedWorkerScriptLoader::SharedWorkerScriptLoader(PassRefPtr<SharedWorker> worker, std::unique_ptr<MessagePortChannel> port, PassRefPtr<SharedWorkerProxy> proxy)
     : m_worker(worker)
-    , m_port(port)
+    , m_port(std::move(port))
     , m_proxy(proxy)
 {
 }
@@ -331,9 +331,9 @@ void SharedWorkerScriptLoader::notifyFinished()
     else {
         InspectorInstrumentation::scriptImported(m_worker->scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script());
         DefaultSharedWorkerRepository::instance().workerScriptLoaded(*m_proxy, m_worker->scriptExecutionContext()->userAgent(m_scriptLoader->url()),
-                                                                     m_scriptLoader->script(), m_port.release(),
-                                                                     m_worker->scriptExecutionContext()->contentSecurityPolicy()->deprecatedHeader(),
-                                                                     m_worker->scriptExecutionContext()->contentSecurityPolicy()->deprecatedHeaderType());
+            m_scriptLoader->script(), std::move(m_port),
+            m_worker->scriptExecutionContext()->contentSecurityPolicy()->deprecatedHeader(),
+            m_worker->scriptExecutionContext()->contentSecurityPolicy()->deprecatedHeaderType());
     }
     m_worker->unsetPendingActivity(m_worker.get());
     this->deref(); // This frees this object - must be the last action in this function.
@@ -355,7 +355,7 @@ bool DefaultSharedWorkerRepository::isAvailable()
     return platformStrategies()->sharedWorkerStrategy()->isAvailable();
 }
 
-void DefaultSharedWorkerRepository::workerScriptLoaded(SharedWorkerProxy& proxy, const String& userAgent, const String& workerScript, PassOwnPtr<MessagePortChannel> port, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
+void DefaultSharedWorkerRepository::workerScriptLoaded(SharedWorkerProxy& proxy, const String& userAgent, const String& workerScript, std::unique_ptr<MessagePortChannel> port, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType contentSecurityPolicyType)
 {
     MutexLocker lock(m_lock);
     if (proxy.isClosing())
@@ -367,7 +367,7 @@ void DefaultSharedWorkerRepository::workerScriptLoaded(SharedWorkerProxy& proxy,
         proxy.setThread(thread);
         thread->start();
     }
-    proxy.thread()->runLoop().postTask(SharedWorkerConnectTask::create(port));
+    proxy.thread()->runLoop().postTask(SharedWorkerConnectTask::create(std::move(port)));
 }
 
 bool DefaultSharedWorkerRepository::hasSharedWorkers(Document* document)
@@ -398,7 +398,7 @@ void DefaultSharedWorkerRepository::documentDetached(Document* document)
         m_proxies[i]->documentDetached(document);
 }
 
-void DefaultSharedWorkerRepository::connectToWorker(PassRefPtr<SharedWorker> worker, PassOwnPtr<MessagePortChannel> port, const URL& url, const String& name, ExceptionCode& ec)
+void DefaultSharedWorkerRepository::connectToWorker(PassRefPtr<SharedWorker> worker, std::unique_ptr<MessagePortChannel> port, const URL& url, const String& name, ExceptionCode& ec)
 {
     MutexLocker lock(m_lock);
     ASSERT(worker->scriptExecutionContext()->securityOrigin()->canAccess(SecurityOrigin::create(url).get()));
@@ -415,9 +415,9 @@ void DefaultSharedWorkerRepository::connectToWorker(PassRefPtr<SharedWorker> wor
     }
     // If proxy is already running, just connect to it - otherwise, kick off a loader to load the script.
     if (proxy->thread())
-        proxy->thread()->runLoop().postTask(SharedWorkerConnectTask::create(port));
+        proxy->thread()->runLoop().postTask(SharedWorkerConnectTask::create(std::move(port)));
     else {
-        RefPtr<SharedWorkerScriptLoader> loader = adoptRef(new SharedWorkerScriptLoader(worker, port, proxy.release()));
+        RefPtr<SharedWorkerScriptLoader> loader = adoptRef(new SharedWorkerScriptLoader(worker, std::move(port), proxy.release()));
         loader->load(url);
     }
 }
index d262952..8818303 100644 (file)
 #if ENABLE(SHARED_WORKERS)
 
 #include "ContentSecurityPolicy.h"
+#include <memory>
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Threading.h>
@@ -62,10 +62,10 @@ namespace WebCore {
         static bool isAvailable();
 
         // Invoked once the worker script has been loaded to fire up the worker thread.
-        void workerScriptLoaded(SharedWorkerProxy&, const String& userAgent, const String& workerScript, PassOwnPtr<MessagePortChannel>, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
+        void workerScriptLoaded(SharedWorkerProxy&, const String& userAgent, const String& workerScript, std::unique_ptr<MessagePortChannel>, const String& contentSecurityPolicy, ContentSecurityPolicy::HeaderType);
 
         // Internal implementation of SharedWorkerRepository::connect()
-        void connectToWorker(PassRefPtr<SharedWorker>, PassOwnPtr<MessagePortChannel>, const URL&, const String& name, ExceptionCode&);
+        void connectToWorker(PassRefPtr<SharedWorker>, std::unique_ptr<MessagePortChannel>, const URL&, const String& name, ExceptionCode&);
 
         // Notification that a document has been detached.
         void documentDetached(Document*);
index 634b4d0..882e229 100644 (file)
@@ -66,7 +66,7 @@ PassRefPtr<SharedWorker> SharedWorker::create(ScriptExecutionContext& context, c
 
     RefPtr<MessageChannel> channel = MessageChannel::create(context);
     worker->m_port = channel->port1();
-    OwnPtr<MessagePortChannel> remotePort = channel->port2()->disentangle();
+    std::unique_ptr<MessagePortChannel> remotePort = channel->port2()->disentangle();
     ASSERT(remotePort);
 
     worker->suspendIfNeeded();
@@ -80,7 +80,7 @@ PassRefPtr<SharedWorker> SharedWorker::create(ScriptExecutionContext& context, c
         return 0;
     }
 
-    SharedWorkerRepository::connect(worker.get(), remotePort.release(), scriptURL, name, ec);
+    SharedWorkerRepository::connect(worker.get(), std::move(remotePort), scriptURL, name, ec);
 
     return worker.release();
 }
index 23f2fa8..7547d7a 100644 (file)
@@ -47,7 +47,7 @@ namespace WebCore {
 PassRefPtr<MessageEvent> createConnectEvent(PassRefPtr<MessagePort> prpPort)
 {
     RefPtr<MessagePort> port = prpPort;
-    RefPtr<MessageEvent> event = MessageEvent::create(adoptPtr(new MessagePortArray(1, port)), Deprecated::ScriptValue(), String(), String(), port);
+    RefPtr<MessageEvent> event = MessageEvent::create(std::make_unique<MessagePortArray>(1, port), Deprecated::ScriptValue(), String(), String(), port);
     event->initEvent(eventNames().connectEvent, false, false);
     return event.release();
 }
index a3cda5b..571c9c7 100644 (file)
@@ -41,9 +41,9 @@ bool SharedWorkerRepository::isAvailable()
     return DefaultSharedWorkerRepository::instance().isAvailable();
 }
 
-void SharedWorkerRepository::connect(PassRefPtr<SharedWorker> worker, PassOwnPtr<MessagePortChannel> port, const URL& url, const String& name, ExceptionCode& ec)
+void SharedWorkerRepository::connect(PassRefPtr<SharedWorker> worker, std::unique_ptr<MessagePortChannel> port, const URL& url, const String& name, ExceptionCode& ec)
 {
-    DefaultSharedWorkerRepository::instance().connectToWorker(worker, port, url, name, ec);
+    DefaultSharedWorkerRepository::instance().connectToWorker(worker, std::move(port), url, name, ec);
 }
 
 void SharedWorkerRepository::documentDetached(Document* document)
index 049f86a..4e2f49f 100644 (file)
@@ -33,8 +33,8 @@
 
 #if ENABLE(SHARED_WORKERS)
 
+#include <memory>
 #include <wtf/Forward.h>
-#include <wtf/PassOwnPtr.h>
 #include <wtf/PassRefPtr.h>
 
 namespace WebCore {
@@ -53,7 +53,7 @@ namespace WebCore {
         static bool isAvailable();
 
         // Connects the passed SharedWorker object with the specified worker thread, creating a new thread if necessary.
-        static void connect(PassRefPtr<SharedWorker>, PassOwnPtr<MessagePortChannel>, const URL&, const String& name, ExceptionCode&);
+        static void connect(PassRefPtr<SharedWorker>, std::unique_ptr<MessagePortChannel>, const URL&, const String& name, ExceptionCode&);
 
         // Invoked when a document has been detached.
         static void documentDetached(Document*);
index 168d138..629cf4e 100644 (file)
@@ -119,10 +119,10 @@ void Worker::postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort*
 void Worker::postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray* ports, ExceptionCode& ec)
 {
     // Disentangle the port in preparation for sending it to the remote context.
-    OwnPtr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, ec);
+    std::unique_ptr<MessagePortChannelArray> channels = MessagePort::disentanglePorts(ports, ec);
     if (ec)
         return;
-    m_contextProxy->postMessageToWorkerGlobalScope(message, channels.release());
+    m_contextProxy->postMessageToWorkerGlobalScope(message, std::move(channels));
 }
 
 void Worker::terminate()
index 0a30071..9286416 100644 (file)
@@ -33,8 +33,8 @@
 
 #include "MessagePort.h"
 #include "WorkerThread.h"
+#include <memory>
 #include <wtf/Forward.h>
-#include <wtf/PassOwnPtr.h>
 
 namespace WebCore {
 
@@ -52,7 +52,7 @@ namespace WebCore {
 
         virtual void terminateWorkerGlobalScope() = 0;
 
-        virtual void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>) = 0;
+        virtual void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue>, std::unique_ptr<MessagePortChannelArray>) = 0;
 
         virtual bool hasPendingActivity() const = 0;
 
index 575ff2c..438f47e 100644 (file)
@@ -55,15 +55,15 @@ namespace WebCore {
 
 class MessageWorkerGlobalScopeTask : public ScriptExecutionContext::Task {
 public:
-    static PassOwnPtr<MessageWorkerGlobalScopeTask> create(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels)
+    static PassOwnPtr<MessageWorkerGlobalScopeTask> create(PassRefPtr<SerializedScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels)
     {
-        return adoptPtr(new MessageWorkerGlobalScopeTask(message, channels));
+        return adoptPtr(new MessageWorkerGlobalScopeTask(message, std::move(channels)));
     }
 
 private:
-    MessageWorkerGlobalScopeTask(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels)
+    MessageWorkerGlobalScopeTask(PassRefPtr<SerializedScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels)
         : m_message(message)
-        , m_channels(channels)
+        , m_channels(std::move(channels))
     {
     }
 
@@ -71,27 +71,27 @@ private:
     {
         ASSERT_WITH_SECURITY_IMPLICATION(scriptContext->isWorkerGlobalScope());
         DedicatedWorkerGlobalScope* context = static_cast<DedicatedWorkerGlobalScope*>(scriptContext);
-        OwnPtr<MessagePortArray> ports = MessagePort::entanglePorts(*scriptContext, m_channels.release());
-        context->dispatchEvent(MessageEvent::create(ports.release(), m_message));
+        std::unique_ptr<MessagePortArray> ports = MessagePort::entanglePorts(*scriptContext, std::move(m_channels));
+        context->dispatchEvent(MessageEvent::create(std::move(ports), m_message));
         context->thread()->workerObjectProxy().confirmMessageFromWorkerObject(context->hasPendingActivity());
     }
 
 private:
     RefPtr<SerializedScriptValue> m_message;
-    OwnPtr<MessagePortChannelArray> m_channels;
+    std::unique_ptr<MessagePortChannelArray> m_channels;
 };
 
 class MessageWorkerTask : public ScriptExecutionContext::Task {
 public:
-    static PassOwnPtr<MessageWorkerTask> create(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels, WorkerMessagingProxy* messagingProxy)
+    static PassOwnPtr<MessageWorkerTask> create(PassRefPtr<SerializedScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels, WorkerMessagingProxy* messagingProxy)
     {
-        return adoptPtr(new MessageWorkerTask(message, channels, messagingProxy));
+        return adoptPtr(new MessageWorkerTask(message, std::move(channels), messagingProxy));
     }
 
 private:
-    MessageWorkerTask(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels, WorkerMessagingProxy* messagingProxy)
+    MessageWorkerTask(PassRefPtr<SerializedScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels, WorkerMessagingProxy* messagingProxy)
         : m_message(message)
-        , m_channels(channels)
+        , m_channels(std::move(channels))
         , m_messagingProxy(messagingProxy)
     {
     }
@@ -102,13 +102,13 @@ private:
         if (!workerObject || m_messagingProxy->askedToTerminate())
             return;
 
-        OwnPtr<MessagePortArray> ports = MessagePort::entanglePorts(*scriptContext, m_channels.release());
-        workerObject->dispatchEvent(MessageEvent::create(ports.release(), m_message));
+        std::unique_ptr<MessagePortArray> ports = MessagePort::entanglePorts(*scriptContext, std::move(m_channels));
+        workerObject->dispatchEvent(MessageEvent::create(std::move(ports), m_message));
     }
 
 private:
     RefPtr<SerializedScriptValue> m_message;
-    OwnPtr<MessagePortChannelArray> m_channels;
+    std::unique_ptr<MessagePortChannelArray> m_channels;
     WorkerMessagingProxy* m_messagingProxy;
 };
 
@@ -309,21 +309,21 @@ void WorkerMessagingProxy::startWorkerGlobalScope(const URL& scriptURL, const St
     InspectorInstrumentation::didStartWorkerGlobalScope(m_scriptExecutionContext.get(), this, scriptURL);
 }
 
-void WorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels)
+void WorkerMessagingProxy::postMessageToWorkerObject(PassRefPtr<SerializedScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels)
 {
-    m_scriptExecutionContext->postTask(MessageWorkerTask::create(message, channels, this));
+    m_scriptExecutionContext->postTask(MessageWorkerTask::create(message, std::move(channels), this));
 }
 
-void WorkerMessagingProxy::postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray> channels)
+void WorkerMessagingProxy::postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue> message, std::unique_ptr<MessagePortChannelArray> channels)
 {
     if (m_askedToTerminate)
         return;
 
     if (m_workerThread) {
         ++m_unconfirmedMessageCount;
-        m_workerThread->runLoop().postTask(MessageWorkerGlobalScopeTask::create(message, channels));
+        m_workerThread->runLoop().postTask(MessageWorkerGlobalScopeTask::create(message, std::move(channels)));
     } else
-        m_queuedEarlyTasks.append(MessageWorkerGlobalScopeTask::create(message, channels));
+        m_queuedEarlyTasks.append(MessageWorkerGlobalScopeTask::create(message, std::move(channels)));
 }
 
 bool WorkerMessagingProxy::postTaskForModeToWorkerGlobalScope(PassOwnPtr<ScriptExecutionContext::Task> task, const String& mode)
index bf607f5..ecfe868 100644 (file)
@@ -31,6 +31,7 @@
 #include "WorkerGlobalScopeProxy.h"
 #include "WorkerLoaderProxy.h"
 #include "WorkerObjectProxy.h"
+#include <memory>
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/PassOwnPtr.h>
@@ -53,7 +54,7 @@ namespace WebCore {
         // (Only use these methods in the worker object thread.)
         virtual void startWorkerGlobalScope(const URL& scriptURL, const String& userAgent, const String& sourceCode, WorkerThreadStartMode) override;
         virtual void terminateWorkerGlobalScope() override;
-        virtual void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>) override;
+        virtual void postMessageToWorkerGlobalScope(PassRefPtr<SerializedScriptValue>, std::unique_ptr<MessagePortChannelArray>) override;
         virtual bool hasPendingActivity() const override;
         virtual void workerObjectDestroyed() override;
         virtual void notifyNetworkStateChange(bool isOnline) override;
@@ -65,7 +66,7 @@ namespace WebCore {
 
         // Implementations of WorkerObjectProxy.
         // (Only use these methods in the worker context thread.)
-        virtual void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>) override;
+        virtual void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, std::unique_ptr<MessagePortChannelArray>) override;
         virtual void postExceptionToWorkerObject(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL) override;
         virtual void postConsoleMessageToWorkerObject(MessageSource, MessageLevel, const String& message, int lineNumber, int columnNumber, const String& sourceURL) override;
 #if ENABLE(INSPECTOR)
index e6a4b7d..cefab4d 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "WorkerReportingProxy.h"
 #include "MessagePort.h"
-#include <wtf/PassOwnPtr.h>
+#include <memory>
 
 namespace WebCore {
 
@@ -42,7 +42,7 @@ namespace WebCore {
     // A proxy to talk to the worker object.
     class WorkerObjectProxy : public WorkerReportingProxy {
     public:
-        virtual void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>) = 0;
+        virtual void postMessageToWorkerObject(PassRefPtr<SerializedScriptValue>, std::unique_ptr<MessagePortChannelArray>) = 0;
 
         virtual void confirmMessageFromWorkerObject(bool hasPendingActivity) = 0;
         virtual void reportPendingActivity(bool hasPendingActivity) = 0;