Diff
Modified: trunk/Source/WebKit2/ChangeLog (103177 => 103178)
--- trunk/Source/WebKit2/ChangeLog 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/ChangeLog 2011-12-18 17:06:52 UTC (rev 103178)
@@ -1,3 +1,60 @@
+2011-12-16 Anders Carlsson <[email protected]>
+
+ Move everyone off of WorkItem
+ https://bugs.webkit.org/show_bug.cgi?id=74773
+
+ Reviewed by Darin Adler.
+
+ * Platform/CoreIPC/unix/ConnectionUnix.cpp:
+ (CoreIPC::Connection::open):
+ (CoreIPC::Connection::setShouldCloseConnectionOnProcessTermination):
+ * Platform/CoreIPC/win/ConnectionWin.cpp:
+ (CoreIPC::Connection::open):
+ * Platform/RunLoop.cpp:
+ (RunLoop::performWork):
+ (RunLoop::dispatch):
+ * Platform/RunLoop.h:
+ * Platform/WorkQueue.cpp:
+ * Platform/WorkQueue.h:
+ (WorkQueue::WorkItemWin::function):
+ * Platform/gtk/WorkQueueGtk.cpp:
+ (WorkQueue::EventSource::EventSource):
+ (WorkQueue::EventSource::executeEventSource):
+ (WorkQueue::registerEventSourceHandler):
+ (WorkQueue::dispatchOnSource):
+ (WorkQueue::dispatch):
+ (WorkQueue::dispatchAfterDelay):
+ (WorkQueue::dispatchOnTermination):
+ * Platform/mac/WorkQueueMac.cpp:
+ (WorkQueue::executeFunction):
+ (WorkQueue::dispatch):
+ (WorkQueue::dispatchAfterDelay):
+ * Platform/qt/WorkQueueQt.cpp:
+ (WorkQueue::WorkItemQt::WorkItemQt):
+ (WorkQueue::WorkItemQt::~WorkItemQt):
+ (WorkQueue::WorkItemQt::execute):
+ (WorkQueue::registerSocketEventHandler):
+ (WorkQueue::dispatch):
+ (WorkQueue::dispatchAfterDelay):
+ (WorkQueue::dispatchOnTermination):
+ * Platform/win/RunLoopWin.cpp:
+ (RunLoop::wakeUp):
+ * Platform/win/WorkQueueWin.cpp:
+ (WorkQueue::WorkItemWin::WorkItemWin):
+ (WorkQueue::WorkItemWin::create):
+ (WorkQueue::HandleWorkItem::HandleWorkItem):
+ (WorkQueue::HandleWorkItem::createByAdoptingHandle):
+ (WorkQueue::registerHandle):
+ (WorkQueue::dispatch):
+ * UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp:
+ (WebKit::ProcessLauncher::launchProcess):
+ * UIProcess/Launcher/qt/ProcessLauncherQt.cpp:
+ (WebKit::ProcessLauncher::launchProcess):
+ * UIProcess/Launcher/win/ProcessLauncherWin.cpp:
+ (WebKit::ProcessLauncher::launchProcess):
+ * WebProcess/mac/CoreIPCClientRunLoop.mm:
+ (WebKit::callOnCoreIPCClientRunLoopAndWait):
+
2011-12-17 Sam Weinig <[email protected]>
Make PlatformTouchEvent inherit from PlatformEvent
Modified: trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp (103177 => 103178)
--- trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/Platform/CoreIPC/unix/ConnectionUnix.cpp 2011-12-18 17:06:52 UTC (rev 103178)
@@ -29,13 +29,13 @@
#include "Connection.h"
#include "ArgumentEncoder.h"
-#include "WorkItem.h"
#include "SharedMemory.h"
#include <sys/socket.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <wtf/Assertions.h>
+#include <wtf/Functional.h>
#include <wtf/OwnArrayPtr.h>
#if PLATFORM(QT)
@@ -419,15 +419,15 @@
m_isConnected = true;
#if PLATFORM(QT)
- m_socketNotifier = m_connectionQueue.registerSocketEventHandler(m_socketDescriptor, QSocketNotifier::Read, WorkItem::create(this, &Connection::readyReadHandler));
+ m_socketNotifier = m_connectionQueue.registerSocketEventHandler(m_socketDescriptor, QSocketNotifier::Read, bind(&Connection::readyReadHandler, this));
#elif PLATFORM(GTK)
- m_connectionQueue.registerEventSourceHandler(m_socketDescriptor, (G_IO_HUP | G_IO_ERR), WorkItem::create(this, &Connection::connectionDidClose));
- m_connectionQueue.registerEventSourceHandler(m_socketDescriptor, G_IO_IN, WorkItem::create(this, &Connection::readyReadHandler));
+ m_connectionQueue.registerEventSourceHandler(m_socketDescriptor, (G_IO_HUP | G_IO_ERR), bind(&Connection::connectionDidClose, this));
+ m_connectionQueue.registerEventSourceHandler(m_socketDescriptor, G_IO_IN, bind(&Connection::readyReadHandler, this));
#endif
// Schedule a call to readyReadHandler. Data may have arrived before installation of the signal
// handler.
- m_connectionQueue.scheduleWork(WorkItem::create(this, &Connection::readyReadHandler));
+ m_connectionQueue.dispatch(bind(&Connection::readyReadHandler, this));
return true;
}
@@ -555,7 +555,7 @@
#if PLATFORM(QT)
void Connection::setShouldCloseConnectionOnProcessTermination(WebKit::PlatformProcessIdentifier process)
{
- m_connectionQueue.scheduleWorkOnTermination(process, WorkItem::create(this, &Connection::connectionDidClose));
+ m_connectionQueue.dispatchOnTermination(process, bind(&Connection::connectionDidClose, this));
}
#endif
Modified: trunk/Source/WebKit2/Platform/CoreIPC/win/ConnectionWin.cpp (103177 => 103178)
--- trunk/Source/WebKit2/Platform/CoreIPC/win/ConnectionWin.cpp 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/Platform/CoreIPC/win/ConnectionWin.cpp 2011-12-18 17:06:52 UTC (rev 103178)
@@ -27,7 +27,7 @@
#include "Connection.h"
#include "ArgumentEncoder.h"
-#include "WorkItem.h"
+#include <wtf/Functional.h>
#include <wtf/RandomNumber.h>
#include <wtf/text/WTFString.h>
@@ -263,11 +263,11 @@
m_isConnected = true;
// Start listening for read and write state events.
- m_connectionQueue.registerHandle(m_readState.hEvent, WorkItem::create(this, &Connection::readEventHandler));
- m_connectionQueue.registerHandle(m_writeState.hEvent, WorkItem::create(this, &Connection::writeEventHandler));
+ m_connectionQueue.registerHandle(m_readState.hEvent, bind(&Connection::readEventHandler, this));
+ m_connectionQueue.registerHandle(m_writeState.hEvent, bind(&Connection::writeEventHandler, this));
// Schedule a read.
- m_connectionQueue.scheduleWork(WorkItem::create(this, &Connection::readEventHandler));
+ m_connectionQueue.dispatch(bind(&Connection::readEventHandler, this));
return true;
}
Modified: trunk/Source/WebKit2/Platform/RunLoop.cpp (103177 => 103178)
--- trunk/Source/WebKit2/Platform/RunLoop.cpp 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/Platform/RunLoop.cpp 2011-12-18 17:06:52 UTC (rev 103178)
@@ -52,27 +52,20 @@
void RunLoop::performWork()
{
- Vector<OwnPtr<WorkItem> > workItemQueue;
+ Vector<Function<void()> > functionQueue;
{
- MutexLocker locker(m_workItemQueueLock);
- m_workItemQueue.swap(workItemQueue);
+ MutexLocker locker(m_functionQueueLock);
+ m_functionQueue.swap(functionQueue);
}
- for (size_t i = 0; i < workItemQueue.size(); ++i) {
- OwnPtr<WorkItem> item = workItemQueue[i].release();
- item->execute();
- }
+ for (size_t i = 0; i < functionQueue.size(); ++i)
+ functionQueue[i]();
}
void RunLoop::dispatch(const Function<void()>& function)
{
- scheduleWork(WorkItem::create(function));
-}
+ MutexLocker locker(m_functionQueueLock);
+ m_functionQueue.append(function);
-void RunLoop::scheduleWork(PassOwnPtr<WorkItem> item)
-{
- MutexLocker locker(m_workItemQueueLock);
- m_workItemQueue.append(item);
-
wakeUp();
}
Modified: trunk/Source/WebKit2/Platform/RunLoop.h (103177 => 103178)
--- trunk/Source/WebKit2/Platform/RunLoop.h 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/Platform/RunLoop.h 2011-12-18 17:06:52 UTC (rev 103178)
@@ -29,6 +29,7 @@
#define RunLoop_h
#include <wtf/Forward.h>
+#include <wtf/Functional.h>
#include <wtf/HashMap.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/ThreadSpecific.h>
@@ -56,9 +57,6 @@
static RunLoop* current();
static RunLoop* main();
- // FIXME: Get rid of this overload and use WTF::Function everywhere.
- void scheduleWork(PassOwnPtr<WorkItem>);
-
void dispatch(const Function<void()>&);
#if PLATFORM(WIN)
@@ -143,8 +141,8 @@
void performWork();
void wakeUp();
- Mutex m_workItemQueueLock;
- Vector<OwnPtr<WorkItem> > m_workItemQueue;
+ Mutex m_functionQueueLock;
+ Vector<Function<void()> > m_functionQueue;
#if PLATFORM(WIN)
static bool registerRunLoopMessageWindowClass();
Modified: trunk/Source/WebKit2/Platform/WorkQueue.cpp (103177 => 103178)
--- trunk/Source/WebKit2/Platform/WorkQueue.cpp 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/Platform/WorkQueue.cpp 2011-12-18 17:06:52 UTC (rev 103178)
@@ -40,16 +40,6 @@
#endif
}
-void WorkQueue::dispatch(const Function<void()>& function)
-{
- scheduleWork(WorkItem::create(function));
-}
-
-void WorkQueue::dispatchAfterDelay(const Function<void()>& function, double delay)
-{
- scheduleWorkAfterDelay(WorkItem::create(function), delay);
-}
-
void WorkQueue::invalidate()
{
{
Modified: trunk/Source/WebKit2/Platform/WorkQueue.h (103177 => 103178)
--- trunk/Source/WebKit2/Platform/WorkQueue.h 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/Platform/WorkQueue.h 2011-12-18 17:06:52 UTC (rev 103178)
@@ -33,8 +33,8 @@
#endif
#endif
-#include "WorkItem.h"
#include <wtf/Forward.h>
+#include <wtf/Functional.h>
#include <wtf/HashMap.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/RefCounted.h>
@@ -71,14 +71,6 @@
// Will dispatch the given function after the given delay (in seconds).
void dispatchAfterDelay(const Function<void()>&, double delay);
- // FIXME: Get rid of WorkItem everywhere.
-
- // Will schedule the given work item to run as soon as possible.
- void scheduleWork(PassOwnPtr<WorkItem>);
-
- // Will schedule the given work item to run after the given delay (in seconds).
- void scheduleWorkAfterDelay(PassOwnPtr<WorkItem>, double delay);
-
void invalidate();
#if OS(DARWIN)
@@ -95,15 +87,15 @@
void registerMachPortEventHandler(mach_port_t, MachPortEventType, const Function<void()>&);
void unregisterMachPortEventHandler(mach_port_t);
#elif PLATFORM(WIN)
- void registerHandle(HANDLE, PassOwnPtr<WorkItem>);
+ void registerHandle(HANDLE, const Function<void()>&);
void unregisterAndCloseHandle(HANDLE);
#elif PLATFORM(QT)
- QSocketNotifier* registerSocketEventHandler(int, QSocketNotifier::Type, PassOwnPtr<WorkItem>);
- void scheduleWorkOnTermination(WebKit::PlatformProcessIdentifier, PassOwnPtr<WorkItem>);
+ QSocketNotifier* registerSocketEventHandler(int, QSocketNotifier::Type, const Function<void()>&);
+ void dispatchOnTermination(WebKit::PlatformProcessIdentifier, const Function<void()>&);
#elif PLATFORM(GTK)
- void registerEventSourceHandler(int, int, PassOwnPtr<WorkItem>);
+ void registerEventSourceHandler(int, int, const Function<void()>&);
void unregisterEventSourceHandler(int);
- void scheduleWorkOnTermination(WebKit::PlatformProcessIdentifier, PassOwnPtr<WorkItem>);
+ void dispatchOnTermination(WebKit::PlatformProcessIdentifier, const Function<void()>&);
#endif
private:
@@ -116,7 +108,7 @@
#if OS(DARWIN)
#if HAVE(DISPATCH_H)
- static void executeWorkItem(void*);
+ static void executeFunction(void*);
Mutex m_eventSourcesMutex;
class EventSource;
HashMap<mach_port_t, EventSource*> m_eventSources;
@@ -125,30 +117,30 @@
#elif PLATFORM(WIN)
class WorkItemWin : public ThreadSafeRefCounted<WorkItemWin> {
public:
- static PassRefPtr<WorkItemWin> create(PassOwnPtr<WorkItem>, WorkQueue*);
+ static PassRefPtr<WorkItemWin> create(const Function<void()>&, WorkQueue*);
virtual ~WorkItemWin();
- WorkItem* item() const { return m_item.get(); }
+ Function<void()>& function() { return m_function; }
WorkQueue* queue() const { return m_queue; }
protected:
- WorkItemWin(PassOwnPtr<WorkItem>, WorkQueue*);
+ WorkItemWin(const Function<void()>&, WorkQueue*);
private:
- OwnPtr<WorkItem> m_item;
+ Function<void()> m_function;
WorkQueue* m_queue;
};
class HandleWorkItem : public WorkItemWin {
public:
- static PassRefPtr<HandleWorkItem> createByAdoptingHandle(HANDLE, PassOwnPtr<WorkItem>, WorkQueue*);
+ static PassRefPtr<HandleWorkItem> createByAdoptingHandle(HANDLE, const Function<void()>&, WorkQueue*);
virtual ~HandleWorkItem();
void setWaitHandle(HANDLE waitHandle) { m_waitHandle = waitHandle; }
HANDLE waitHandle() const { return m_waitHandle; }
private:
- HandleWorkItem(HANDLE, PassOwnPtr<WorkItem>, WorkQueue*);
+ HandleWorkItem(HANDLE, const Function<void()>&, WorkQueue*);
HANDLE m_handle;
HANDLE m_waitHandle;
@@ -182,7 +174,7 @@
#elif PLATFORM(GTK)
static void* startWorkQueueThread(WorkQueue*);
void workQueueThreadBody();
- void scheduleWorkOnSource(GSource*, PassOwnPtr<WorkItem>, GSourceFunc);
+ void dispatchOnSource(GSource*, const Function<void()>&, GSourceFunc);
ThreadIdentifier m_workQueueThread;
GMainContext* m_eventContext;
Modified: trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp (103177 => 103178)
--- trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/Platform/gtk/WorkQueueGtk.cpp 2011-12-18 17:06:52 UTC (rev 103178)
@@ -36,8 +36,8 @@
// WorkQueue::EventSource
class WorkQueue::EventSource {
public:
- EventSource(PassOwnPtr<WorkItem> workItem, WorkQueue* workQueue, GCancellable* cancellable)
- : m_workItem(workItem)
+ EventSource(const Function<void()>& function, WorkQueue* workQueue, GCancellable* cancellable)
+ : m_function(function)
, m_workQueue(workQueue)
, m_cancellable(cancellable)
{
@@ -60,7 +60,7 @@
return;
}
- eventSource->m_workItem->execute();
+ eventSource->m_function();
}
static gboolean performWorkOnce(EventSource* eventSource)
@@ -93,7 +93,7 @@
}
public:
- PassOwnPtr<WorkItem> m_workItem;
+ Function<void()> m_function;
WorkQueue* m_workQueue;
GCancellable* m_cancellable;
};
@@ -153,14 +153,14 @@
g_main_loop_run(m_eventLoop);
}
-void WorkQueue::registerEventSourceHandler(int fileDescriptor, int condition, PassOwnPtr<WorkItem> item)
+void WorkQueue::registerEventSourceHandler(int fileDescriptor, int condition, const Function<void()>& function)
{
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()));
ASSERT(dispatchSource);
- EventSource* eventSource = new EventSource(item, this, cancellable.get());
+ EventSource* eventSource = new EventSource(function, this, cancellable.get());
ASSERT(eventSource);
g_source_set_callback(dispatchSource.get(), reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWork),
@@ -200,9 +200,9 @@
}
}
-void WorkQueue::scheduleWorkOnSource(GSource* dispatchSource, PassOwnPtr<WorkItem> item, GSourceFunc sourceCallback)
+void WorkQueue::dispatchOnSource(GSource* dispatchSource, const Function<void()>& function, GSourceFunc sourceCallback)
{
- EventSource* eventSource = new EventSource(item, this, 0);
+ EventSource* eventSource = new EventSource(function, this, 0);
g_source_set_callback(dispatchSource, sourceCallback, eventSource,
reinterpret_cast<GDestroyNotify>(&WorkQueue::EventSource::deleteEventSource));
@@ -210,27 +210,27 @@
g_source_attach(dispatchSource, m_eventContext);
}
-void WorkQueue::scheduleWork(PassOwnPtr<WorkItem> item)
+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);
- scheduleWorkOnSource(dispatchSource.get(), item, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce));
+ dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce));
}
-void WorkQueue::scheduleWorkAfterDelay(PassOwnPtr<WorkItem> item, double delay)
+void WorkQueue::dispatchAfterDelay(const Function<void()>& function, double delay)
{
GRefPtr<GSource> dispatchSource = adoptGRef(g_timeout_source_new(static_cast<guint>(delay * 1000)));
ASSERT(dispatchSource);
- scheduleWorkOnSource(dispatchSource.get(), item, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce));
+ dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnce));
}
-void WorkQueue::scheduleWorkOnTermination(WebKit::PlatformProcessIdentifier process, PassOwnPtr<WorkItem> item)
+void WorkQueue::dispatchOnTermination(WebKit::PlatformProcessIdentifier process, const Function<void()>& function)
{
GRefPtr<GSource> dispatchSource = adoptGRef(g_child_watch_source_new(process));
ASSERT(dispatchSource);
- scheduleWorkOnSource(dispatchSource.get(), item, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnTermination));
+ dispatchOnSource(dispatchSource.get(), function, reinterpret_cast<GSourceFunc>(&WorkQueue::EventSource::performWorkOnTermination));
}
Modified: trunk/Source/WebKit2/Platform/mac/WorkQueueMac.cpp (103177 => 103178)
--- trunk/Source/WebKit2/Platform/mac/WorkQueueMac.cpp 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/Platform/mac/WorkQueueMac.cpp 2011-12-18 17:06:52 UTC (rev 103178)
@@ -32,30 +32,30 @@
#if HAVE(DISPATCH_H)
-void WorkQueue::executeWorkItem(void* item)
+void WorkQueue::executeFunction(void* context)
{
WorkQueue* queue = static_cast<WorkQueue*>(dispatch_get_context(dispatch_get_current_queue()));
- OwnPtr<WorkItem> workItem = adoptPtr(static_cast<WorkItem*>(item));
+ OwnPtr<Function<void()> > function = adoptPtr(static_cast<Function<void()>*>(context));
{
MutexLocker locker(queue->m_isValidMutex);
if (!queue->m_isValid)
return;
}
-
- workItem->execute();
+
+ (*function)();
}
-void WorkQueue::scheduleWork(PassOwnPtr<WorkItem> item)
+void WorkQueue::dispatch(const Function<void()>& function)
{
- dispatch_async_f(m_dispatchQueue, item.leakPtr(), executeWorkItem);
+ dispatch_async_f(m_dispatchQueue, new Function<void()>(function), executeFunction);
}
-void WorkQueue::scheduleWorkAfterDelay(PassOwnPtr<WorkItem> item, double delay)
+void WorkQueue::dispatchAfterDelay(const Function<void()>& function, double delay)
{
dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC);
- dispatch_after_f(delayTime, m_dispatchQueue, item.leakPtr(), executeWorkItem);
+ dispatch_after_f(delayTime, m_dispatchQueue, new Function<void()>(function), executeFunction);
}
class WorkQueue::EventSource {
Modified: trunk/Source/WebKit2/Platform/qt/WorkQueueQt.cpp (103177 => 103178)
--- trunk/Source/WebKit2/Platform/qt/WorkQueueQt.cpp 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/Platform/qt/WorkQueueQt.cpp 2011-12-18 17:06:52 UTC (rev 103178)
@@ -37,32 +37,31 @@
class WorkQueue::WorkItemQt : public QObject {
Q_OBJECT
public:
- WorkItemQt(WorkQueue* workQueue, WorkItem* workItem)
+ WorkItemQt(WorkQueue* workQueue, const Function<void()>& function)
: m_queue(workQueue)
, m_source(0)
, m_signal(0)
- , m_workItem(workItem)
+ , m_function(function)
{
}
- WorkItemQt(WorkQueue* workQueue, QObject* source, const char* signal, WorkItem* workItem)
+ WorkItemQt(WorkQueue* workQueue, QObject* source, const char* signal, const Function<void()>& function)
: m_queue(workQueue)
, m_source(source)
, m_signal(signal)
- , m_workItem(workItem)
+ , m_function(function)
{
connect(m_source, m_signal, SLOT(execute()), Qt::QueuedConnection);
}
~WorkItemQt()
{
- delete m_workItem;
}
Q_SLOT void execute()
{
if (m_queue->m_isValid)
- m_workItem->execute();
+ m_function();
}
Q_SLOT void executeAndDelete()
@@ -79,17 +78,17 @@
WorkQueue* m_queue;
QObject* m_source;
const char* m_signal;
- WorkItem* m_workItem;
+ Function<void()> m_function;
};
-QSocketNotifier* WorkQueue::registerSocketEventHandler(int socketDescriptor, QSocketNotifier::Type type, PassOwnPtr<WorkItem> workItem)
+QSocketNotifier* WorkQueue::registerSocketEventHandler(int socketDescriptor, QSocketNotifier::Type type, const Function<void()>& function)
{
ASSERT(m_workThread);
QSocketNotifier* notifier = new QSocketNotifier(socketDescriptor, type, 0);
notifier->setEnabled(false);
notifier->moveToThread(m_workThread);
- WorkQueue::WorkItemQt* itemQt = new WorkQueue::WorkItemQt(this, notifier, SIGNAL(activated(int)), workItem.leakPtr());
+ WorkQueue::WorkItemQt* itemQt = new WorkQueue::WorkItemQt(this, notifier, SIGNAL(activated(int)), function);
itemQt->moveToThread(m_workThread);
notifier->setEnabled(true);
return notifier;
@@ -109,23 +108,23 @@
deleteAllValues(m_signalListeners);
}
-void WorkQueue::scheduleWork(PassOwnPtr<WorkItem> item)
+void WorkQueue::dispatch(const Function<void()>& function)
{
- WorkQueue::WorkItemQt* itemQt = new WorkQueue::WorkItemQt(this, item.leakPtr());
+ WorkQueue::WorkItemQt* itemQt = new WorkQueue::WorkItemQt(this, function);
itemQt->moveToThread(m_workThread);
QMetaObject::invokeMethod(itemQt, "executeAndDelete", Qt::QueuedConnection);
}
-void WorkQueue::scheduleWorkAfterDelay(PassOwnPtr<WorkItem> item, double delayInSecond)
+void WorkQueue::dispatchAfterDelay(const Function<void()>& function, double delayInSecond)
{
- WorkQueue::WorkItemQt* itemQt = new WorkQueue::WorkItemQt(this, item.leakPtr());
+ WorkQueue::WorkItemQt* itemQt = new WorkQueue::WorkItemQt(this, function);
itemQt->startTimer(static_cast<int>(delayInSecond * 1000));
itemQt->moveToThread(m_workThread);
}
-void WorkQueue::scheduleWorkOnTermination(WebKit::PlatformProcessIdentifier process, PassOwnPtr<WorkItem> workItem)
+void WorkQueue::dispatchOnTermination(WebKit::PlatformProcessIdentifier process, const Function<void()>& function)
{
- WorkQueue::WorkItemQt* itemQt = new WorkQueue::WorkItemQt(this, process, SIGNAL(finished(int, QProcess::ExitStatus)), workItem.leakPtr());
+ WorkQueue::WorkItemQt* itemQt = new WorkQueue::WorkItemQt(this, process, SIGNAL(finished(int, QProcess::ExitStatus)), function);
itemQt->moveToThread(m_workThread);
}
Modified: trunk/Source/WebKit2/Platform/win/RunLoopWin.cpp (103177 => 103178)
--- trunk/Source/WebKit2/Platform/win/RunLoopWin.cpp 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/Platform/win/RunLoopWin.cpp 2011-12-18 17:06:52 UTC (rev 103178)
@@ -155,7 +155,7 @@
void RunLoop::wakeUp()
{
- // FIXME: No need to wake up the run loop if we've already called scheduleWork
+ // FIXME: No need to wake up the run loop if we've already called dispatch
// before the run loop has had the time to respond.
::PostMessage(m_runLoopMessageWindow, PerformWorkMessage, reinterpret_cast<WPARAM>(this), 0);
}
Modified: trunk/Source/WebKit2/Platform/win/WorkQueueWin.cpp (103177 => 103178)
--- trunk/Source/WebKit2/Platform/win/WorkQueueWin.cpp 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/Platform/win/WorkQueueWin.cpp 2011-12-18 17:06:52 UTC (rev 103178)
@@ -29,32 +29,32 @@
#include <WebCore/NotImplemented.h>
#include <wtf/Threading.h>
-inline WorkQueue::WorkItemWin::WorkItemWin(PassOwnPtr<WorkItem> item, WorkQueue* queue)
- : m_item(item)
+inline WorkQueue::WorkItemWin::WorkItemWin(const Function<void()>& function, WorkQueue* queue)
+ : m_function(function)
, m_queue(queue)
{
}
-PassRefPtr<WorkQueue::WorkItemWin> WorkQueue::WorkItemWin::create(PassOwnPtr<WorkItem> item, WorkQueue* queue)
+PassRefPtr<WorkQueue::WorkItemWin> WorkQueue::WorkItemWin::create(const Function<void()>& function, WorkQueue* queue)
{
- return adoptRef(new WorkItemWin(item, queue));
+ return adoptRef(new WorkItemWin(function, queue));
}
WorkQueue::WorkItemWin::~WorkItemWin()
{
}
-inline WorkQueue::HandleWorkItem::HandleWorkItem(HANDLE handle, PassOwnPtr<WorkItem> item, WorkQueue* queue)
- : WorkItemWin(item, queue)
+inline WorkQueue::HandleWorkItem::HandleWorkItem(HANDLE handle, const Function<void()>& function, WorkQueue* queue)
+ : WorkItemWin(function, queue)
, m_handle(handle)
, m_waitHandle(0)
{
ASSERT_ARG(handle, handle);
}
-PassRefPtr<WorkQueue::HandleWorkItem> WorkQueue::HandleWorkItem::createByAdoptingHandle(HANDLE handle, PassOwnPtr<WorkItem> item, WorkQueue* queue)
+PassRefPtr<WorkQueue::HandleWorkItem> WorkQueue::HandleWorkItem::createByAdoptingHandle(HANDLE handle, const Function<void()>& function, WorkQueue* queue)
{
- return adoptRef(new HandleWorkItem(handle, item, queue));
+ return adoptRef(new HandleWorkItem(handle, function, queue));
}
WorkQueue::HandleWorkItem::~HandleWorkItem()
@@ -87,9 +87,9 @@
queue->performWorkOnRegisteredWorkThread();
}
-void WorkQueue::registerHandle(HANDLE handle, PassOwnPtr<WorkItem> item)
+void WorkQueue::registerHandle(HANDLE handle, const Function<void()>& function)
{
- RefPtr<HandleWorkItem> handleItem = HandleWorkItem::createByAdoptingHandle(handle, item, this);
+ RefPtr<HandleWorkItem> handleItem = HandleWorkItem::createByAdoptingHandle(handle, function, this);
{
MutexLocker lock(m_handlesLock);
@@ -194,11 +194,11 @@
::DeleteTimerQueueEx(m_timerQueue, 0);
}
-void WorkQueue::scheduleWork(PassOwnPtr<WorkItem> item)
+void WorkQueue::dispatch(const Function<void()>& function))
{
MutexLocker locker(m_workItemQueueLock);
- m_workItemQueue.append(WorkItemWin::create(item, this));
+ m_workItemQueue.append(WorkItemWin::create(function, this));
// Spawn a work thread to perform the work we just added. As an optimization, we avoid
// spawning the thread if a work thread is already registered. This prevents multiple work
@@ -214,7 +214,7 @@
static PassRefPtr<TimerContext> create() { return adoptRef(new TimerContext); }
WorkQueue* queue;
- OwnPtr<WorkItem> item;
+ Function<void()> function;
Mutex timerMutex;
HANDLE timer;
@@ -230,7 +230,7 @@
// Balanced by leakRef in scheduleWorkAfterDelay.
RefPtr<TimerContext> timerContext = adoptRef(static_cast<TimerContext*>(context));
- timerContext->queue->scheduleWork(timerContext->item.release());
+ timerContext->queue->dispatch(timerContext->function);
MutexLocker lock(timerContext->timerMutex);
ASSERT(timerContext->timer);
@@ -239,13 +239,13 @@
ASSERT_WITH_MESSAGE(false, "::DeleteTimerQueueTimer failed with error %lu", ::GetLastError());
}
-void WorkQueue::scheduleWorkAfterDelay(PassOwnPtr<WorkItem> item, double delay)
+void WorkQueue::dispatchAfterDelay(const Function<void()>& function, double delay)
{
ASSERT(m_timerQueue);
RefPtr<TimerContext> context = TimerContext::create();
context->queue = this;
- context->item = item;
+ context->function = function;
{
// The timer callback could fire before ::CreateTimerQueueTimer even returns, so we protect
Modified: trunk/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp (103177 => 103178)
--- trunk/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp 2011-12-18 17:06:52 UTC (rev 103178)
@@ -133,7 +133,7 @@
g_child_watch_add(m_processIdentifier, childFinishedFunction, GINT_TO_POINTER(sockets[1]));
// We've finished launching the process, message back to the main run loop.
- RunLoop::main()->scheduleWork(WorkItem::create(this, &ProcessLauncher::didFinishLaunchingProcess, m_processIdentifier, sockets[1]));
+ RunLoop::main()->dispatch(bind(&ProcessLauncher::didFinishLaunchingProcess, this, m_processIdentifier, sockets[1]));
}
void ProcessLauncher::terminateProcess()
Modified: trunk/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp (103177 => 103178)
--- trunk/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp 2011-12-18 17:06:52 UTC (rev 103178)
@@ -174,7 +174,7 @@
setpriority(PRIO_PROCESS, webProcess->pid(), 10);
- RunLoop::main()->scheduleWork(WorkItem::create(this, &WebKit::ProcessLauncher::didFinishLaunchingProcess, webProcess, connector));
+ RunLoop::main()->dispatch(bind(&WebKit::ProcessLauncher::didFinishLaunchingProcess, this, webProcess, connector));
}
void ProcessLauncher::terminateProcess()
Modified: trunk/Source/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp (103177 => 103178)
--- trunk/Source/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp 2011-12-18 17:06:52 UTC (rev 103178)
@@ -102,7 +102,7 @@
::CloseHandle(processInformation.hThread);
// We've finished launching the process, message back to the run loop.
- RunLoop::main()->scheduleWork(WorkItem::create(this, &ProcessLauncher::didFinishLaunchingProcess, processInformation.hProcess, serverIdentifier));
+ RunLoop::main()->dispatch(bind(&ProcessLauncher::didFinishLaunchingProcess, this, processInformation.hProcess, serverIdentifier));
}
void ProcessLauncher::terminateProcess()
Modified: trunk/Source/WebKit2/WebProcess/mac/CoreIPCClientRunLoop.mm (103177 => 103178)
--- trunk/Source/WebKit2/WebProcess/mac/CoreIPCClientRunLoop.mm 2011-12-18 16:39:21 UTC (rev 103177)
+++ trunk/Source/WebKit2/WebProcess/mac/CoreIPCClientRunLoop.mm 2011-12-18 17:06:52 UTC (rev 103178)
@@ -68,8 +68,8 @@
void callOnCoreIPCClientRunLoopAndWait(FunctionWithContext function, void* context)
{
- // FIXME: It would fit better with WebKit2 coding style to use a WorkItem here.
- // To do that we'd need to make scheduleWork have an overload that takes an array of run loop modes or find some
+ // FIXME: It would fit better with WebKit2 coding style to use a WTF Function here.
+ // To do that we'd need to make dispatch have an overload that takes an array of run loop modes or find some
// other way to specify that we want to include the synchronous load run loop mode.
RetainPtr<WKFunctionAdapter> adapter(AdoptNS, [[WKFunctionAdapter alloc] init]);
adapter->function = function;