WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-128467-20140208214936.patch (text/plain), 55.42 KB, created by
Zan Dobersek
on 2014-02-08 12:49:42 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Zan Dobersek
Created:
2014-02-08 12:49:42 PST
Size:
55.42 KB
patch
obsolete
>Subversion Revision: 163713 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index d266595ee9c6ffe092bcd18b6cf6e53ec2bc293e..ce348b6e86a6b8772d79de752995e65a2d11c464 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,73 @@ >+2014-02-08 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 NOBODY (OOPS!). >+ >+ 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 Darin Adler <darin@apple.com> > > Change TextIterator to use StringView, preparing to wean it from deprecatedCharacters >diff --git a/Source/WebCore/bindings/js/JSMessageEventCustom.cpp b/Source/WebCore/bindings/js/JSMessageEventCustom.cpp >index c84ca0d9a525b5c81ff7370172460fc605a2df8a..5615a086320aff15876e579ce7101bae2d6bfa4b 100644 >--- a/Source/WebCore/bindings/js/JSMessageEventCustom.cpp >+++ b/Source/WebCore/bindings/js/JSMessageEventCustom.cpp >@@ -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(); > } >diff --git a/Source/WebCore/dom/MessageEvent.cpp b/Source/WebCore/dom/MessageEvent.cpp >index 4388c9fecfac102b78028f13d148d871b991812d..5816d0a67b31d82ce8eac48b3c3bd7976844ee9b 100644 >--- a/Source/WebCore/dom/MessageEvent.cpp >+++ b/Source/WebCore/dom/MessageEvent.cpp >@@ -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 >diff --git a/Source/WebCore/dom/MessageEvent.h b/Source/WebCore/dom/MessageEvent.h >index cfb2fa4146221d5f952b70a0544f2cbe14555448..5be90204b8f55340604add2184e8dcd27bfefca0 100644 >--- a/Source/WebCore/dom/MessageEvent.h >+++ b/Source/WebCore/dom/MessageEvent.h >@@ -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 >diff --git a/Source/WebCore/dom/MessagePort.cpp b/Source/WebCore/dom/MessagePort.cpp >index 64167230f767ffd1f6ab570f3aea22baa54ef29d..8e5b29d8f98921d2e0957891b62fd10a336ed22d 100644 >--- a/Source/WebCore/dom/MessagePort.cpp >+++ b/Source/WebCore/dom/MessagePort.cpp >@@ -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 >diff --git a/Source/WebCore/dom/MessagePort.h b/Source/WebCore/dom/MessagePort.h >index 9e043748bc9ccdb8a24c1305c9bc96cb4353616e..0fd3e414d0ca610f6047b60f42a12d63e1d73f50 100644 >--- a/Source/WebCore/dom/MessagePort.h >+++ b/Source/WebCore/dom/MessagePort.h >@@ -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; >diff --git a/Source/WebCore/dom/MessagePortChannel.h b/Source/WebCore/dom/MessagePortChannel.h >index 9e1b7cba6b27524c9cea770df161340dcef66dd7..a711eff6f0d229919011b93309bf6b8ffe51d4f1 100644 >--- a/Source/WebCore/dom/MessagePortChannel.h >+++ b/Source/WebCore/dom/MessagePortChannel.h >@@ -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; > }; > >diff --git a/Source/WebCore/dom/default/PlatformMessagePortChannel.cpp b/Source/WebCore/dom/default/PlatformMessagePortChannel.cpp >index 902da183400aa9c266b0e29848ca35605248fa71..342ef678831b27396d3d57ea25b049e1555ff114 100644 >--- a/Source/WebCore/dom/default/PlatformMessagePortChannel.cpp >+++ b/Source/WebCore/dom/default/PlatformMessagePortChannel.cpp >@@ -37,14 +37,9 @@ > > 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(); >diff --git a/Source/WebCore/dom/default/PlatformMessagePortChannel.h b/Source/WebCore/dom/default/PlatformMessagePortChannel.h >index 6eb89d47d229adf1fecf9bbc942d6517ec21d913..50984f90aeff1536012ad71db0a2370d5cc00ec8 100644 >--- a/Source/WebCore/dom/default/PlatformMessagePortChannel.h >+++ b/Source/WebCore/dom/default/PlatformMessagePortChannel.h >@@ -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. >diff --git a/Source/WebCore/page/DOMWindow.cpp b/Source/WebCore/page/DOMWindow.cpp >index 3df2cc4aca47b190bf9c345f520762149f285fda..4fa4330aa6a6340415467e971df0de2b22cc4427 100644 >--- a/Source/WebCore/page/DOMWindow.cpp >+++ b/Source/WebCore/page/DOMWindow.cpp >@@ -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); > } > >diff --git a/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp b/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >index 701569f15296e534ad917f8988469f8a0ca4f570..a2b2bcdce73e2d481ae4b55fe8df2690d756b68c 100644 >--- a/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >+++ b/Source/WebCore/workers/DedicatedWorkerGlobalScope.cpp >@@ -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) >diff --git a/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp b/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp >index d3a369fb014536ca17858ace90f9d2fd091fbdea..a675f131803ef1b5e5beced4dc4145e0f56883c8 100644 >--- a/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp >+++ b/Source/WebCore/workers/DefaultSharedWorkerRepository.cpp >@@ -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); > } > } >diff --git a/Source/WebCore/workers/DefaultSharedWorkerRepository.h b/Source/WebCore/workers/DefaultSharedWorkerRepository.h >index d2629524e16261f217c3c8dbd6743850814dcc92..881830371a6a2e30ec99f48d796d5fecfa5b609b 100644 >--- a/Source/WebCore/workers/DefaultSharedWorkerRepository.h >+++ b/Source/WebCore/workers/DefaultSharedWorkerRepository.h >@@ -34,10 +34,10 @@ > #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*); >diff --git a/Source/WebCore/workers/SharedWorker.cpp b/Source/WebCore/workers/SharedWorker.cpp >index 634b4d0127cbaf09024b145de285ab7bb7f51a9d..882e2290576aa956e868053e32c8ab0c43053d54 100644 >--- a/Source/WebCore/workers/SharedWorker.cpp >+++ b/Source/WebCore/workers/SharedWorker.cpp >@@ -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(); > } >diff --git a/Source/WebCore/workers/SharedWorkerGlobalScope.cpp b/Source/WebCore/workers/SharedWorkerGlobalScope.cpp >index 23f2fa8a712e89cd8050b900b0d277684deffa2f..7547d7ad084bc9cc5b446582eba5950461c549c2 100644 >--- a/Source/WebCore/workers/SharedWorkerGlobalScope.cpp >+++ b/Source/WebCore/workers/SharedWorkerGlobalScope.cpp >@@ -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(); > } >diff --git a/Source/WebCore/workers/SharedWorkerRepository.cpp b/Source/WebCore/workers/SharedWorkerRepository.cpp >index a3cda5b505f813025e87e3e7a8c6a5f61b5911e8..571c9c72d175caf439ffb9c0c32e4a3a335f773d 100644 >--- a/Source/WebCore/workers/SharedWorkerRepository.cpp >+++ b/Source/WebCore/workers/SharedWorkerRepository.cpp >@@ -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) >diff --git a/Source/WebCore/workers/SharedWorkerRepository.h b/Source/WebCore/workers/SharedWorkerRepository.h >index 049f86ac9e653bf86c816296984bf1a01e0ce35e..4e2f49f9a05a8e32e88cd22ba169ebf8711137cf 100644 >--- a/Source/WebCore/workers/SharedWorkerRepository.h >+++ b/Source/WebCore/workers/SharedWorkerRepository.h >@@ -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*); >diff --git a/Source/WebCore/workers/Worker.cpp b/Source/WebCore/workers/Worker.cpp >index 168d13821045b6677453caac4c59ea7e7797b399..629cf4e4e1f59a19c27df4ecddb42cd17993e610 100644 >--- a/Source/WebCore/workers/Worker.cpp >+++ b/Source/WebCore/workers/Worker.cpp >@@ -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() >diff --git a/Source/WebCore/workers/WorkerGlobalScopeProxy.h b/Source/WebCore/workers/WorkerGlobalScopeProxy.h >index 0a300710aaa48ffea1f68e1167e3f89277572b43..9286416cb695e30c0f9a5f0786ba81167985cc92 100644 >--- a/Source/WebCore/workers/WorkerGlobalScopeProxy.h >+++ b/Source/WebCore/workers/WorkerGlobalScopeProxy.h >@@ -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; > >diff --git a/Source/WebCore/workers/WorkerMessagingProxy.cpp b/Source/WebCore/workers/WorkerMessagingProxy.cpp >index 575ff2ce6b73a4e0f2d8c80132dc12565812fc18..438f47e502181370b35010987d7930aeaf723d05 100644 >--- a/Source/WebCore/workers/WorkerMessagingProxy.cpp >+++ b/Source/WebCore/workers/WorkerMessagingProxy.cpp >@@ -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) >diff --git a/Source/WebCore/workers/WorkerMessagingProxy.h b/Source/WebCore/workers/WorkerMessagingProxy.h >index bf607f582ce1b4d5414a6549c98221725ed95d25..ecfe86836696b34f9eb367aa7d94383f96ec4b43 100644 >--- a/Source/WebCore/workers/WorkerMessagingProxy.h >+++ b/Source/WebCore/workers/WorkerMessagingProxy.h >@@ -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) >diff --git a/Source/WebCore/workers/WorkerObjectProxy.h b/Source/WebCore/workers/WorkerObjectProxy.h >index e6a4b7d73bc56bed07fe480a57bd35d73d86b489..cefab4d148f9d0d9827da0f428bf75f113c7e36d 100644 >--- a/Source/WebCore/workers/WorkerObjectProxy.h >+++ b/Source/WebCore/workers/WorkerObjectProxy.h >@@ -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;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 128467
: 223578