Inline createReceiveSource in its two call sites
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Feb 2017 20:28:40 +0000 (20:28 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Feb 2017 20:28:40 +0000 (20:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167809

Reviewed by Alex Christensen.

* Platform/IPC/mac/ConnectionMac.mm:
(IPC::Connection::open):
(IPC::createReceiveSource): Deleted.

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

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

index 34c5ff9..6794092 100644 (file)
@@ -1,3 +1,14 @@
+2017-02-03  Anders Carlsson  <andersca@apple.com>
+
+        Inline createReceiveSource in its two call sites
+        https://bugs.webkit.org/show_bug.cgi?id=167809
+
+        Reviewed by Alex Christensen.
+
+        * Platform/IPC/mac/ConnectionMac.mm:
+        (IPC::Connection::open):
+        (IPC::createReceiveSource): Deleted.
+
 2017-02-03  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         WKActionSheet should dismiss with animation when done with the sheet
index 72b3aa8..e8e746c 100644 (file)
@@ -181,19 +181,6 @@ void Connection::platformInitialize(Identifier identifier)
     m_xpcConnection = identifier.xpcConnection;
 }
 
-template<typename 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);
-
-    dispatch_source_set_cancel_handler(source, ^{
-        mach_port_mod_refs(mach_task_self(), receivePort, MACH_PORT_RIGHT_RECEIVE, -1);
-    });
-
-    return source;
-}
-
 bool Connection::open()
 {
     if (m_isServer) {
@@ -225,17 +212,24 @@ bool Connection::open()
     // Change the message queue length for the receive port.
     setMachPortQueueLength(m_receivePort, MACH_PORT_QLIMIT_LARGE);
 
-    // Register the data available handler.
     RefPtr<Connection> connection(this);
-    m_receiveSource = createReceiveSource(m_receivePort, m_connectionQueue, [connection] {
+    m_receiveSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, m_receivePort, 0, m_connectionQueue->dispatchQueue());
+    dispatch_source_set_event_handler(m_receiveSource, [connection] {
         connection->receiveSourceEventHandler();
     });
+    dispatch_source_set_cancel_handler(m_receiveSource, [connection] {
+        mach_port_mod_refs(mach_task_self(), connection->m_receivePort, MACH_PORT_RIGHT_RECEIVE, -1);
+    });
 
 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED <= 101000
     if (m_exceptionPort) {
-        m_exceptionPortDataAvailableSource = createReceiveSource(m_exceptionPort, m_connectionQueue, [connection] {
+        m_exceptionPortDataAvailableSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, m_exceptionPort, 0, m_connectionQueue->dispatchQueue());
+        dispatch_source_set_event_handler(m_exceptionPortDataAvailableSource, [connection] {
             connection->exceptionSourceEventHandler();
         });
+        dispatch_source_set_cancel_handler(m_exceptionPortDataAvailableSource, [connection] {
+            mach_port_mod_refs(mach_task_self(), connection->m_exceptionPort, MACH_PORT_RIGHT_RECEIVE, -1);
+        });
 
         auto encoder = std::make_unique<Encoder>("IPC", "SetExceptionPort", 0);
         encoder->encode(MachPort(m_exceptionPort, MACH_MSG_TYPE_MAKE_SEND));