Title: [160162] trunk/Source/WebKit2
Revision
160162
Author
[email protected]
Date
2013-12-05 00:47:45 -0800 (Thu, 05 Dec 2013)

Log Message

[GTK][WK2] Clean up WorkQueueGtk
https://bugs.webkit.org/show_bug.cgi?id=125177

Reviewed by Carlos Garcia Campos.

Clean up the GTK implementation of the WorkQueue class a bit.
- registerSocketEventHandler doesn't take a condition argument anymore -- G_IO_IN was the only condition ever passed into
that method so that is now the hard-coded default.
- Clean up the declarations of GTK-specific bits in the WorkQueue header file. SocketEventSourceIterator typedef is removed
and auto will be used instead.
- WorkQueue::dispatchOnTermination and WorkQueue::SocketEventSource::performWorkOnTermination methods were unused and now removed.
- WorkQueue::SocketEventSource doesn't expect a GIO condition anymore, and WorkQueue::SocketEventSource::checkCondition is removed.
G_IO_IN condition was the only one used is now hard-coded into the check in WorkQueue::SocketEventSource::eventCallback.
- Removed an unnecessary non-null assertion for the heap-allocated SocketEventSource.
- Removed a technically duplicated assertion that a file descriptor is already present in the event sources map. Moved the
assertion before the HashMap::find() call.
- Removed two unnecessary assertions that non-null values are being returned by g_idle_source_new() and g_timeout_source_new().
Both functions are guaranteed to return non-null values.

* Platform/CoreIPC/unix/ConnectionUnix.cpp:
(CoreIPC::Connection::open):
* Platform/WorkQueue.h:
* Platform/gtk/WorkQueueGtk.cpp:
(WorkQueue::SocketEventSource::SocketEventSource):
(WorkQueue::SocketEventSource::eventCallback):
(WorkQueue::registerSocketEventHandler):
(WorkQueue::unregisterSocketEventHandler):
(WorkQueue::dispatch):
(WorkQueue::dispatchAfterDelay):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (160161 => 160162)


--- trunk/Source/WebKit2/ChangeLog	2013-12-05 07:41:26 UTC (rev 160161)
+++ trunk/Source/WebKit2/ChangeLog	2013-12-05 08:47:45 UTC (rev 160162)
@@ -1,3 +1,35 @@
+2013-12-05  Zan Dobersek  <[email protected]>
+
+        [GTK][WK2] Clean up WorkQueueGtk
+        https://bugs.webkit.org/show_bug.cgi?id=125177
+
+        Reviewed by Carlos Garcia Campos.
+
+        Clean up the GTK implementation of the WorkQueue class a bit.
+        - registerSocketEventHandler doesn't take a condition argument anymore -- G_IO_IN was the only condition ever passed into
+        that method so that is now the hard-coded default.
+        - Clean up the declarations of GTK-specific bits in the WorkQueue header file. SocketEventSourceIterator typedef is removed
+        and auto will be used instead.
+        - WorkQueue::dispatchOnTermination and WorkQueue::SocketEventSource::performWorkOnTermination methods were unused and now removed.
+        - WorkQueue::SocketEventSource doesn't expect a GIO condition anymore, and WorkQueue::SocketEventSource::checkCondition is removed.
+        G_IO_IN condition was the only one used is now hard-coded into the check in WorkQueue::SocketEventSource::eventCallback.
+        - Removed an unnecessary non-null assertion for the heap-allocated SocketEventSource.
+        - Removed a technically duplicated assertion that a file descriptor is already present in the event sources map. Moved the
+        assertion before the HashMap::find() call.
+        - Removed two unnecessary assertions that non-null values are being returned by g_idle_source_new() and g_timeout_source_new().
+        Both functions are guaranteed to return non-null values.
+
+        * Platform/CoreIPC/unix/ConnectionUnix.cpp:
+        (CoreIPC::Connection::open):
+        * Platform/WorkQueue.h:
+        * Platform/gtk/WorkQueueGtk.cpp:
+        (WorkQueue::SocketEventSource::SocketEventSource):
+        (WorkQueue::SocketEventSource::eventCallback):
+        (WorkQueue::registerSocketEventHandler):
+        (WorkQueue::unregisterSocketEventHandler):
+        (WorkQueue::dispatch):
+        (WorkQueue::dispatchAfterDelay):
+
 2013-12-04  Gergo Balogh  <[email protected]>
 
         Report error when #else is used in message receiver generator's input.

