Changeset 162370 in webkit
- Timestamp:
- Jan 20, 2014 1:17:24 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r162307 r162370 1 2014-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 1 21 2014-01-20 Zan Dobersek <zdobersek@igalia.com> 2 22 -
trunk/Source/WebKit2/Platform/IPC/unix/ConnectionUnix.cpp
r161156 r162370 389 389 m_isConnected = true; 390 390 #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 }); 392 399 #elif PLATFORM(EFL) 393 400 m_connectionQueue->registerSocketEventHandler(m_socketDescriptor, WTF::bind(&Connection::readyReadHandler, this)); -
trunk/Source/WebKit2/Platform/WorkQueue.h
r162307 r162370 64 64 dispatch_queue_t dispatchQueue() const { return m_dispatchQueue; } 65 65 #elif PLATFORM(GTK) 66 void registerSocketEventHandler(int, const Function<void()>&, const Function<void()>&);66 void registerSocketEventHandler(int, std::function<void ()>, std::function<void ()>); 67 67 void unregisterSocketEventHandler(int); 68 68 #elif PLATFORM(EFL) -
trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp
r162307 r162370 70 70 class WorkQueue::SocketEventSource : public WorkQueue::EventSource { 71 71 public: 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) 74 74 , m_cancellable(cancellable) 75 , m_closeFunction( closeFunction)75 , m_closeFunction(std::move(closeFunction)) 76 76 { 77 77 ASSERT(cancellable); … … 108 108 private: 109 109 GCancellable* m_cancellable; 110 Function<void()> m_closeFunction;110 std::function<void ()> m_closeFunction; 111 111 }; 112 112 … … 160 160 } 161 161 162 void WorkQueue::registerSocketEventHandler(int fileDescriptor, const Function<void()>& function, const Function<void()>&closeFunction)162 void WorkQueue::registerSocketEventHandler(int fileDescriptor, std::function<void ()> function, std::function<void ()> closeFunction) 163 163 { 164 164 GRefPtr<GSocket> socket = adoptGRef(g_socket_new_from_fd(fileDescriptor, 0)); … … 167 167 GRefPtr<GSource> dispatchSource = adoptGRef(g_socket_create_source(socket.get(), G_IO_IN, cancellable.get())); 168 168 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)); 170 171 171 172 g_source_set_callback(dispatchSource.get(), reinterpret_cast<GSourceFunc>(&WorkQueue::SocketEventSource::eventCallback), … … 207 208 void WorkQueue::dispatchOnSource(GSource* dispatchSource, std::function<void ()> function, GSourceFunc sourceCallback) 208 209 { 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), 210 211 reinterpret_cast<GDestroyNotify>(&WorkQueue::EventSource::deleteEventSource)); 211 212 … … 217 218 GRefPtr<GSource> dispatchSource = adoptGRef(g_idle_source_new()); 218 219 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), 220 221 reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce)); 221 222 } … … 225 226 GRefPtr<GSource> dispatchSource = adoptGRef(g_timeout_source_new( 226 227 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), 228 229 reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce)); 229 230 }
Note: See TracChangeset
for help on using the changeset viewer.