Title: [103132] trunk/Source/WebKit2
Revision
103132
Author
ander...@apple.com
Date
2011-12-16 17:03:36 -0800 (Fri, 16 Dec 2011)

Log Message

Convert more WorkItems over to WTF::Functions
https://bugs.webkit.org/show_bug.cgi?id=74770

Reviewed by Andreas Kling.

* Platform/WorkQueue.cpp:
(WorkQueue::dispatchAfterDelay):
* Platform/WorkQueue.h:
* Shared/ChildProcess.cpp:
(WebKit::ChildProcess::didCloseOnConnectionWorkQueue):
* UIProcess/Launcher/ThreadLauncher.cpp:
(WebKit::ThreadLauncher::launchThread):
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::pluginThreadAsyncCall):
* WebProcess/Plugins/PluginView.cpp:
(WebKit::derefPluginView):
(WebKit::PluginView::unprotectPluginFromDestruction):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (103131 => 103132)


--- trunk/Source/WebKit2/ChangeLog	2011-12-17 00:58:33 UTC (rev 103131)
+++ trunk/Source/WebKit2/ChangeLog	2011-12-17 01:03:36 UTC (rev 103132)
@@ -1,3 +1,25 @@
+2011-12-16  Anders Carlsson  <ander...@apple.com>
+
+        Convert more WorkItems over to WTF::Functions
+        https://bugs.webkit.org/show_bug.cgi?id=74770
+
+        Reviewed by Andreas Kling.
+
+        * Platform/WorkQueue.cpp:
+        (WorkQueue::dispatchAfterDelay):
+        * Platform/WorkQueue.h:
+        * Shared/ChildProcess.cpp:
+        (WebKit::ChildProcess::didCloseOnConnectionWorkQueue):
+        * UIProcess/Launcher/ThreadLauncher.cpp:
+        (WebKit::ThreadLauncher::launchThread):
+        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+        (WebKit::ProcessLauncher::launchProcess):
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::pluginThreadAsyncCall):
+        * WebProcess/Plugins/PluginView.cpp:
+        (WebKit::derefPluginView):
+        (WebKit::PluginView::unprotectPluginFromDestruction):
+
 2011-12-16  Mark Hahnenberg  <mhahnenb...@apple.com>
 
         Windows test fix

Modified: trunk/Source/WebKit2/Platform/WorkItem.h (103131 => 103132)


--- trunk/Source/WebKit2/Platform/WorkItem.h	2011-12-17 00:58:33 UTC (rev 103131)
+++ trunk/Source/WebKit2/Platform/WorkItem.h	2011-12-17 01:03:36 UTC (rev 103132)
@@ -42,9 +42,6 @@
 
     static PassOwnPtr<WorkItem> create(void (*)());
 
-    template<typename C>
-    static PassOwnPtr<WorkItem> createDeref(C*);
-
     static PassOwnPtr<WorkItem> create(const Function<void()>&);
 
     virtual ~WorkItem() { }
@@ -190,30 +187,6 @@
     return adoptPtr(static_cast<WorkItem*>(new FunctionWorkItem0(function)));
 }
 
