Title: [102954] trunk/Source/WebKit2
Revision
102954
Author
[email protected]
Date
2011-12-15 10:15:14 -0800 (Thu, 15 Dec 2011)

Log Message

Move WorkQueue Mach handlers over to WTF::Function
https://bugs.webkit.org/show_bug.cgi?id=74620

Reviewed by Sam Weinig.

* Platform/CoreIPC/mac/ConnectionMac.cpp:
(CoreIPC::Connection::open):
(CoreIPC::Connection::initializeDeadNameSource):
* Platform/WorkQueue.h:
* Platform/mac/WorkQueueMac.cpp:
(WorkQueue::EventSource::EventSource):
(WorkQueue::EventSource::eventHandler):
(WorkQueue::registerMachPortEventHandler):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (102953 => 102954)


--- trunk/Source/WebKit2/ChangeLog	2011-12-15 18:05:19 UTC (rev 102953)
+++ trunk/Source/WebKit2/ChangeLog	2011-12-15 18:15:14 UTC (rev 102954)
@@ -1,3 +1,19 @@
+2011-12-15  Anders Carlsson  <[email protected]>
+
+        Move WorkQueue Mach handlers over to WTF::Function
+        https://bugs.webkit.org/show_bug.cgi?id=74620
+
+        Reviewed by Sam Weinig.
+
+        * Platform/CoreIPC/mac/ConnectionMac.cpp:
+        (CoreIPC::Connection::open):
+        (CoreIPC::Connection::initializeDeadNameSource):
+        * Platform/WorkQueue.h:
+        * Platform/mac/WorkQueueMac.cpp:
+        (WorkQueue::EventSource::EventSource):
+        (WorkQueue::EventSource::eventHandler):
+        (WorkQueue::registerMachPortEventHandler):
+
 2011-12-14  Anders Carlsson  <[email protected]>
 
         Add WTF::Function to wtf/Forward.h

Modified: trunk/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp (102953 => 102954)


--- trunk/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp	2011-12-15 18:05:19 UTC (rev 102953)
+++ trunk/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp	2011-12-15 18:15:14 UTC (rev 102954)
@@ -104,11 +104,11 @@
     setMachPortQueueLength(m_receivePort, MACH_PORT_QLIMIT_LARGE);
 
     // Register the data available handler.
-    m_connectionQueue.registerMachPortEventHandler(m_receivePort, WorkQueue::MachPortDataAvailable, WorkItem::create(this, &Connection::receiveSourceEventHandler));
+    m_connectionQueue.registerMachPortEventHandler(m_receivePort, WorkQueue::MachPortDataAvailable, bind(&Connection::receiveSourceEventHandler, this));
 
     // If we have an exception port, register the data available handler and send over the port to the other end.
     if (m_exceptionPort) {
-        m_connectionQueue.registerMachPortEventHandler(m_exceptionPort, WorkQueue::MachPortDataAvailable, WorkItem::create(this, &Connection::exceptionSourceEventHandler));
+        m_connectionQueue.registerMachPortEventHandler(m_exceptionPort, WorkQueue::MachPortDataAvailable, bind(&Connection::exceptionSourceEventHandler, this));
 
         deprecatedSend(CoreIPCMessage::SetExceptionPort, 0, MachPort(m_exceptionPort, MACH_MSG_TYPE_MAKE_SEND));
     }
@@ -225,7 +225,7 @@
 
 void Connection::initializeDeadNameSource()
 {
-    m_connectionQueue.registerMachPortEventHandler(m_sendPort, WorkQueue::MachPortDeadNameNotification, WorkItem::create(this, &Connection::connectionDidClose));
+    m_connectionQueue.registerMachPortEventHandler(m_sendPort, WorkQueue::MachPortDeadNameNotification, bind(&Connection::connectionDidClose, this));
 }
 
 static PassOwnPtr<ArgumentDecoder> createArgumentDecoder(mach_msg_header_t* header)

Modified: trunk/Source/WebKit2/Platform/WorkQueue.h (102953 => 102954)


--- trunk/Source/WebKit2/Platform/WorkQueue.h	2011-12-15 18:05:19 UTC (rev 102953)
+++ trunk/Source/WebKit2/Platform/WorkQueue.h	2011-12-15 18:15:14 UTC (rev 102954)
@@ -87,9 +87,9 @@
         MachPortDeadNameNotification
     };
     
-    // Will execute the given work item whenever the given mach port event fires.
+    // Will execute the given function whenever the given mach port event fires.
     // Note that this will adopt the mach port and destroy it when the work queue is invalidated.
-    void registerMachPortEventHandler(mach_port_t, MachPortEventType, PassOwnPtr<WorkItem>);
+    void registerMachPortEventHandler(mach_port_t, MachPortEventType, const Function<void()>&);
     void unregisterMachPortEventHandler(mach_port_t);
 #elif PLATFORM(WIN)
     void registerHandle(HANDLE, PassOwnPtr<WorkItem>);

Modified: trunk/Source/WebKit2/Platform/mac/WorkQueueMac.cpp (102953 => 102954)


--- trunk/Source/WebKit2/Platform/mac/WorkQueueMac.cpp	2011-12-15 18:05:19 UTC (rev 102953)
+++ trunk/Source/WebKit2/Platform/mac/WorkQueueMac.cpp	2011-12-15 18:15:14 UTC (rev 102954)
@@ -60,10 +60,10 @@
 
 class WorkQueue::EventSource {
 public:
-    EventSource(MachPortEventType eventType, dispatch_source_t dispatchSource, PassOwnPtr<WorkItem> workItem)
+    EventSource(MachPortEventType eventType, dispatch_source_t dispatchSource, const Function<void()>& function)
         : m_eventType(eventType)
         , m_dispatchSource(dispatchSource)
-        , m_workItem(workItem)
+        , m_function(function)
     {
     }
     
@@ -73,7 +73,7 @@
     {
         EventSource* eventSource = static_cast<EventSource*>(source);
         
-        eventSource->m_workItem->execute();
+        eventSource->m_function();
     }
     
     static void cancelHandler(void* source)
@@ -106,11 +106,11 @@
     
     // This is a weak reference, since m_dispatchSource references the event source.
     dispatch_source_t m_dispatchSource;
-    
-    OwnPtr<WorkItem> m_workItem;
+
+    Function<void()> m_function;
 };
 
-void WorkQueue::registerMachPortEventHandler(mach_port_t machPort, MachPortEventType eventType, PassOwnPtr<WorkItem> workItem)
+void WorkQueue::registerMachPortEventHandler(mach_port_t machPort, MachPortEventType eventType, const Function<void()>& function)
 {
     dispatch_source_type_t sourceType = 0;
     switch (eventType) {
@@ -124,7 +124,7 @@
     
     dispatch_source_t dispatchSource = dispatch_source_create(sourceType, machPort, 0, m_dispatchQueue);
     
-    EventSource* eventSource = new EventSource(eventType, dispatchSource, workItem);
+    EventSource* eventSource = new EventSource(eventType, dispatchSource, function);
     dispatch_set_context(dispatchSource, eventSource);
     
     dispatch_source_set_event_handler_f(dispatchSource, &EventSource::eventHandler);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to