Modified: trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp (160161 => 160162)


--- trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp	2013-12-05 07:41:26 UTC (rev 160161)
+++ trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp	2013-12-05 08:47:45 UTC (rev 160162)
@@ -378,7 +378,7 @@
 
     m_isConnected = true;
 #if PLATFORM(GTK)
-    m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, G_IO_IN, WTF::bind(&Connection::readyReadHandler, this), WTF::bind(&Connection::connectionDidClose, this));
+    m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, WTF::bind(&Connection::readyReadHandler, this), WTF::bind(&Connection::connectionDidClose, this));
 #elif PLATFORM(EFL)
     m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, WTF::bind(&Connection::readyReadHandler, this));
 #endif

Modified: trunk/Source/WebKit2/Platform/WorkQueue.h (160161 => 160162)


--- trunk/Source/WebKit2/Platform/WorkQueue.h	2013-12-05 07:41:26 UTC (rev 160161)
+++ trunk/Source/WebKit2/Platform/WorkQueue.h	2013-12-05 08:47:45 UTC (rev 160162)
@@ -64,9 +64,8 @@
 #if OS(DARWIN)
     dispatch_queue_t dispatchQueue() const { return m_dispatchQueue; }
 #elif PLATFORM(GTK)
-    void registerSocketEventHandler(int, int, const Function<void()>& function, const Function<void()>& closeFunction);
+    void registerSocketEventHandler(int, const Function<void()>&, const Function<void()>&);
     void unregisterSocketEventHandler(int);
-    void dispatchOnTermination(WebKit::PlatformProcessIdentifier, const Function<void()>&);
 #elif PLATFORM(EFL)
     void registerSocketEventHandler(int, const Function<void()>&);
     void unregisterSocketEventHandler(int);
@@ -82,6 +81,9 @@
     static void executeFunction(void*);
     dispatch_queue_t m_dispatchQueue;
 #elif PLATFORM(GTK)
+    class EventSource;
+    class SocketEventSource;
+
     static void startWorkQueueThread(WorkQueue*);
     void workQueueThreadBody();
     void dispatchOnSource(GSource*, const Function<void()>&, GSourceFunc);
@@ -91,10 +93,7 @@
     Mutex m_eventLoopLock;
     GRefPtr<GMainLoop> m_eventLoop;
     Mutex m_eventSourcesLock;
-    class EventSource;
-    class SocketEventSource;
     HashMap<int, Vector<SocketEventSource*>> m_eventSources;
-    typedef HashMap<int, Vector<SocketEventSource*>>::iterator SocketEventSourceIterator;
 #elif PLATFORM(EFL)
     RefPtr<DispatchQueue> m_dispatchQueue;
 #endif

Modified: trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp (160161 => 160162)


--- trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp	2013-12-05 07:41:26 UTC (rev 160161)
+++ trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp	2013-12-05 08:47:45 UTC (rev 160162)
@@ -56,13 +56,6 @@
         return FALSE;
     }
 
