Commit ad5420c1 authored by ap@apple.com's avatar ap@apple.com

https://bugs.webkit.org/show_bug.cgi?id=112627

MessagePort::disentangle() takes an ExceptionCode argument without any need

Reviewed by Geoffrey Garen.

MessagePort::disentangle() is called in two places. One has ASSERT_NO_EXCEPTION,
and another fails to check the exception, but clearly cannot get one.

This function is also not exposed to bindings.

* dom/MessagePort.cpp:
(WebCore::MessagePort::disentangle):
(WebCore::MessagePort::disentanglePorts):
* dom/MessagePort.h:
* workers/SharedWorker.cpp:
(WebCore::SharedWorker::create):
Also removed some unhelpful comments.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146130 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1430de0e
2013-03-18 Alexey Proskuryakov <ap@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=112627
MessagePort::disentangle() takes an ExceptionCode argument without any need
Reviewed by Geoffrey Garen.
MessagePort::disentangle() is called in two places. One has ASSERT_NO_EXCEPTION,
and another fails to check the exception, but clearly cannot get one.
This function is also not exposed to bindings.
* dom/MessagePort.cpp:
(WebCore::MessagePort::disentangle):
(WebCore::MessagePort::disentanglePorts):
* dom/MessagePort.h:
* workers/SharedWorker.cpp:
(WebCore::SharedWorker::create):
Also removed some unhelpful comments.
2013-03-18 Xianzhu Wang <wangxianzhu@chromium.org>
Variant of non-primary fell-back SVGFont causes crash.
......@@ -88,18 +88,17 @@ void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const M
m_entangledChannel->postMessageToRemote(MessagePortChannel::EventData::create(message, channels.release()));
}
PassOwnPtr<MessagePortChannel> MessagePort::disentangle(ExceptionCode& ec)
PassOwnPtr<MessagePortChannel> MessagePort::disentangle()
{
if (!m_entangledChannel)
ec = INVALID_STATE_ERR;
else {
m_entangledChannel->disentangle();
ASSERT(m_entangledChannel);
m_entangledChannel->disentangle();
// We can't receive any messages or generate any events, so remove ourselves from the list of active ports.
ASSERT(m_scriptExecutionContext);
m_scriptExecutionContext->destroyedMessagePort(this);
m_scriptExecutionContext = 0;
// We can't receive any messages or generate any events, so remove ourselves from the list of active ports.
ASSERT(m_scriptExecutionContext);
m_scriptExecutionContext->destroyedMessagePort(this);
m_scriptExecutionContext = 0;
}
return m_entangledChannel.release();
}
......@@ -221,7 +220,7 @@ 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()));
for (unsigned int i = 0 ; i < ports->size() ; ++i) {
OwnPtr<MessagePortChannel> channel = (*ports)[i]->disentangle(ASSERT_NO_EXCEPTION); // Can't generate exception here if passed above checks.
OwnPtr<MessagePortChannel> channel = (*ports)[i]->disentangle();
(*portArray)[i] = channel.release();
}
return portArray.release();
......
......@@ -47,10 +47,6 @@ namespace WebCore {
// The overwhelmingly common case is sending a single port, so handle that efficiently with an inline buffer of size 1.
typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray;
// FIXME: This class should inherit from ActiveDOMObject and use
// setPendingActivity / unsetPendingActivity instead of duplicating
// ActiveDOMObject's features and relying on JavaScript garbage collection
// to get its lifetime right.
class MessagePort : public RefCounted<MessagePort>, public EventTarget {
public:
static PassRefPtr<MessagePort> create(ScriptExecutionContext& scriptExecutionContext) { return adoptRef(new MessagePort(scriptExecutionContext)); }
......@@ -64,14 +60,11 @@ namespace WebCore {
void close();
void entangle(PassOwnPtr<MessagePortChannel>);
PassOwnPtr<MessagePortChannel> disentangle(ExceptionCode&);
PassOwnPtr<MessagePortChannel> disentangle();
// Disentangle an array of ports, returning the entangled channels.
// Per section 8.3.3 of the HTML5 spec, generates an INVALID_STATE_ERR exception if any of the passed ports are null or not entangled.
// Returns 0 if there is an exception, or if the passed-in array is 0/empty.
static PassOwnPtr<MessagePortChannelArray> disentanglePorts(const MessagePortArray*, ExceptionCode&);
// Entangles an array of channels, returning an array of MessagePorts in matching order.
// Returns 0 if the passed array is 0/empty.
static PassOwnPtr<MessagePortArray> entanglePorts(ScriptExecutionContext&, PassOwnPtr<MessagePortChannelArray>);
......
......@@ -61,7 +61,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(ec);
OwnPtr<MessagePortChannel> remotePort = channel->port2()->disentangle();
ASSERT(remotePort);
worker->suspendIfNeeded();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment