Changeset 162370 in webkit


Ignore:
Timestamp:
Jan 20, 2014 1:17:24 PM (10 years ago)
Author:
zandobersek@gmail.com
Message:

[GTK][WK2] Move the rest of GTK's WorkQueue implementation to std::function
https://bugs.webkit.org/show_bug.cgi?id=127273

Reviewed by Anders Carlsson.

Move to using std::function and move semantics in WorkQueue::registerSocketEventHandler
and WorkQueue::SocketEventSource.

  • Platform/IPC/unix/ConnectionUnix.cpp:

(IPC::Connection::open):

  • Platform/WorkQueue.h:
  • Platform/gtk/WorkQueueGtk.cpp:

(WorkQueue::SocketEventSource::SocketEventSource):
(WorkQueue::registerSocketEventHandler):
(WorkQueue::dispatchOnSource): Use std::move instead of std::forward<T>.
(WorkQueue::dispatch): Ditto.
(WorkQueue::dispatchAfter): Ditto.

Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r162307 r162370  
     12014-01-20  Zan Dobersek  <zdobersek@igalia.com>
     2
     3        [GTK][WK2] Move the rest of GTK's WorkQueue implementation to std::function
     4        https://bugs.webkit.org/show_bug.cgi?id=127273
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Move to using std::function and move semantics in WorkQueue::registerSocketEventHandler
     9        and WorkQueue::SocketEventSource.
     10
     11        * Platform/IPC/unix/ConnectionUnix.cpp:
     12        (IPC::Connection::open):
     13        * Platform/WorkQueue.h:
     14        * Platform/gtk/WorkQueueGtk.cpp:
     15        (WorkQueue::SocketEventSource::SocketEventSource):
     16        (WorkQueue::registerSocketEventHandler):
     17        (WorkQueue::dispatchOnSource): Use std::move instead of std::forward<T>.
     18        (WorkQueue::dispatch): Ditto.
     19        (WorkQueue::dispatchAfter): Ditto.
     20
    1212014-01-20  Zan Dobersek  <zdobersek@igalia.com>
    222
  • trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp

    r161156 r162370  
    389389    m_isConnected = true;
    390390#if PLATFORM(GTK)
    391     m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, WTF::bind(&Connection::readyReadHandler, this), WTF::bind(&Connection::connectionDidClose, this));
     391    RefPtr<Connection> protector(this);
     392    m_connectionQueue->registerSocketEventHandler(m_socketDescriptor,
     393        [=] {
     394            protector->readyReadHandler();
     395        },
     396        [=] {
     397            protector->connectionDidClose();
     398        });
    392399#elif PLATFORM(EFL)
    393400    m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, WTF::bind(&Connection::readyReadHandler, this));
  • trunk/Source/WebKit2/Platform/WorkQueue.h

    r162307 r162370  
    6464    dispatch_queue_t dispatchQueue() const { return m_dispatchQueue; }
    6565#elif PLATFORM(GTK)
    66     void registerSocketEventHandler(int, const Function<void()>&, const Function<void()>&);
     66    void registerSocketEventHandler(int, std::function<void ()>, std::function<void ()>);
    6767    void unregisterSocketEventHandler(int);
    6868#elif PLATFORM(EFL)
  • trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp

    r162307 r162370  
    7070class WorkQueue::SocketEventSource : public WorkQueue::EventSource {
    7171public:
    72     SocketEventSource(const Function<void()>& function, WorkQueue* workQueue, GCancellable* cancellable, const Function<void()>& closeFunction)
    73         : EventSource(function, workQueue)
     72    SocketEventSource(std::function<void ()> function, WorkQueue* workQueue, GCancellable* cancellable, std::function<void ()> closeFunction)
     73        : EventSource(std::move(function), workQueue)
    7474        , m_cancellable(cancellable)
    75         , m_closeFunction(closeFunction)
     75        , m_closeFunction(std::move(closeFunction))
    7676    {
    7777        ASSERT(cancellable);
     
    108108private:
    109109    GCancellable* m_cancellable;
    110     Function<void()> m_closeFunction;
     110    std::function<void ()> m_closeFunction;
    111111};
    112112
     
    160160}
    161161
    162 void WorkQueue::registerSocketEventHandler(int fileDescriptor, const Function<void()>& function, const Function<void()>& closeFunction)
     162void WorkQueue::registerSocketEventHandler(int fileDescriptor, std::function<void ()> function, std::function<void ()> closeFunction)
    163163{
    164164    GRefPtr<GSocket> socket = adoptGRef(g_socket_new_from_fd(fileDescriptor, 0));
     
    167167    GRefPtr<GSource> dispatchSource = adoptGRef(g_socket_create_source(socket.get(), G_IO_IN, cancellable.get()));
    168168    ASSERT(dispatchSource);
    169     SocketEventSource* eventSource = new SocketEventSource(function, this, cancellable.get(), closeFunction);
     169    SocketEventSource* eventSource = new SocketEventSource(std::move(function), this,
     170        cancellable.get(), std::move(closeFunction));
    170171
    171172    g_source_set_callback(dispatchSource.get(), reinterpret_cast<GSourceFunc>(&WorkQueue::SocketEventSource::eventCallback),
     
    207208void WorkQueue::dispatchOnSource(GSource* dispatchSource, std::function<void ()> function, GSourceFunc sourceCallback)
    208209{
    209     g_source_set_callback(dispatchSource, sourceCallback, new EventSource(std::forward<std::function<void ()>>(function), this),
     210    g_source_set_callback(dispatchSource, sourceCallback, new EventSource(std::move(function), this),
    210211        reinterpret_cast<GDestroyNotify>(&WorkQueue::EventSource::deleteEventSource));
    211212
     
    217218    GRefPtr<GSource> dispatchSource = adoptGRef(g_idle_source_new());
    218219    g_source_set_priority(dispatchSource.get(), G_PRIORITY_DEFAULT);
    219     dispatchOnSource(dispatchSource.get(), std::forward<std::function<void ()>>(function),
     220    dispatchOnSource(dispatchSource.get(), std::move(function),
    220221        reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce));
    221222}
     
    225226    GRefPtr<GSource> dispatchSource = adoptGRef(g_timeout_source_new(
    226227        static_cast<guint>(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count())));
    227     dispatchOnSource(dispatchSource.get(), std::forward<std::function<void ()>>(function),
     228    dispatchOnSource(dispatchSource.get(), std::move(function),
    228229        reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce));
    229230}
Note: See TracChangeset for help on using the changeset viewer.