Title: [252209] trunk/Source/WebCore
Revision
252209
Author
[email protected]
Date
2019-11-07 15:16:07 -0800 (Thu, 07 Nov 2019)

Log Message

Port MessagePort to the HTML5 event loop
https://bugs.webkit.org/show_bug.cgi?id=203960

Reviewed by Ryosuke Niwa.

* dom/MessagePort.cpp:
(WebCore::MessagePort::MessagePort):
(WebCore::MessagePort::close):
(WebCore::MessagePort::dispatchMessages):
(WebCore::MessagePort::dispatchEvent):
* dom/MessagePort.h:
* dom/TaskSource.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (252208 => 252209)


--- trunk/Source/WebCore/ChangeLog	2019-11-07 23:01:20 UTC (rev 252208)
+++ trunk/Source/WebCore/ChangeLog	2019-11-07 23:16:07 UTC (rev 252209)
@@ -1,3 +1,18 @@
+2019-11-07  Chris Dumez  <[email protected]>
+
+        Port MessagePort to the HTML5 event loop
+        https://bugs.webkit.org/show_bug.cgi?id=203960
+
+        Reviewed by Ryosuke Niwa.
+
+        * dom/MessagePort.cpp:
+        (WebCore::MessagePort::MessagePort):
+        (WebCore::MessagePort::close):
+        (WebCore::MessagePort::dispatchMessages):
+        (WebCore::MessagePort::dispatchEvent):
+        * dom/MessagePort.h:
+        * dom/TaskSource.h:
+
 2019-11-07  Antti Koivisto  <[email protected]>
 
         Factor matched declarations cache into a class

Modified: trunk/Source/WebCore/dom/MessagePort.cpp (252208 => 252209)


--- trunk/Source/WebCore/dom/MessagePort.cpp	2019-11-07 23:01:20 UTC (rev 252208)
+++ trunk/Source/WebCore/dom/MessagePort.cpp	2019-11-07 23:16:07 UTC (rev 252209)
@@ -98,7 +98,6 @@
     : ActiveDOMObject(&scriptExecutionContext)
     , m_identifier(local)
     , m_remoteIdentifier(remote)
-    , m_eventQueue(GenericEventQueue::create(*this))
 {
     LOG(MessagePorts, "Created MessagePort %s (%p) in process %" PRIu64, m_identifier.logString().utf8().data(), this, Process::identifier().toUInt64());
 
@@ -235,7 +234,6 @@
     }
 
     removeAllEventListeners();
-    m_eventQueue->close();
 }
 
 void MessagePort::contextDestroyed()
@@ -277,7 +275,8 @@
             if (contextIsWorker && downcast<WorkerGlobalScope>(*m_scriptExecutionContext).isClosing())
                 return;
             auto ports = MessagePort::entanglePorts(*m_scriptExecutionContext, WTFMove(message.transferredPorts));
-            m_eventQueue->enqueueEvent(MessageEvent::create(WTFMove(ports), message.message.releaseNonNull()));
+            // Per specification, each MessagePort object has a task source called the port message queue.
+            queueTaskToDispatchEvent(*this, TaskSource::PostedMessageQueue, MessageEvent::create(WTFMove(ports), message.message.releaseNonNull()));
         }
     };
 
@@ -284,6 +283,14 @@
     MessagePortChannelProvider::fromContext(*m_scriptExecutionContext).takeAllMessagesForPort(m_identifier, WTFMove(messagesTakenHandler));
 }
 
+void MessagePort::dispatchEvent(Event& event)
+{
+    if (m_closed)
+        return;
+
+    EventTarget::dispatchEvent(event);
+}
+
 void MessagePort::updateActivity(MessagePortChannelProvider::HasActivity hasActivity)
 {
     bool hasHadLocalActivity = m_hasHadLocalActivitySinceLastCheck;

Modified: trunk/Source/WebCore/dom/MessagePort.h (252208 => 252209)


--- trunk/Source/WebCore/dom/MessagePort.h	2019-11-07 23:01:20 UTC (rev 252208)
+++ trunk/Source/WebCore/dom/MessagePort.h	2019-11-07 23:16:07 UTC (rev 252209)
@@ -29,7 +29,6 @@
 #include "ActiveDOMObject.h"
 #include "EventTarget.h"
 #include "ExceptionOr.h"
-#include "GenericEventQueue.h"
 #include "MessagePortChannel.h"
 #include "MessagePortIdentifier.h"
 #include "MessageWithMessagePorts.h"
@@ -96,6 +95,8 @@
     void refEventTarget() final { ref(); }
     void derefEventTarget() final { deref(); }
 
+    void dispatchEvent(Event&) final;
+
 private:
     explicit MessagePort(ScriptExecutionContext&, const MessagePortIdentifier& local, const MessagePortIdentifier& remote);
 
@@ -126,7 +127,6 @@
     MessagePortIdentifier m_remoteIdentifier;
 
     mutable std::atomic<unsigned> m_refCount { 1 };
-    UniqueRef<GenericEventQueue> m_eventQueue;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/TaskSource.h (252208 => 252209)


--- trunk/Source/WebCore/dom/TaskSource.h	2019-11-07 23:01:20 UTC (rev 252208)
+++ trunk/Source/WebCore/dom/TaskSource.h	2019-11-07 23:16:07 UTC (rev 252209)
@@ -33,6 +33,7 @@
     FontLoading,
     IdleTask,
     Networking,
+    PostedMessageQueue,
     UserInteraction
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to