Rename the connection sources to better indicate what data direction they are used for
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Dec 2016 22:30:58 +0000 (22:30 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Dec 2016 22:30:58 +0000 (22:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165548

Reviewed by Tim Horton.

* Platform/IPC/Connection.h:
* Platform/IPC/mac/ConnectionMac.mm:
(IPC::Connection::platformInvalidate):
(IPC::Connection::platformInitialize):
(IPC::createReceiveSource):
(IPC::Connection::initializeSendSource):
(IPC::Connection::receiveSourceEventHandler):
(IPC::createDataAvailableSource): Deleted.
(IPC::Connection::initializeDeadNameSource): Deleted.
Rename m_deadNameSource to m_sendSource, and m_receivePortDataAvailableSource to m_receiveSource.

(IPC::Connection::open):
Initialize the send source before we attempt to send a first message.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209481 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/Platform/IPC/Connection.h
Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm

index 4e0e3b6..6dd47f5 100644 (file)
@@ -1,3 +1,24 @@
+2016-12-07  Anders Carlsson  <andersca@apple.com>
+
+        Rename the connection sources to better indicate what data direction they are used for
+        https://bugs.webkit.org/show_bug.cgi?id=165548
+
+        Reviewed by Tim Horton.
+
+        * Platform/IPC/Connection.h:
+        * Platform/IPC/mac/ConnectionMac.mm:
+        (IPC::Connection::platformInvalidate):
+        (IPC::Connection::platformInitialize):
+        (IPC::createReceiveSource):
+        (IPC::Connection::initializeSendSource):
+        (IPC::Connection::receiveSourceEventHandler):
+        (IPC::createDataAvailableSource): Deleted.
+        (IPC::Connection::initializeDeadNameSource): Deleted.
+        Rename m_deadNameSource to m_sendSource, and m_receivePortDataAvailableSource to m_receiveSource.
+
+        (IPC::Connection::open):
+        Initialize the send source before we attempt to send a first message.
+
 2016-12-07  Simon Fraser  <simon.fraser@apple.com>
 
         Fix use of enum in a WK2 C SPI header.
index f012a01..892d9b0 100644 (file)
@@ -312,13 +312,13 @@ private:
 #elif OS(DARWIN)
     // Called on the connection queue.
     void receiveSourceEventHandler();
-    void initializeDeadNameSource();
+    void initializeSendSource();
 
     mach_port_t m_sendPort;
-    dispatch_source_t m_deadNameSource;
+    dispatch_source_t m_sendSource;
 
     mach_port_t m_receivePort;
-    dispatch_source_t m_receivePortDataAvailableSource;
+    dispatch_source_t m_receiveSource;
 
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 101000
     void exceptionSourceEventHandler();
index 0b668b7..12778a5 100644 (file)
@@ -132,14 +132,14 @@ void Connection::platformInvalidate()
     ASSERT(m_receivePort);
 
     // Unregister our ports.
-    dispatch_source_cancel(m_deadNameSource);
-    dispatch_release(m_deadNameSource);
-    m_deadNameSource = 0;
+    dispatch_source_cancel(m_sendSource);
+    dispatch_release(m_sendSource);
+    m_sendSource = 0;
     m_sendPort = MACH_PORT_NULL;
 
-    dispatch_source_cancel(m_receivePortDataAvailableSource);
-    dispatch_release(m_receivePortDataAvailableSource);
-    m_receivePortDataAvailableSource = 0;
+    dispatch_source_cancel(m_receiveSource);
+    dispatch_release(m_receiveSource);
+    m_receiveSource = 0;
     m_receivePort = MACH_PORT_NULL;
 
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 101000
@@ -173,14 +173,14 @@ void Connection::platformInitialize(Identifier identifier)
         m_sendPort = identifier.port;
     }
 
-    m_deadNameSource = nullptr;
-    m_receivePortDataAvailableSource = nullptr;
+    m_sendSource = nullptr;
+    m_receiveSource = nullptr;
 
     m_xpcConnection = identifier.xpcConnection;
 }
 
 template<typename Function>
-static dispatch_source_t createDataAvailableSource(mach_port_t receivePort, WorkQueue& workQueue, Function&& function)
+static dispatch_source_t createReceiveSource(mach_port_t receivePort, WorkQueue& workQueue, Function&& function)
 {
     dispatch_source_t source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, receivePort, 0, workQueue.dispatchQueue());
     dispatch_source_set_event_handler(source, function);
@@ -215,9 +215,9 @@ bool Connection::open()
         auto encoder = std::make_unique<Encoder>("IPC", "InitializeConnection", 0);
         encoder->encode(MachPort(m_receivePort, MACH_MSG_TYPE_MAKE_SEND));
 
-        sendMessage(WTFMove(encoder), { });
+        initializeSendSource();
 
-        initializeDeadNameSource();
+        sendMessage(WTFMove(encoder), { });
     }
 
     // Change the message queue length for the receive port.
@@ -225,7 +225,7 @@ bool Connection::open()
 
     // Register the data available handler.
     RefPtr<Connection> connection(this);
-    m_receivePortDataAvailableSource = createDataAvailableSource(m_receivePort, m_connectionQueue, [connection] {
+    m_receiveSource = createReceiveSource(m_receivePort, m_connectionQueue, [connection] {
         connection->receiveSourceEventHandler();
     });
 
@@ -244,10 +244,10 @@ bool Connection::open()
 
     ref();
     dispatch_async(m_connectionQueue->dispatchQueue(), ^{
-        dispatch_resume(m_receivePortDataAvailableSource);
+        dispatch_resume(m_receiveSource);
 
-        if (m_deadNameSource)
-            dispatch_resume(m_deadNameSource);
+        if (m_sendSource)
+            dispatch_resume(m_sendSource);
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 101000
         if (m_exceptionPortDataAvailableSource)
             dispatch_resume(m_exceptionPortDataAvailableSource);
@@ -356,17 +356,17 @@ bool Connection::sendOutgoingMessage(std::unique_ptr<Encoder> encoder)
     return true;
 }
 
-void Connection::initializeDeadNameSource()
+void Connection::initializeSendSource()
 {
-    m_deadNameSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_SEND, m_sendPort, 0, m_connectionQueue->dispatchQueue());
+    m_sendSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_SEND, m_sendPort, 0, m_connectionQueue->dispatchQueue());
 
     RefPtr<Connection> connection(this);
-    dispatch_source_set_event_handler(m_deadNameSource, [connection] {
+    dispatch_source_set_event_handler(m_sendSource, [connection] {
         connection->connectionDidClose();
     });
 
     mach_port_t sendPort = m_sendPort;
-    dispatch_source_set_cancel_handler(m_deadNameSource, ^{
+    dispatch_source_set_cancel_handler(m_sendSource, ^{
         // Release our send right.
         mach_port_deallocate(mach_task_self(), sendPort);
     });
@@ -510,8 +510,8 @@ void Connection::receiveSourceEventHandler()
             if (previousNotificationPort != MACH_PORT_NULL)
                 mach_port_deallocate(mach_task_self(), previousNotificationPort);
 
-            initializeDeadNameSource();
-            dispatch_resume(m_deadNameSource);
+            initializeSendSource();
+            dispatch_resume(m_sendSource);
         }
 
         m_isConnected = true;