summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/default/PlatformMessagePortChannel.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/dom/default/PlatformMessagePortChannel.h')
-rw-r--r--Source/WebCore/dom/default/PlatformMessagePortChannel.h48
1 files changed, 17 insertions, 31 deletions
diff --git a/Source/WebCore/dom/default/PlatformMessagePortChannel.h b/Source/WebCore/dom/default/PlatformMessagePortChannel.h
index 6eb89d47d..4e4916a4f 100644
--- a/Source/WebCore/dom/default/PlatformMessagePortChannel.h
+++ b/Source/WebCore/dom/default/PlatformMessagePortChannel.h
@@ -28,13 +28,10 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef PlatformMessagePortChannel_h
-#define PlatformMessagePortChannel_h
+#pragma once
#include "MessagePortChannel.h"
-
#include <wtf/MessageQueue.h>
-#include <wtf/PassRefPtr.h>
#include <wtf/Threading.h>
namespace WebCore {
@@ -46,33 +43,24 @@ namespace WebCore {
// The goal of this implementation is to eliminate contention except when cloning or closing the port, so each side of the channel has its own separate mutex.
class PlatformMessagePortChannel : public ThreadSafeRefCounted<PlatformMessagePortChannel> {
public:
- class EventData {
- WTF_MAKE_NONCOPYABLE(EventData); WTF_MAKE_FAST_ALLOCATED;
- public:
- static std::unique_ptr<EventData> create(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>);
-
- PassRefPtr<SerializedScriptValue> message() { return m_message; }
- PassOwnPtr<MessagePortChannelArray> channels() { return m_channels.release(); }
-
- private:
- EventData(PassRefPtr<SerializedScriptValue> message, PassOwnPtr<MessagePortChannelArray>);
- RefPtr<SerializedScriptValue> m_message;
- OwnPtr<MessagePortChannelArray> m_channels;
- };
-
// Wrapper for MessageQueue that allows us to do thread safe sharing by two proxies.
class MessagePortQueue : public ThreadSafeRefCounted<MessagePortQueue> {
public:
- static PassRefPtr<MessagePortQueue> create() { return adoptRef(new MessagePortQueue()); }
+ static Ref<MessagePortQueue> create() { return adoptRef(*new MessagePortQueue()); }
- std::unique_ptr<PlatformMessagePortChannel::EventData> tryGetMessage()
+ std::unique_ptr<MessagePortChannel::EventData> takeMessage()
{
return m_queue.tryGetMessage();
}
- bool appendAndCheckEmpty(std::unique_ptr<PlatformMessagePortChannel::EventData> message)
+ Deque<std::unique_ptr<MessagePortChannel::EventData>> takeAllMessages()
{
- return m_queue.appendAndCheckEmpty(std::move(message));
+ return m_queue.takeAllMessages();
+ }
+
+ bool appendAndCheckEmpty(std::unique_ptr<MessagePortChannel::EventData>&& message)
+ {
+ return m_queue.appendAndCheckEmpty(WTFMove(message));
}
bool isEmpty()
@@ -83,21 +71,21 @@ namespace WebCore {
private:
MessagePortQueue() { }
- MessageQueue<PlatformMessagePortChannel::EventData> m_queue;
+ MessageQueue<MessagePortChannel::EventData> m_queue;
};
~PlatformMessagePortChannel();
- static PassRefPtr<PlatformMessagePortChannel> create(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing);
- PlatformMessagePortChannel(PassRefPtr<MessagePortQueue> incoming, PassRefPtr<MessagePortQueue> outgoing);
+ static Ref<PlatformMessagePortChannel> create(MessagePortQueue* incoming, MessagePortQueue* outgoing);
+ PlatformMessagePortChannel(MessagePortQueue* incoming, MessagePortQueue* outgoing);
- PassRefPtr<PlatformMessagePortChannel> entangledChannel();
+ RefPtr<PlatformMessagePortChannel> entangledChannel();
void setRemotePort(MessagePort*);
void closeInternal();
- // Mutex used to ensure exclusive access to the object internals.
- Mutex m_mutex;
+ // Lock used to ensure exclusive access to the object internals.
+ Lock m_mutex;
// Pointer to our entangled pair - cleared when close() is called.
RefPtr<PlatformMessagePortChannel> m_entangledChannel;
@@ -107,9 +95,7 @@ namespace WebCore {
RefPtr<MessagePortQueue> m_outgoingQueue;
// The port we are connected to (the remote port) - this is the port that is notified when new messages arrive.
- MessagePort* m_remotePort;
+ MessagePort* m_remotePort { nullptr };
};
} // namespace WebCore
-
-#endif // PlatformMessagePortChannel_h