Changeset 44915 in webkit for trunk/JavaScriptCore/wtf


Ignore:
Timestamp:
Jun 21, 2009, 2:32:20 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2009-06-21 Drew Wilson <[email protected]>

Reviewed by David Levin.

<https://bugs.webkit.org/show_bug.cgi?id=25043>
Added support for multi-threaded MessagePorts.

  • wtf/MessageQueue.h: (WTF::::appendAndCheckEmpty):

Added API to test whether the queue was empty before adding an element.

WebCore:

2009-06-21 Drew Wilson <[email protected]>

Reviewed by David Levin.

<https://bugs.webkit.org/show_bug.cgi?id=25043>
Removed obsolete MessagePort.startConversation(), active and onclose APIs.

Refactored MessagePortProxy into MessagePortChannel and a platform-dependent PlatformMessagePortChannel
implementation. Modified APIs to simplify cross-process implementations by moving the messaging code
entirely into the platform-dependent proxy.

Created a thread-safe default PlatformMessagePortChannel implementation.

Changed DOMWindow messaging to create the MessageEvent in the target ScriptExecutionContext to match how
cross-thread MessagePorts work.

  • GNUMakefile.am:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:

Added MessagePortChannel/PlatformMessagePortChannel files.

  • bindings/js/JSMessagePortCustom.cpp: (WebCore::JSMessagePort::mark):

Changed ports to not mark their entangled pair as reachable, per the spec.

  • bindings/v8/custom/V8MessagePortCustom.cpp:
  • dom/MessageChannel.cpp: (WebCore::MessageChannel::MessageChannel):

Updated to use PlatformMessagePortChannel::createChannel() to entangle the ports.

  • dom/MessagePort.cpp: (WebCore::MessagePort::MessagePort): (WebCore::MessagePort::~MessagePort): (WebCore::MessagePort::postMessage): (WebCore::MessagePort::disentangle): (WebCore::MessagePort::messageAvailable): (WebCore::MessagePort::start): (WebCore::MessagePort::close): (WebCore::MessagePort::entangle): (WebCore::MessagePort::contextDestroyed): (WebCore::MessagePort::dispatchMessages): (WebCore::MessagePort::setOnmessage): (WebCore::MessagePort::hasPendingActivity):

Changed these APIs to delegate to new PlatformMessagePortChannel APIs.

  • dom/MessagePort.h:

Renamed isQueueOpen() to started().

  • dom/MessagePort.idl:

Removed startConversation and onclose.

  • dom/MessagePortProxy.h: Removed.
  • dom/MessagePortChannel.cpp: Added. (WebCore::MessagePortChannel::EventData::create): (WebCore::MessagePortChannel::EventData::EventData): (WebCore::MessagePortChannel::~MessagePortChannel):
  • dom/MessagePortChannel.h: Added. (WebCore::MessagePortChannel::EventData::message): (WebCore::MessagePortChannel::EventData::channel):

Changed EventData to hold a reference to a MessagePortChannel object instead of a MessagePort to enable cross-thread messaging.

(WebCore::MessagePortChannel::MessagePortChannel):
(WebCore::MessagePortChannel::create):

  • dom/ScriptExecutionContext.cpp: (WebCore:ScriptExecutionContext::dispatchMessagePortEvents):

