Changeset 160162 in webkit


Ignore:
Timestamp:
Dec 5, 2013 12:47:45 AM (10 years ago)
Author:
zandobersek@gmail.com
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):

Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r160161 r160162  
     12013-12-05  Zan Dobersek  <zdobersek@igalia.com>
     2
     3        [GTK][WK2] Clean up WorkQueueGtk
     4        https://bugs.webkit.org/show_bug.cgi?id=125177
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Clean up the GTK implementation of the WorkQueue class a bit.
     9        - registerSocketEventHandler doesn't take a condition argument anymore -- G_IO_IN was the only condition ever passed into
     10        that method so that is now the hard-coded default.
     11        - Clean up the declarations of GTK-specific bits in the WorkQueue header file. SocketEventSourceIterator typedef is removed
     12        and auto will be used instead.
     13        - WorkQueue::dispatchOnTermination and WorkQueue::SocketEventSource::performWorkOnTermination methods were unused and now removed.
     14        - WorkQueue::SocketEventSource doesn't expect a GIO condition anymore, and WorkQueue::SocketEventSource::checkCondition is removed.
     15        G_IO_IN condition was the only one used is now hard-coded into the check in WorkQueue::SocketEventSource::eventCallback.
     16        - Removed an unnecessary non-null assertion for the heap-allocated SocketEventSource.
     17        - Removed a technically duplicated assertion that a file descriptor is already present in the event sources map. Moved the
     18        assertion before the HashMap::find() call.
     19        - Removed two unnecessary assertions that non-null values are being returned by g_idle_source_new() and g_timeout_source_new().
     20        Both functions are guaranteed to return non-null values.
     21
     22        * Platform/CoreIPC/unix/ConnectionUnix.cpp:
     23        (CoreIPC::Connection::open):
     24        * Platform/WorkQueue.h:
     25        * Platform/gtk/WorkQueueGtk.cpp:
     26        (WorkQueue::SocketEventSource::SocketEventSource):
     27        (WorkQueue::SocketEventSource::eventCallback):
     28        (WorkQueue::registerSocketEventHandler):
     29        (WorkQueue::unregisterSocketEventHandler):
     30        (WorkQueue::dispatch):
     31        (WorkQueue::dispatchAfterDelay):
     32
    1332013-12-04  Gergo Balogh  <geryxyz@inf.u-szeged.hu>
    234
  • trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp

    r156887 r160162  
    379379    m_isConnected = true;
    380380#if PLATFORM(GTK)
    381     m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, G_IO_IN, WTF::bind(&Connection::readyReadHandler, this), WTF::bind(&Connection::connectionDidClose, this));
     381    m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, WTF::bind(&Connection::readyReadHandler, this), WTF::bind(&Connection::connectionDidClose, this));
    382382#elif PLATFORM(EFL)
    383383    m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, WTF::bind(&Connection::readyReadHandler, this));
  • trunk/Source/WebKit2/Platform/WorkQueue.h

    r157894 r160162  
    6565    dispatch_queue_t dispatchQueue() const { return m_dispatchQueue; }
    6666#elif PLATFORM(GTK)
    67     void registerSocketEventHandler(int, int, const Function<void()>& function, const Function<void()>& closeFunction);
     67    void registerSocketEventHandler(int, const Function<void()>&, const Function<void()>&);
    6868    void unregisterSocketEventHandler(int);
    69     void dispatchOnTermination(WebKit::PlatformProcessIdentifier, const Function<void()>&);
    7069#elif PLATFORM(EFL)
    7170    void registerSocketEventHandler(int, const Function<void()>&);
     
    8382    dispatch_queue_t m_dispatchQueue;
    8483#elif PLATFORM(GTK)
     84    class EventSource;
     85    class SocketEventSource;
     86
    8587    static void startWorkQueueThread(WorkQueue*);
    8688    void workQueueThreadBody();
     
    9294    GRefPtr<GMainLoop> m_eventLoop;
    9395    Mutex m_eventSourcesLock;
    94     class EventSource;
    95     class SocketEventSource;
    9696    HashMap<int, Vector<SocketEventSource*>> m_eventSources;
    97     typedef HashMap<int, Vector<SocketEventSource*>>::iterator SocketEventSourceIterator;
    9897#elif PLATFORM(EFL)
    9998    RefPtr<DispatchQueue> m_dispatchQueue;
  • trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp

    r159882 r160162  
    5757    }
    5858
    59     static gboolean performWorkOnTermination(GPid, gint, EventSource* eventSource)
    60     {
    61         ASSERT(eventSource);
    62         eventSource->performWork();
    63         return FALSE;
    64     }
    65 
    6659    static void deleteEventSource(EventSource* eventSource)
    6760    {
     
    7770class WorkQueue::SocketEventSource : public WorkQueue::EventSource {
    7871public:
    79     SocketEventSource(const Function<void()>& function, WorkQueue* workQueue, int condition, GCancellable* cancellable, const Function<void()>& closeFunction)
     72    SocketEventSource(const Function<void()>& function, WorkQueue* workQueue, GCancellable* cancellable, const Function<void()>& closeFunction)
    8073        : EventSource(function, workQueue)
    81         , m_condition(condition)
    8274        , m_cancellable(cancellable)
    8375        , m_closeFunction(closeFunction)
     
    9688    }
    9789
    98     bool checkCondition(GIOCondition condition) const
    99     {
    100         return condition & m_condition;
    101     }
    102 
    103     static gboolean eventCallback(GSocket*, GIOCondition condition, SocketEventSource* eventSource)
     90    static gboolean eventCallback(GSocket* socket, GIOCondition condition, SocketEventSource* eventSource)
    10491    {
    10592        ASSERT(eventSource);
     
    11097        }
    11198
    112         if (eventSource->checkCondition(condition)) {
     99        if (condition & G_IO_IN) {
    113100            eventSource->performWork();
    114101            return TRUE;
     
    120107
    121108private:
    122     int m_condition;
    123109    GCancellable* m_cancellable;
    124110    Function<void()> m_closeFunction;
     
    174160}
    175161
    176 void WorkQueue::registerSocketEventHandler(int fileDescriptor, int condition, const Function<void()>& function, const Function<void()>& closeFunction)
     162void WorkQueue::registerSocketEventHandler(int fileDescriptor, const Function<void()>& function, const Function<void()>& closeFunction)
    177163{
    178164    GRefPtr<GSocket> socket = adoptGRef(g_socket_new_from_fd(fileDescriptor, 0));
    179165    ASSERT(socket);
    180166    GRefPtr<GCancellable> cancellable = adoptGRef(g_cancellable_new());
    181     GRefPtr<GSource> dispatchSource = adoptGRef(g_socket_create_source(socket.get(), static_cast<GIOCondition>(condition), cancellable.get()));
     167    GRefPtr<GSource> dispatchSource = adoptGRef(g_socket_create_source(socket.get(), G_IO_IN, cancellable.get()));
    182168    ASSERT(dispatchSource);
    183     SocketEventSource* eventSource = new SocketEventSource(function, this, condition, cancellable.get(), closeFunction);
    184     ASSERT(eventSource);
     169    SocketEventSource* eventSource = new SocketEventSource(function, this, cancellable.get(), closeFunction);
    185170
    186171    g_source_set_callback(dispatchSource.get(), reinterpret_cast<GSourceFunc>(&WorkQueue::SocketEventSource::eventCallback),
     
    191176        MutexLocker locker(m_eventSourcesLock);
    192177        Vector<SocketEventSource*> sources;
    193         SocketEventSourceIterator it = m_eventSources.find(fileDescriptor);
     178        auto it = m_eventSources.find(fileDescriptor);
    194179        if (it != m_eventSources.end())
    195180            sources = it->value;
     
    208193    MutexLocker locker(m_eventSourcesLock);
    209194
    210     SocketEventSourceIterator it = m_eventSources.find(fileDescriptor);
    211     ASSERT(it != m_eventSources.end());
    212195    ASSERT(m_eventSources.contains(fileDescriptor));
     196    auto it = m_eventSources.find(fileDescriptor);
    213197
    214198    if (it != m_eventSources.end()) {
     
    232216{
    233217    GRefPtr<GSource> dispatchSource = adoptGRef(g_idle_source_new());
    234     ASSERT(dispatchSource);
    235218    g_source_set_priority(dispatchSource.get(), G_PRIORITY_DEFAULT);
    236 
    237219    dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce));
    238220}
     
    241223{
    242224    GRefPtr<GSource> dispatchSource = adoptGRef(g_timeout_source_new(static_cast<guint>(delay * 1000)));
    243     ASSERT(dispatchSource);
    244 
    245225    dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce));
    246226}
    247 
    248 void WorkQueue::dispatchOnTermination(WebKit::PlatformProcessIdentifier process, const Function<void()>& function)
    249 {
    250     GRefPtr<GSource> dispatchSource = adoptGRef(g_child_watch_source_new(process));
    251     ASSERT(dispatchSource);
    252 
    253     dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnTermination));
    254 }
Note: See TracChangeset for help on using the changeset viewer.