-template<typename C>
-class DerefWorkItem : private WorkItem {
-    // We only allow WorkItem to create this.
-    friend class WorkItem;
-
-    explicit DerefWorkItem(C* ptr)
-        : m_ptr(ptr)
-    {
-    }
-
-    virtual void execute()
-    {
-        m_ptr->deref();
-    }
-
-    C* m_ptr;
-};
-
-template<typename C>
-PassOwnPtr<WorkItem> WorkItem::createDeref(C* ptr)
-{
-    return adoptPtr(static_cast<WorkItem*>(new DerefWorkItem<C>(ptr)));
-}
-
 // FunctionWorkItem is a temporary class. WorkItem should just be replaced by WTF::Function everywhere.
 class FunctionWorkItem : private WorkItem {
     // We only allow WorkItem to create this.

Modified: trunk/Source/WebKit2/Platform/WorkQueue.cpp (103131 => 103132)


--- trunk/Source/WebKit2/Platform/WorkQueue.cpp	2011-12-17 00:58:33 UTC (rev 103131)
+++ trunk/Source/WebKit2/Platform/WorkQueue.cpp	2011-12-17 01:03:36 UTC (rev 103132)
@@ -45,6 +45,11 @@
     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 (103131 => 103132)


--- trunk/Source/WebKit2/Platform/WorkQueue.h	2011-12-17 00:58:33 UTC (rev 103131)
+++ trunk/Source/WebKit2/Platform/WorkQueue.h	2011-12-17 01:03:36 UTC (rev 103132)
@@ -68,6 +68,9 @@
     // Will dispatch the given function to run as soon as possible.
     void dispatch(const Function<void()>&);
 
+    // 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.

Modified: trunk/Source/WebKit2/Shared/ChildProcess.cpp (103131 => 103132)


--- trunk/Source/WebKit2/Shared/ChildProcess.cpp	2011-12-17 00:58:33 UTC (rev 103131)
+++ trunk/Source/WebKit2/Shared/ChildProcess.cpp	2011-12-17 01:03:36 UTC (rev 103132)
@@ -93,8 +93,8 @@
     // If the connection has been closed and we haven't responded in the main thread for 10 seconds
     // the process will exit forcibly.
     static const double watchdogDelay = 10.0;
-    
-    workQueue.scheduleWorkAfterDelay(WorkItem::create(watchdogCallback), watchdogDelay);
+
+    workQueue.dispatchAfterDelay(bind(static_cast<void(*)()>(watchdogCallback)), watchdogDelay);
 }
     
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/Launcher/ThreadLauncher.cpp (103131 => 103132)


--- trunk/Source/WebKit2/UIProcess/Launcher/ThreadLauncher.cpp	2011-12-17 00:58:33 UTC (rev 103131)
+++ trunk/Source/WebKit2/UIProcess/Launcher/ThreadLauncher.cpp	2011-12-17 01:03:36 UTC (rev 103132)
@@ -43,7 +43,7 @@
     CoreIPC::Connection::Identifier connectionIdentifier = createWebThread();
 
     // We've finished launching the thread, message back to the main run loop.
-    RunLoop::main()->scheduleWork(WorkItem::create(this, &ThreadLauncher::didFinishLaunchingThread, connectionIdentifier));
+    RunLoop::main()->dispatch(bind(&ThreadLauncher::didFinishLaunchingThread, this, connectionIdentifier));
 }
 
 void ThreadLauncher::didFinishLaunchingThread(CoreIPC::Connection::Identifier identifier)

Modified: trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm (103131 => 103132)


--- trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm	2011-12-17 00:58:33 UTC (rev 103131)
+++ trunk/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm	2011-12-17 01:03:36 UTC (rev 103132)
@@ -182,7 +182,7 @@
     }
     
     // We've finished launching the process, message back to the main run loop.
-    RunLoop::main()->scheduleWork(WorkItem::create(this, &ProcessLauncher::didFinishLaunchingProcess, processIdentifier, listeningPort));
+    RunLoop::main()->dispatch(bind(&ProcessLauncher::didFinishLaunchingProcess, this, processIdentifier, listeningPort));
 }
 
 void ProcessLauncher::terminateProcess()

Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (103131 => 103132)


--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-12-17 00:58:33 UTC (rev 103131)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2011-12-17 01:03:36 UTC (rev 103132)
@@ -308,7 +308,7 @@
 
 void NetscapePlugin::pluginThreadAsyncCall(void (*function)(void*), void* userData)
 {
-    RunLoop::main()->scheduleWork(WorkItem::create(this, &NetscapePlugin::handlePluginThreadAsyncCall, function, userData));
+    RunLoop::main()->dispatch(bind(&NetscapePlugin::handlePluginThreadAsyncCall, this, function, userData));
 }
     
 void NetscapePlugin::handlePluginThreadAsyncCall(void (*function)(void*), void* userData)

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (103131 => 103132)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2011-12-17 00:58:33 UTC (rev 103131)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp	2011-12-17 01:03:36 UTC (rev 103132)
@@ -1202,6 +1202,11 @@
         ref();
 }
 
+static void derefPluginView(PluginView* pluginView)
+{
+    pluginView->deref();
+}
+
 void PluginView::unprotectPluginFromDestruction()
 {
     if (m_isBeingDestroyed)
@@ -1213,7 +1218,7 @@
     // the destroyed object higher on the stack. To prevent this, if the plug-in has
     // only one remaining reference, call deref() asynchronously.
     if (hasOneRef())
-        RunLoop::main()->scheduleWork(WorkItem::createDeref(this));
+        RunLoop::main()->dispatch(bind(derefPluginView, this));
     else
         deref();
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to