summaryrefslogtreecommitdiff
path: root/Source/WebCore/dom/MessagePortChannel.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/dom/MessagePortChannel.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/dom/MessagePortChannel.h')
-rw-r--r--Source/WebCore/dom/MessagePortChannel.h34
1 files changed, 20 insertions, 14 deletions
diff --git a/Source/WebCore/dom/MessagePortChannel.h b/Source/WebCore/dom/MessagePortChannel.h
index 9e1b7cba6..60ed6f836 100644
--- a/Source/WebCore/dom/MessagePortChannel.h
+++ b/Source/WebCore/dom/MessagePortChannel.h
@@ -28,15 +28,12 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef MessagePortChannel_h
-#define MessagePortChannel_h
+#pragma once
#include "SerializedScriptValue.h"
-#include <wtf/OwnPtr.h>
+#include <memory>
+#include <wtf/Deque.h>
#include <wtf/Forward.h>
-#include <wtf/PassOwnPtr.h>
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/text/WTFString.h>
@@ -46,17 +43,27 @@ namespace WebCore {
class MessagePortChannel;
class PlatformMessagePortChannel;
class ScriptExecutionContext;
- 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:
- static void createChannel(PassRefPtr<MessagePort>, PassRefPtr<MessagePort>);
+ struct EventData {
+ EventData(Ref<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray>&& channels)
+ : message(WTFMove(message))
+ , channels(WTFMove(channels))
+ { }
+
+ Ref<SerializedScriptValue> message;
+ std::unique_ptr<MessagePortChannelArray> channels;
+ };
+
+ explicit MessagePortChannel(RefPtr<PlatformMessagePortChannel>&&);
+ static void createChannel(MessagePort*, 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).
// Returns false if the entanglement failed because the port was closed.
@@ -75,10 +82,12 @@ namespace WebCore {
bool hasPendingActivity();
// Sends a message and optional cloned port to the remote port.
- void postMessageToRemote(PassRefPtr<SerializedScriptValue>, PassOwnPtr<MessagePortChannelArray>);
+ void postMessageToRemote(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>);
// Extracts a message from the message queue for this port.
- bool tryGetMessageFromRemote(RefPtr<SerializedScriptValue>&, OwnPtr<MessagePortChannelArray>&);
+ std::unique_ptr<EventData> takeMessageFromRemote();
+
+ Deque<std::unique_ptr<EventData>> takeAllMessagesFromRemote();
// Returns the entangled port if run by the same thread (see MessagePort::locallyEntangledPort() for more details).
MessagePort* locallyEntangledPort(const ScriptExecutionContext*);
@@ -86,10 +95,7 @@ namespace WebCore {
~MessagePortChannel();
private:
- explicit MessagePortChannel(PassRefPtr<PlatformMessagePortChannel>);
RefPtr<PlatformMessagePortChannel> m_channel;
};
} // namespace WebCore
-
-#endif // MessagePortChannel_h