-    static gboolean performWorkOnTermination(GPid, gint, EventSource* eventSource)
-    {
-        ASSERT(eventSource);
-        eventSource->performWork();
-        return FALSE;
-    }
-
     static void deleteEventSource(EventSource* eventSource)
     {
         ASSERT(eventSource);
@@ -76,9 +69,8 @@
 
 class WorkQueue::SocketEventSource : public WorkQueue::EventSource {
 public:
-    SocketEventSource(const Function<void()>& function, WorkQueue* workQueue, int condition, GCancellable* cancellable, const Function<void()>& closeFunction)
+    SocketEventSource(const Function<void()>& function, WorkQueue* workQueue, GCancellable* cancellable, const Function<void()>& closeFunction)
         : EventSource(function, workQueue)
-        , m_condition(condition)
         , m_cancellable(cancellable)
         , m_closeFunction(closeFunction)
     {
@@ -95,13 +87,8 @@
         m_closeFunction();
     }
 
-    bool checkCondition(GIOCondition condition) const
+    static gboolean eventCallback(GSocket* socket, GIOCondition condition, SocketEventSource* eventSource)
     {
-        return condition & m_condition;
-    }
-
-    static gboolean eventCallback(GSocket*, GIOCondition condition, SocketEventSource* eventSource)
-    {
         ASSERT(eventSource);
 
         if (condition & G_IO_HUP || condition & G_IO_ERR) {
@@ -109,7 +96,7 @@
             return FALSE;
         }
 
-        if (eventSource->checkCondition(condition)) {
+        if (condition & G_IO_IN) {
             eventSource->performWork();
             return TRUE;
         }
@@ -119,7 +106,6 @@
     }
 
 private:
-    int m_condition;
     GCancellable* m_cancellable;
     Function<void()> m_closeFunction;
 };
@@ -173,15 +159,14 @@
     g_main_loop_run(m_eventLoop.get());
 }
 
-void WorkQueue::registerSocketEventHandler(int fileDescriptor, int condition, const Function<void()>& function, const Function<void()>& closeFunction)
+void WorkQueue::registerSocketEventHandler(int fileDescriptor, const Function<void()>& function, const Function<void()>& closeFunction)
 {
     GRefPtr<GSocket> socket = adoptGRef(g_socket_new_from_fd(fileDescriptor, 0));
     ASSERT(socket);
     GRefPtr<GCancellable> cancellable = adoptGRef(g_cancellable_new());
-    GRefPtr<GSource> dispatchSource = adoptGRef(g_socket_create_source(socket.get(), static_cast<GIOCondition>(condition), cancellable.get()));
+    GRefPtr<GSource> dispatchSource = adoptGRef(g_socket_create_source(socket.get(), G_IO_IN, cancellable.get()));
     ASSERT(dispatchSource);
-    SocketEventSource* eventSource = new SocketEventSource(function, this, condition, cancellable.get(), closeFunction);
-    ASSERT(eventSource);
+    SocketEventSource* eventSource = new SocketEventSource(function, this, cancellable.get(), closeFunction);
 
     g_source_set_callback(dispatchSource.get(), reinterpret_cast<GSourceFunc>(&WorkQueue::SocketEventSource::eventCallback),
         eventSource, reinterpret_cast<GDestroyNotify>(&WorkQueue::EventSource::deleteEventSource));
@@ -190,7 +175,7 @@
     {
         MutexLocker locker(m_eventSourcesLock);
         Vector<SocketEventSource*> sources;
-        SocketEventSourceIterator it = m_eventSources.find(fileDescriptor);
+        auto it = m_eventSources.find(fileDescriptor);
         if (it != m_eventSources.end())
             sources = it->value;
 
@@ -207,9 +192,8 @@
 
     MutexLocker locker(m_eventSourcesLock);
 
-    SocketEventSourceIterator it = m_eventSources.find(fileDescriptor);
-    ASSERT(it != m_eventSources.end());
     ASSERT(m_eventSources.contains(fileDescriptor));
+    auto it = m_eventSources.find(fileDescriptor);
 
     if (it != m_eventSources.end()) {
         Vector<SocketEventSource*> sources = it->value;
@@ -231,24 +215,12 @@
 void WorkQueue::dispatch(const Function<void()>& function)
 {
     GRefPtr<GSource> dispatchSource = adoptGRef(g_idle_source_new());
-    ASSERT(dispatchSource);
     g_source_set_priority(dispatchSource.get(), G_PRIORITY_DEFAULT);
-
     dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce));
 }
 
 void WorkQueue::dispatchAfterDelay(const Function<void()>& function, double delay)
 {
     GRefPtr<GSource> dispatchSource = adoptGRef(g_timeout_source_new(static_cast<guint>(delay * 1000)));
-    ASSERT(dispatchSource);
-
     dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce));
 }
-
-void WorkQueue::dispatchOnTermination(WebKit::PlatformProcessIdentifier process, const Function<void()>& function)
-{
-    GRefPtr<GSource> dispatchSource = adoptGRef(g_child_watch_source_new(process));
-    ASSERT(dispatchSource);
-
-    dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnTermination));
-}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to