Renamed isQueueOpen() to started().

  • dom/default/PlatformMessagePortChannel.cpp: Added. (WebCore::MessagePortChannel::entangleIfOpen): (WebCore::MessagePortChannel::disentangle): (WebCore::MessagePortChannel::postMessageToRemote): (WebCore::MessagePortChannel::tryGetMessageFromRemote): (WebCore::MessagePortChannel::close): (WebCore::MessagePortChannel::isConnectedTo): (WebCore::MessagePortChannel::hasPendingActivity): (WebCore::PlatformMessagePortChannel::PlatformMessagePortChannel): (WebCore::PlatformMessagePortChannel::~PlatformMessagePortChannel): (WebCore::PlatformMessagePortChannel::createChannel): (WebCore::PlatformMessagePortChannel::entangleIfOpen): (WebCore::PlatformMessagePortChannel::disentangle): (WebCore::PlatformMessagePortChannel::setRemotePort): (WebCore::PlatformMessagePortChannel::remotePort): (WebCore::PlatformMessagePortChannel::entangledChannel): (WebCore::PlatformMessagePortChannel::setEntangledChannel): (WebCore::PlatformMessagePortChannel::postMessageToRemote): (WebCore::PlatformMessagePortChannel::tryGetMessageFromRemote): (WebCore::PlatformMessagePortChannel::isConnectedTo): (WebCore::PlatformMessagePortChannel::close): (WebCore::PlatformMessagePortChannel::closeInternal): (WebCore::PlatformMessagePortChannel::hasPendingActivity):
  • dom/default/PlatformMessagePortChannel.h: Added. (WebCore::PlatformMessagePortChannel::MessagePortQueue::create): (WebCore::PlatformMessagePortChannel::MessagePortQueue::tryGetMessage): (WebCore::PlatformMessagePortChannel::MessagePortQueue::appendAndCheckEmpty): (WebCore::PlatformMessagePortChannel::MessagePortQueue::isEmpty): (WebCore::PlatformMessagePortChannel::MessagePortQueue::MessagePortQueue):
  • page/DOMWindow.cpp: (WebCore::PostMessageTimer::PostMessageTimer):

Changed DOMWindow messaging to create the MessageEvent in the target ScriptExecutionContext to match how cross-thread MessagePorts work.

(WebCore::PostMessageTimer::event):
(WebCore::DOMWindow::postMessage):
(WebCore::DOMWindow::postMessageTimerFired):

LayoutTests:

2009-06-21 Drew Wilson <[email protected]>

Reviewed by David Levin.

<https://bugs.webkit.org/show_bug.cgi?id=25043>
Updated MessageChannel/MessagePorts tests to reflect latest spec (close event has been removed).
Added more tests of port cloning.

  • fast/events/message-channel-gc-2-expected.txt:
  • fast/events/message-channel-gc-2.html-disabled:
  • fast/events/message-channel-gc-3-expected.txt:
  • fast/events/message-channel-gc-3.html-disabled:
  • fast/events/message-channel-gc-expected.txt:
  • fast/events/message-channel-gc.html-disabled:
  • fast/events/message-port-clone-expected.txt: Added.
  • fast/events/message-port-clone.html-disabled: Added.
  • fast/events/message-port-expected.txt:
  • fast/events/message-port-no-wrapper-expected.txt: Added.
  • fast/events/message-port-onclose-expected.txt: Removed.
  • fast/events/message-port-onclose.html-disabled: Removed.
  • fast/events/message-port.html-disabled:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/MessageQueue.h

    r41156 r44915  
    4848    class MessageQueue : Noncopyable {
    4949    public:
    50         MessageQueue() : m_killed(false) {}
     50        MessageQueue() : m_killed(false) { }
    5151       
    5252        void append(const DataType&);
     53        bool appendAndCheckEmpty(const DataType&);
    5354        void prepend(const DataType&);
    5455        bool waitForMessage(DataType&);
     
    8081        m_queue.append(message);
    8182        m_condition.signal();
     83    }
     84
     85    // Returns true if the queue was empty before the item was added.
     86    template<typename DataType>
     87    inline bool MessageQueue<DataType>::appendAndCheckEmpty(const DataType& message)
     88    {
     89        MutexLocker lock(m_mutex);
     90        bool wasEmpty = m_queue.isEmpty();
     91        m_queue.append(message);
     92        m_condition.signal();
     93        return wasEmpty;
    8294    }
    8395
Note: See TracChangeset for help on using the changeset viewer.