Title: [201493] trunk/Source
Revision
201493
Author
[email protected]
Date
2016-05-28 21:20:06 -0700 (Sat, 28 May 2016)

Log Message

Templatize NoncopyableFunction class similarly to std::function
https://bugs.webkit.org/show_bug.cgi?id=158185

Reviewed by Darin Adler.

Templatize NoncopyableFunction class similarly to std::function, so
that it can be used as a std::function replacement in more places.

Previously, NoncopyableFunction could only support "void()" lambdas.

Source/WebCore:

* Modules/mediastream/MediaEndpointPeerConnection.cpp:
(WebCore::MediaEndpointPeerConnection::runTask):
* Modules/mediastream/MediaEndpointPeerConnection.h:
* fileapi/AsyncFileStream.cpp:
(WebCore::callOnFileThread):
(WebCore::AsyncFileStream::perform):
(WebCore::AsyncFileStream::getSize):
(WebCore::AsyncFileStream::openForRead):
(WebCore::AsyncFileStream::openForWrite):
(WebCore::AsyncFileStream::write):
* fileapi/AsyncFileStream.h:
* page/scrolling/ScrollingThread.cpp:
(WebCore::ScrollingThread::dispatch):
(WebCore::ScrollingThread::dispatchBarrier):
(WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread):
* page/scrolling/ScrollingThread.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask):
* platform/mediastream/MediaStreamPrivate.cpp:
(WebCore::MediaStreamPrivate::scheduleDeferredTask):
* platform/mediastream/MediaStreamPrivate.h:
* platform/mediastream/mac/AVMediaCaptureSource.h:
* platform/mediastream/mac/AVMediaCaptureSource.mm:
(WebCore::AVMediaCaptureSource::scheduleDeferredTask):

Source/WebKit:

* Storage/StorageSyncManager.cpp:
(WebCore::StorageSyncManager::dispatch):
* Storage/StorageSyncManager.h:
* Storage/StorageThread.cpp:
(WebCore::StorageThread::dispatch):
(WebCore::StorageThread::terminate):
* Storage/StorageThread.h:

Source/WebKit2:

* NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp:
(WebKit::NetworkCache::runTaskInQueue):

Source/WTF:

* wtf/FunctionDispatcher.h:
* wtf/MainThread.cpp:
(WTF::functionQueue):
(WTF::dispatchFunctionsFromMainThread):
(WTF::callOnMainThread):
* wtf/MainThread.h:
* wtf/NoncopyableFunction.h:
* wtf/RunLoop.cpp:
(WTF::RunLoop::performWork):
(WTF::RunLoop::dispatch):
* wtf/RunLoop.h:
* wtf/WorkQueue.h:
* wtf/cocoa/WorkQueueCocoa.cpp:
(WTF::WorkQueue::dispatch):
(WTF::WorkQueue::dispatchAfter):
* wtf/efl/DispatchQueueWorkItemEfl.h:
(WorkItem::WorkItem):
(TimerWorkItem::create):
(TimerWorkItem::TimerWorkItem):
* wtf/efl/WorkQueueEfl.cpp:
(WTF::WorkQueue::dispatch):
(WTF::WorkQueue::dispatchAfter):
* wtf/generic/RunLoopGeneric.cpp:
(WTF::RunLoop::TimerBase::ScheduledTask::create):
(WTF::RunLoop::TimerBase::ScheduledTask::ScheduledTask):
(WTF::RunLoop::dispatchAfter):
* wtf/generic/WorkQueueGeneric.cpp:
(WorkQueue::dispatch):
(WorkQueue::dispatchAfter):
* wtf/glib/RunLoopGLib.cpp:
(WTF::DispatchAfterContext::DispatchAfterContext):
(WTF::RunLoop::dispatchAfter):
* wtf/win/WorkItemWin.cpp:
(WTF::WorkItemWin::WorkItemWin):
(WTF::WorkItemWin::create):
(WTF::HandleWorkItem::HandleWorkItem):
(WTF::HandleWorkItem::createByAdoptingHandle):
* wtf/win/WorkItemWin.h:
(WTF::WorkItemWin::function):
* wtf/win/WorkQueueWin.cpp:
(WTF::WorkQueue::dispatch):
(WTF::WorkQueue::dispatchAfter):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (201492 => 201493)


--- trunk/Source/WTF/ChangeLog	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/ChangeLog	2016-05-29 04:20:06 UTC (rev 201493)
@@ -1,3 +1,58 @@
+2016-05-28  Chris Dumez  <[email protected]>
+
+        Templatize NoncopyableFunction class similarly to std::function
+        https://bugs.webkit.org/show_bug.cgi?id=158185
+
+        Reviewed by Darin Adler.
+
+        Templatize NoncopyableFunction class similarly to std::function, so
+        that it can be used as a std::function replacement in more places.
+
+        Previously, NoncopyableFunction could only support "void()" lambdas.
+
+        * wtf/FunctionDispatcher.h:
+        * wtf/MainThread.cpp:
+        (WTF::functionQueue):
+        (WTF::dispatchFunctionsFromMainThread):
+        (WTF::callOnMainThread):
+        * wtf/MainThread.h:
+        * wtf/NoncopyableFunction.h:
+        * wtf/RunLoop.cpp:
+        (WTF::RunLoop::performWork):
+        (WTF::RunLoop::dispatch):
+        * wtf/RunLoop.h:
+        * wtf/WorkQueue.h:
+        * wtf/cocoa/WorkQueueCocoa.cpp:
+        (WTF::WorkQueue::dispatch):
+        (WTF::WorkQueue::dispatchAfter):
+        * wtf/efl/DispatchQueueWorkItemEfl.h:
+        (WorkItem::WorkItem):
+        (TimerWorkItem::create):
+        (TimerWorkItem::TimerWorkItem):
+        * wtf/efl/WorkQueueEfl.cpp:
+        (WTF::WorkQueue::dispatch):
+        (WTF::WorkQueue::dispatchAfter):
+        * wtf/generic/RunLoopGeneric.cpp:
+        (WTF::RunLoop::TimerBase::ScheduledTask::create):
+        (WTF::RunLoop::TimerBase::ScheduledTask::ScheduledTask):
+        (WTF::RunLoop::dispatchAfter):
+        * wtf/generic/WorkQueueGeneric.cpp:
+        (WorkQueue::dispatch):
+        (WorkQueue::dispatchAfter):
+        * wtf/glib/RunLoopGLib.cpp:
+        (WTF::DispatchAfterContext::DispatchAfterContext):
+        (WTF::RunLoop::dispatchAfter):
+        * wtf/win/WorkItemWin.cpp:
+        (WTF::WorkItemWin::WorkItemWin):
+        (WTF::WorkItemWin::create):
+        (WTF::HandleWorkItem::HandleWorkItem):
+        (WTF::HandleWorkItem::createByAdoptingHandle):
+        * wtf/win/WorkItemWin.h:
+        (WTF::WorkItemWin::function):
+        * wtf/win/WorkQueueWin.cpp:
+        (WTF::WorkQueue::dispatch):
+        (WTF::WorkQueue::dispatchAfter):
+
 2016-05-28  Dan Bernstein  <[email protected]>
 
         Build fix for projects that include MainThread.h without including FastMalloc.h.

Modified: trunk/Source/WTF/wtf/FunctionDispatcher.h (201492 => 201493)


--- trunk/Source/WTF/wtf/FunctionDispatcher.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/FunctionDispatcher.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -39,7 +39,7 @@
 public:
     WTF_EXPORT_PRIVATE virtual ~FunctionDispatcher();
 
-    virtual void dispatch(NoncopyableFunction&&) = 0;
+    virtual void dispatch(NoncopyableFunction<void ()>&&) = 0;
 
 protected:
     WTF_EXPORT_PRIVATE FunctionDispatcher();

Modified: trunk/Source/WTF/wtf/MainThread.cpp (201492 => 201493)


--- trunk/Source/WTF/wtf/MainThread.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/MainThread.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -47,9 +47,9 @@
 
 static StaticLock mainThreadFunctionQueueMutex;
 
-static Deque<NoncopyableFunction>& functionQueue()
+static Deque<NoncopyableFunction<void ()>>& functionQueue()
 {
-    static NeverDestroyed<Deque<NoncopyableFunction>> functionQueue;
+    static NeverDestroyed<Deque<NoncopyableFunction<void ()>>> functionQueue;
     return functionQueue;
 }
 
@@ -120,7 +120,7 @@
 
     auto startTime = std::chrono::steady_clock::now();
 
-    NoncopyableFunction function;
+    NoncopyableFunction<void ()> function;
 
     while (true) {
         {
@@ -144,7 +144,7 @@
     }
 }
 
-void callOnMainThread(NoncopyableFunction&& function)
+void callOnMainThread(NoncopyableFunction<void ()>&& function)
 {
     ASSERT(function);
 

Modified: trunk/Source/WTF/wtf/MainThread.h (201492 => 201493)


--- trunk/Source/WTF/wtf/MainThread.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/MainThread.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -41,7 +41,7 @@
 // Must be called from the main thread.
 WTF_EXPORT_PRIVATE void initializeMainThread();
 
-WTF_EXPORT_PRIVATE void callOnMainThread(NoncopyableFunction&&);
+WTF_EXPORT_PRIVATE void callOnMainThread(NoncopyableFunction<void ()>&&);
 
 #if PLATFORM(COCOA)
 WTF_EXPORT_PRIVATE void callOnWebThreadOrDispatchAsyncOnMainThread(void (^block)());

Modified: trunk/Source/WTF/wtf/NoncopyableFunction.h (201492 => 201493)


--- trunk/Source/WTF/wtf/NoncopyableFunction.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/NoncopyableFunction.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -30,8 +30,10 @@
 
 namespace WTF {
 
-// FIXME: We could make this templated to support other lambdas than void() and make this more reusable.
-class NoncopyableFunction {
+template<typename> class NoncopyableFunction;
+
+template <typename Out, typename... In>
+class NoncopyableFunction<Out(In...)> {
 public:
     NoncopyableFunction() = default;
 
@@ -41,10 +43,11 @@
     {
     }
 
-    void operator()() const
+    Out operator()(In... in) const
     {
         if (m_callableWrapper)
-            m_callableWrapper->call();
+            return m_callableWrapper->call(std::forward<In>(in)...);
+        return Out();
     }
 
     explicit operator bool() const { return !!m_callableWrapper; }
@@ -68,11 +71,11 @@
     public:
         virtual ~CallableWrapperBase() { }
 
-        virtual void call() = 0;
+        virtual Out call(In...) = 0;
     };
 
     template<typename CallableType>
-    class CallableWrapper final : public CallableWrapperBase {
+    class CallableWrapper : public CallableWrapperBase {
     public:
         explicit CallableWrapper(CallableType&& callable)
             : m_callable(WTFMove(callable))
@@ -82,7 +85,7 @@
         CallableWrapper(const CallableWrapper&) = delete;
         CallableWrapper& operator=(const CallableWrapper&) = delete;
 
-        void call() final { m_callable(); }
+        Out call(In... in) final { return m_callable(std::forward<In>(in)...); }
 
     private:
         CallableType m_callable;

Modified: trunk/Source/WTF/wtf/RunLoop.cpp (201492 => 201493)


--- trunk/Source/WTF/wtf/RunLoop.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/RunLoop.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -91,7 +91,7 @@
 
     size_t functionsToHandle = 0;
     {
-        NoncopyableFunction function;
+        NoncopyableFunction<void ()> function;
         {
             MutexLocker locker(m_functionQueueLock);
             functionsToHandle = m_functionQueue.size();
@@ -106,7 +106,7 @@
     }
 
     for (size_t functionsHandled = 1; functionsHandled < functionsToHandle; ++functionsHandled) {
-        NoncopyableFunction function;
+        NoncopyableFunction<void ()> function;
         {
             MutexLocker locker(m_functionQueueLock);
 
@@ -123,7 +123,7 @@
     }
 }
 
-void RunLoop::dispatch(NoncopyableFunction&& function)
+void RunLoop::dispatch(NoncopyableFunction<void ()>&& function)
 {
     {
         MutexLocker locker(m_functionQueueLock);

Modified: trunk/Source/WTF/wtf/RunLoop.h (201492 => 201493)


--- trunk/Source/WTF/wtf/RunLoop.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/RunLoop.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -59,7 +59,7 @@
     WTF_EXPORT_PRIVATE static bool isMain();
     ~RunLoop();
 
-    void dispatch(NoncopyableFunction&&) override;
+    void dispatch(NoncopyableFunction<void ()>&&) override;
 
     WTF_EXPORT_PRIVATE static void run();
     WTF_EXPORT_PRIVATE void stop();
@@ -79,7 +79,7 @@
 #endif
 
 #if USE(GLIB_EVENT_LOOP) || USE(GENERIC_EVENT_LOOP)
-    WTF_EXPORT_PRIVATE void dispatchAfter(std::chrono::nanoseconds, NoncopyableFunction&&);
+    WTF_EXPORT_PRIVATE void dispatchAfter(std::chrono::nanoseconds, NoncopyableFunction<void ()>&&);
 #endif
 
     class TimerBase {
@@ -155,7 +155,7 @@
     void performWork();
 
     Mutex m_functionQueueLock;
-    Deque<NoncopyableFunction> m_functionQueue;
+    Deque<NoncopyableFunction<void ()>> m_functionQueue;
 
 #if USE(WINDOWS_EVENT_LOOP)
     static bool registerRunLoopMessageWindowClass();

Modified: trunk/Source/WTF/wtf/WorkQueue.h (201492 => 201493)


--- trunk/Source/WTF/wtf/WorkQueue.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/WorkQueue.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -72,8 +72,8 @@
     WTF_EXPORT_PRIVATE static Ref<WorkQueue> create(const char* name, Type = Type::Serial, QOS = QOS::Default);
     virtual ~WorkQueue();
 
-    WTF_EXPORT_PRIVATE void dispatch(NoncopyableFunction&&) override;
-    WTF_EXPORT_PRIVATE void dispatchAfter(std::chrono::nanoseconds, NoncopyableFunction&&);
+    WTF_EXPORT_PRIVATE void dispatch(NoncopyableFunction<void ()>&&) override;
+    WTF_EXPORT_PRIVATE void dispatchAfter(std::chrono::nanoseconds, NoncopyableFunction<void ()>&&);
 
     WTF_EXPORT_PRIVATE static void concurrentApply(size_t iterations, const std::function<void (size_t index)>&);
 

Modified: trunk/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp (201492 => 201493)


--- trunk/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -28,10 +28,10 @@
 
 namespace WTF {
 
-void WorkQueue::dispatch(NoncopyableFunction&& function)
+void WorkQueue::dispatch(NoncopyableFunction<void ()>&& function)
 {
     ref();
-    auto* functionPtr = new NoncopyableFunction(WTFMove(function));
+    auto* functionPtr = new NoncopyableFunction<void ()>(WTFMove(function));
     dispatch_async(m_dispatchQueue, ^{
         (*functionPtr)();
         delete functionPtr;
@@ -39,10 +39,10 @@
     });
 }
 
-void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction&& function)
+void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction<void ()>&& function)
 {
     ref();
-    auto* functionPtr = new NoncopyableFunction(WTFMove(function));
+    auto* functionPtr = new NoncopyableFunction<void ()>(WTFMove(function));
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, duration.count()), m_dispatchQueue, ^{
         (*functionPtr)();
         delete functionPtr;

Modified: trunk/Source/WTF/wtf/efl/DispatchQueueWorkItemEfl.h (201492 => 201493)


--- trunk/Source/WTF/wtf/efl/DispatchQueueWorkItemEfl.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/efl/DispatchQueueWorkItemEfl.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -34,7 +34,7 @@
 
 class WorkItem {
 public:
-    WorkItem(Ref<WorkQueue>&& workQueue, NoncopyableFunction&& function)
+    WorkItem(Ref<WorkQueue>&& workQueue, NoncopyableFunction<void ()>&& function)
         : m_workQueue(WTFMove(workQueue))
         , m_function(WTFMove(function))
     {
@@ -44,12 +44,12 @@
 
 private:
     Ref<WorkQueue> m_workQueue;
-    NoncopyableFunction m_function;
+    NoncopyableFunction<void ()> m_function;
 };
 
 class TimerWorkItem : public WorkItem {
 public:
-    static std::unique_ptr<TimerWorkItem> create(Ref<WorkQueue>&& workQueue, NoncopyableFunction&& function, std::chrono::nanoseconds delayNanoSeconds)
+    static std::unique_ptr<TimerWorkItem> create(Ref<WorkQueue>&& workQueue, NoncopyableFunction<void ()>&& function, std::chrono::nanoseconds delayNanoSeconds)
     {
         ASSERT(delayNanoSeconds.count() >= 0);
         return std::unique_ptr<TimerWorkItem>(new TimerWorkItem(WTFMove(workQueue), WTFMove(function), monotonicallyIncreasingTime() * 1000000000.0 + delayNanoSeconds.count()));
@@ -58,7 +58,7 @@
     bool hasExpired(double currentTimeNanoSeconds) const { return currentTimeNanoSeconds >= m_expirationTimeNanoSeconds; }
 
 protected:
-    TimerWorkItem(Ref<WorkQueue>&& workQueue, NoncopyableFunction&& function, double expirationTimeNanoSeconds)
+    TimerWorkItem(Ref<WorkQueue>&& workQueue, NoncopyableFunction<void ()>&& function, double expirationTimeNanoSeconds)
         : WorkItem(WTFMove(workQueue), WTFMove(function))
         , m_expirationTimeNanoSeconds(expirationTimeNanoSeconds)
     {

Modified: trunk/Source/WTF/wtf/efl/WorkQueueEfl.cpp (201492 => 201493)


--- trunk/Source/WTF/wtf/efl/WorkQueueEfl.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/efl/WorkQueueEfl.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -54,7 +54,7 @@
     m_dispatchQueue->clearSocketEventHandler();
 }
 
-void WorkQueue::dispatch(NoncopyableFunction&& function)
+void WorkQueue::dispatch(NoncopyableFunction<void ()>&& function)
 {
     if (!m_dispatchQueue)
         return;
@@ -62,7 +62,7 @@
     m_dispatchQueue->dispatch(std::make_unique<WorkItem>(*this, WTFMove(function)));
 }
 
-void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction&& function)
+void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction<void ()>&& function)
 {
     if (!m_dispatchQueue)
         return;

Modified: trunk/Source/WTF/wtf/generic/RunLoopGeneric.cpp (201492 => 201493)


--- trunk/Source/WTF/wtf/generic/RunLoopGeneric.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/generic/RunLoopGeneric.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -32,12 +32,12 @@
 class RunLoop::TimerBase::ScheduledTask : public ThreadSafeRefCounted<ScheduledTask> {
 WTF_MAKE_NONCOPYABLE(ScheduledTask);
 public:
-    static RefPtr<ScheduledTask> create(NoncopyableFunction&& function, double interval, bool repeating)
+    static RefPtr<ScheduledTask> create(NoncopyableFunction<void ()>&& function, double interval, bool repeating)
     {
         return adoptRef(new ScheduledTask(WTFMove(function), interval, repeating));
     }
 
-    ScheduledTask(NoncopyableFunction&& function, double interval, bool repeating)
+    ScheduledTask(NoncopyableFunction<void ()>&& function, double interval, bool repeating)
         : m_function(WTFMove(function))
         , m_fireInterval(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(interval)))
         , m_isRepeating(repeating)
@@ -90,7 +90,7 @@
     }
 
 private:
-    NoncopyableFunction m_function;
+    NoncopyableFunction<void ()> m_function;
     Condition::Clock::time_point m_scheduledTimePoint;
     std::chrono::microseconds m_fireInterval;
     std::atomic<bool> m_isActive { true };
@@ -237,7 +237,7 @@
     wakeUp(locker);
 }
 
-void RunLoop::dispatchAfter(std::chrono::nanoseconds delay, NoncopyableFunction&& function)
+void RunLoop::dispatchAfter(std::chrono::nanoseconds delay, NoncopyableFunction<void ()>&& function)
 {
     LockHolder locker(m_loopLock);
     bool repeating = false;

Modified: trunk/Source/WTF/wtf/generic/WorkQueueGeneric.cpp (201492 => 201493)


--- trunk/Source/WTF/wtf/generic/WorkQueueGeneric.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/generic/WorkQueueGeneric.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -81,7 +81,7 @@
     }
 }
 
-void WorkQueue::dispatch(NoncopyableFunction&& function)
+void WorkQueue::dispatch(NoncopyableFunction<void ()>&& function)
 {
     RefPtr<WorkQueue> protect(this);
     m_runLoop->dispatch([protect, function = WTFMove(function)] {
@@ -89,7 +89,7 @@
     });
 }
 
-void WorkQueue::dispatchAfter(std::chrono::nanoseconds delay, NoncopyableFunction&& function)
+void WorkQueue::dispatchAfter(std::chrono::nanoseconds delay, NoncopyableFunction<void ()>&& function)
 {
     RefPtr<WorkQueue> protect(this);
     m_runLoop->dispatchAfter(delay, [protect, function = WTFMove(function)] {

Modified: trunk/Source/WTF/wtf/glib/RunLoopGLib.cpp (201492 => 201493)


--- trunk/Source/WTF/wtf/glib/RunLoopGLib.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/glib/RunLoopGLib.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -124,7 +124,7 @@
 class DispatchAfterContext {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    DispatchAfterContext(NoncopyableFunction&& function)
+    DispatchAfterContext(NoncopyableFunction<void ()>&& function)
         : m_function(WTFMove(function))
     {
     }
@@ -135,10 +135,10 @@
     }
 
 private:
-    NoncopyableFunction m_function;
+    NoncopyableFunction<void ()> m_function;
 };
 
-void RunLoop::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction&& function)
+void RunLoop::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction<void ()>&& function)
 {
     GRefPtr<GSource> source = adoptGRef(g_timeout_source_new(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count()));
     g_source_set_name(source.get(), "[WebKit] RunLoop dispatchAfter");

Modified: trunk/Source/WTF/wtf/win/WorkItemWin.cpp (201492 => 201493)


--- trunk/Source/WTF/wtf/win/WorkItemWin.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/win/WorkItemWin.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -32,13 +32,13 @@
 
 namespace WTF {
 
-WorkItemWin::WorkItemWin(NoncopyableFunction&& function, WorkQueue* queue)
+WorkItemWin::WorkItemWin(NoncopyableFunction<void ()>&& function, WorkQueue* queue)
     : m_function(WTFMove(function))
     , m_queue(queue)
 {
 }
 
-RefPtr<WorkItemWin> WorkItemWin::create(NoncopyableFunction&& function, WorkQueue* queue)
+RefPtr<WorkItemWin> WorkItemWin::create(NoncopyableFunction<void ()>&& function, WorkQueue* queue)
 {
     return adoptRef(new WorkItemWin(WTFMove(function), queue));
 }
@@ -47,7 +47,7 @@
 {
 }
 
-HandleWorkItem::HandleWorkItem(HANDLE handle, NoncopyableFunction&& function, WorkQueue* queue)
+HandleWorkItem::HandleWorkItem(HANDLE handle, NoncopyableFunction<void ()>&& function, WorkQueue* queue)
     : WorkItemWin(WTFMove(function), queue)
     , m_handle(handle)
     , m_waitHandle(0)
@@ -55,7 +55,7 @@
     ASSERT_ARG(handle, handle);
 }
 
-RefPtr<HandleWorkItem> HandleWorkItem::createByAdoptingHandle(HANDLE handle, NoncopyableFunction&& function, WorkQueue* queue)
+RefPtr<HandleWorkItem> HandleWorkItem::createByAdoptingHandle(HANDLE handle, NoncopyableFunction<void ()>&& function, WorkQueue* queue)
 {
     return adoptRef(new HandleWorkItem(handle, WTFMove(function), queue));
 }

Modified: trunk/Source/WTF/wtf/win/WorkItemWin.h (201492 => 201493)


--- trunk/Source/WTF/wtf/win/WorkItemWin.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/win/WorkItemWin.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -39,30 +39,30 @@
 
 class WorkItemWin : public ThreadSafeRefCounted<WorkItemWin> {
 public:
-    static RefPtr<WorkItemWin> create(NoncopyableFunction&&, WorkQueue*);
+    static RefPtr<WorkItemWin> create(NoncopyableFunction<void ()>&&, WorkQueue*);
     virtual ~WorkItemWin();
 
-    NoncopyableFunction& function() { return m_function; }
+    NoncopyableFunction<void ()>& function() { return m_function; }
     WorkQueue* queue() const { return m_queue.get(); }
 
 protected:
-    WorkItemWin(NoncopyableFunction&&, WorkQueue*);
+    WorkItemWin(NoncopyableFunction<void ()>&&, WorkQueue*);
 
 private:
-    NoncopyableFunction m_function;
+    NoncopyableFunction<void ()> m_function;
     RefPtr<WorkQueue> m_queue;
 };
 
 class HandleWorkItem : public WorkItemWin {
 public:
-    static RefPtr<HandleWorkItem> createByAdoptingHandle(HANDLE, NoncopyableFunction&&, WorkQueue*);
+    static RefPtr<HandleWorkItem> createByAdoptingHandle(HANDLE, NoncopyableFunction<void ()>&&, WorkQueue*);
     virtual ~HandleWorkItem();
 
     void setWaitHandle(HANDLE waitHandle) { m_waitHandle = waitHandle; }
     HANDLE waitHandle() const { return m_waitHandle; }
 
 private:
-    HandleWorkItem(HANDLE, NoncopyableFunction&&, WorkQueue*);
+    HandleWorkItem(HANDLE, NoncopyableFunction<void ()>&&, WorkQueue*);
 
     HANDLE m_handle;
     HANDLE m_waitHandle;

Modified: trunk/Source/WTF/wtf/win/WorkQueueWin.cpp (201492 => 201493)


--- trunk/Source/WTF/wtf/win/WorkQueueWin.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WTF/wtf/win/WorkQueueWin.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -129,7 +129,7 @@
     ::DeleteTimerQueueEx(m_timerQueue, 0);
 }
 
-void WorkQueue::dispatch(NoncopyableFunction&& function)
+void WorkQueue::dispatch(NoncopyableFunction<void ()>&& function)
 {
     MutexLocker locker(m_workItemQueueLock);
     ref();
@@ -149,7 +149,7 @@
     static RefPtr<TimerContext> create() { return adoptRef(new TimerContext); }
 
     WorkQueue* queue;
-    NoncopyableFunction function;
+    NoncopyableFunction<void ()> function;
     Mutex timerMutex;
     HANDLE timer;
 
@@ -180,7 +180,7 @@
     }
 }
 
-void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction&& function)
+void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, NoncopyableFunction<void ()>&& function)
 {
     ASSERT(m_timerQueue);
     ref();

Modified: trunk/Source/WebCore/ChangeLog (201492 => 201493)


--- trunk/Source/WebCore/ChangeLog	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebCore/ChangeLog	2016-05-29 04:20:06 UTC (rev 201493)
@@ -1,3 +1,41 @@
+2016-05-28  Chris Dumez  <[email protected]>
+
+        Templatize NoncopyableFunction class similarly to std::function
+        https://bugs.webkit.org/show_bug.cgi?id=158185
+
+        Reviewed by Darin Adler.
+
+        Templatize NoncopyableFunction class similarly to std::function, so
+        that it can be used as a std::function replacement in more places.
+
+        Previously, NoncopyableFunction could only support "void()" lambdas.
+
+        * Modules/mediastream/MediaEndpointPeerConnection.cpp:
+        (WebCore::MediaEndpointPeerConnection::runTask):
+        * Modules/mediastream/MediaEndpointPeerConnection.h:
+        * fileapi/AsyncFileStream.cpp:
+        (WebCore::callOnFileThread):
+        (WebCore::AsyncFileStream::perform):
+        (WebCore::AsyncFileStream::getSize):
+        (WebCore::AsyncFileStream::openForRead):
+        (WebCore::AsyncFileStream::openForWrite):
+        (WebCore::AsyncFileStream::write):
+        * fileapi/AsyncFileStream.h:
+        * page/scrolling/ScrollingThread.cpp:
+        (WebCore::ScrollingThread::dispatch):
+        (WebCore::ScrollingThread::dispatchBarrier):
+        (WebCore::ScrollingThread::dispatchFunctionsFromScrollingThread):
+        * page/scrolling/ScrollingThread.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+        (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask):
+        * platform/mediastream/MediaStreamPrivate.cpp:
+        (WebCore::MediaStreamPrivate::scheduleDeferredTask):
+        * platform/mediastream/MediaStreamPrivate.h:
+        * platform/mediastream/mac/AVMediaCaptureSource.h:
+        * platform/mediastream/mac/AVMediaCaptureSource.mm:
+        (WebCore::AVMediaCaptureSource::scheduleDeferredTask):
+
 2016-05-28  Alexey Proskuryakov  <[email protected]>
 
         Fix the build with newer clang and other custom configuration options

Modified: trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp (201492 => 201493)


--- trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -95,7 +95,7 @@
     m_mediaEndpoint->generateDtlsInfo();
 }
 
-void MediaEndpointPeerConnection::runTask(NoncopyableFunction&& task)
+void MediaEndpointPeerConnection::runTask(NoncopyableFunction<void ()>&& task)
 {
     if (m_dtlsFingerprint.isNull()) {
         // Only one task needs to be deferred since it will hold off any others until completed.

Modified: trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h (201492 => 201493)


--- trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -78,7 +78,7 @@
     void clearNegotiationNeededState() override { notImplemented(); };
 
 private:
-    void runTask(NoncopyableFunction&&);
+    void runTask(NoncopyableFunction<void ()>&&);
     void startRunningTasks();
 
     void createOfferTask(RTCOfferOptions&, PeerConnection::SessionDescriptionPromise&);
@@ -92,7 +92,7 @@
     PeerConnectionBackendClient* m_client;
     std::unique_ptr<MediaEndpoint> m_mediaEndpoint;
 
-    NoncopyableFunction m_initialDeferredTask;
+    NoncopyableFunction<void ()> m_initialDeferredTask;
 
     std::unique_ptr<SDPProcessor> m_sdpProcessor;
 

Modified: trunk/Source/WebCore/fileapi/AsyncFileStream.cpp (201492 => 201493)


--- trunk/Source/WebCore/fileapi/AsyncFileStream.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebCore/fileapi/AsyncFileStream.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -64,12 +64,12 @@
 #endif
 }
 
-static void callOnFileThread(NoncopyableFunction&& function)
+static void callOnFileThread(NoncopyableFunction<void ()>&& function)
 {
     ASSERT(isMainThread());
     ASSERT(function);
 
-    static NeverDestroyed<MessageQueue<NoncopyableFunction>> queue;
+    static NeverDestroyed<MessageQueue<NoncopyableFunction<void ()>>> queue;
 
     static std::once_flag createFileThreadOnce;
     std::call_once(createFileThreadOnce, [] {
@@ -90,7 +90,7 @@
         });
     });
 
-    queue.get().append(std::make_unique<NoncopyableFunction>(WTFMove(function)));
+    queue.get().append(std::make_unique<NoncopyableFunction<void ()>>(WTFMove(function)));
 }
 
 AsyncFileStream::AsyncFileStream(FileStreamClient& client)
@@ -114,7 +114,7 @@
     });
 }
 
-void AsyncFileStream::perform(std::function<std::function<void(FileStreamClient&)>(FileStream&)>&& operation)
+void AsyncFileStream::perform(NoncopyableFunction<std::function<void(FileStreamClient&)>(FileStream&)>&& operation)
 {
     auto& internals = *m_internals;
     callOnFileThread([&internals, operation = WTFMove(operation)] {
@@ -134,11 +134,10 @@
 
 void AsyncFileStream::getSize(const String& path, double expectedModificationTime)
 {
-    StringCapture capturedPath(path);
     // FIXME: Explicit return type here and in all the other cases like this below is a workaround for a deficiency
     // in the Windows compiler at the time of this writing. Could remove it if that is resolved.
-    perform([capturedPath, expectedModificationTime](FileStream& stream) -> std::function<void(FileStreamClient&)> {
-        long long size = stream.getSize(capturedPath.string(), expectedModificationTime);
+    perform([path = path.isolatedCopy(), expectedModificationTime](FileStream& stream) -> std::function<void(FileStreamClient&)> {
+        long long size = stream.getSize(path, expectedModificationTime);
         return [size](FileStreamClient& client) {
             client.didGetSize(size);
         };
@@ -147,10 +146,9 @@
 
 void AsyncFileStream::openForRead(const String& path, long long offset, long long length)
 {
-    StringCapture capturedPath(path);
     // FIXME: Explicit return type here is a workaround for a deficiency in the Windows compiler at the time of this writing.
-    perform([capturedPath, offset, length](FileStream& stream) -> std::function<void(FileStreamClient&)> {
-        bool success = stream.openForRead(capturedPath.string(), offset, length);
+    perform([path = path.isolatedCopy(), offset, length](FileStream& stream) -> std::function<void(FileStreamClient&)> {
+        bool success = stream.openForRead(path, offset, length);
         return [success](FileStreamClient& client) {
             client.didOpen(success);
         };
@@ -159,9 +157,8 @@
 
 void AsyncFileStream::openForWrite(const String& path)
 {
-    StringCapture capturedPath(path);
-    perform([capturedPath](FileStream& stream) -> std::function<void(FileStreamClient&)> {
-        bool success = stream.openForWrite(capturedPath.string());
+    perform([path = path.isolatedCopy()](FileStream& stream) -> std::function<void(FileStreamClient&)> {
+        bool success = stream.openForWrite(path);
         return [success](FileStreamClient& client) {
             client.didOpen(success);
         };
@@ -188,9 +185,8 @@
 
 void AsyncFileStream::write(const URL& blobURL, long long position, int length)
 {
-    URLCapture capturedURL(blobURL);
-    perform([capturedURL, position, length](FileStream& stream) -> std::function<void(FileStreamClient&)> {
-        int bytesWritten = stream.write(capturedURL.url(), position, length);
+    perform([blobURL = blobURL.isolatedCopy(), position, length](FileStream& stream) -> std::function<void(FileStreamClient&)> {
+        int bytesWritten = stream.write(blobURL, position, length);
         return [bytesWritten](FileStreamClient& client) {
             client.didWrite(bytesWritten);
         };

Modified: trunk/Source/WebCore/fileapi/AsyncFileStream.h (201492 => 201493)


--- trunk/Source/WebCore/fileapi/AsyncFileStream.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebCore/fileapi/AsyncFileStream.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -34,6 +34,7 @@
 
 #include <functional>
 #include <wtf/Forward.h>
+#include <wtf/NoncopyableFunction.h>
 
 namespace WebCore {
 
@@ -56,7 +57,7 @@
 
 private:
     void start();
-    void perform(std::function<std::function<void(FileStreamClient&)>(FileStream&)>&&);
+    void perform(NoncopyableFunction<std::function<void(FileStreamClient&)>(FileStream&)>&&);
 
     struct Internals;
     std::unique_ptr<Internals> m_internals;

Modified: trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp (201492 => 201493)


--- trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebCore/page/scrolling/ScrollingThread.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -45,7 +45,7 @@
     return threadIdentifier && currentThread() == threadIdentifier;
 }
 
-void ScrollingThread::dispatch(NoncopyableFunction&& function)
+void ScrollingThread::dispatch(NoncopyableFunction<void ()>&& function)
 {
     auto& scrollingThread = ScrollingThread::singleton();
     scrollingThread.createThreadIfNeeded();
@@ -58,7 +58,7 @@
     scrollingThread.wakeUpRunLoop();
 }
 
-void ScrollingThread::dispatchBarrier(NoncopyableFunction&& function)
+void ScrollingThread::dispatchBarrier(NoncopyableFunction<void ()>&& function)
 {
     dispatch([function = WTFMove(function)]() mutable {
         callOnMainThread(WTFMove(function));
@@ -104,7 +104,7 @@
 {
     ASSERT(isCurrentThread());
 
-    Vector<NoncopyableFunction> functions;
+    Vector<NoncopyableFunction<void ()>> functions;
     
     {
         std::lock_guard<Lock> lock(m_functionsMutex);

Modified: trunk/Source/WebCore/page/scrolling/ScrollingThread.h (201492 => 201493)


--- trunk/Source/WebCore/page/scrolling/ScrollingThread.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebCore/page/scrolling/ScrollingThread.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -48,11 +48,11 @@
 
 public:
     static bool isCurrentThread();
-    WEBCORE_EXPORT static void dispatch(NoncopyableFunction&&);
+    WEBCORE_EXPORT static void dispatch(NoncopyableFunction<void ()>&&);
 
     // Will dispatch the given function on the main thread once all pending functions
     // on the scrolling thread have finished executing. Used for synchronization purposes.
-    WEBCORE_EXPORT static void dispatchBarrier(NoncopyableFunction&&);
+    WEBCORE_EXPORT static void dispatchBarrier(NoncopyableFunction<void ()>&&);
 
 private:
     friend NeverDestroyed<ScrollingThread>;
@@ -80,7 +80,7 @@
     Lock m_initializeRunLoopMutex;
 
     Lock m_functionsMutex;
-    Vector<NoncopyableFunction> m_functions;
+    Vector<NoncopyableFunction<void ()>> m_functions;
 
 #if PLATFORM(COCOA)
     // FIXME: We should use WebCore::RunLoop here.

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h (201492 => 201493)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -143,7 +143,7 @@
     void updateTracks();
     void renderingModeChanged();
 
-    void scheduleDeferredTask(NoncopyableFunction&&);
+    void scheduleDeferredTask(NoncopyableFunction<void ()>&&);
 
     enum DisplayMode {
         None,

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (201492 => 201493)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm	2016-05-29 04:20:06 UTC (rev 201493)
@@ -624,7 +624,7 @@
     m_player->networkStateChanged();
 }
 
-void MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask(NoncopyableFunction&& function)
+void MediaPlayerPrivateMediaStreamAVFObjC::scheduleDeferredTask(NoncopyableFunction<void ()>&& function)
 {
     ASSERT(function);
     callOnMainThread([weakThis = createWeakPtr(), function = WTFMove(function)] {

Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp (201492 => 201493)


--- trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -299,7 +299,7 @@
     });
 }
 
-void MediaStreamPrivate::scheduleDeferredTask(NoncopyableFunction&& function)
+void MediaStreamPrivate::scheduleDeferredTask(NoncopyableFunction<void ()>&& function)
 {
     ASSERT(function);
     callOnMainThread([weakThis = createWeakPtr(), function = WTFMove(function)] {

Modified: trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.h (201492 => 201493)


--- trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebCore/platform/mediastream/MediaStreamPrivate.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -112,7 +112,7 @@
     void characteristicsChanged();
     void updateActiveVideoTrack();
 
-    void scheduleDeferredTask(NoncopyableFunction&&);
+    void scheduleDeferredTask(NoncopyableFunction<void ()>&&);
 
     WeakPtrFactory<MediaStreamPrivate> m_weakPtrFactory;
     Vector<Observer*> m_observers;

Modified: trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.h (201492 => 201493)


--- trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -86,7 +86,7 @@
     void setVideoSampleBufferDelegate(AVCaptureVideoDataOutput*);
     void setAudioSampleBufferDelegate(AVCaptureAudioDataOutput*);
 
-    void scheduleDeferredTask(NoncopyableFunction&&);
+    void scheduleDeferredTask(NoncopyableFunction<void ()>&&);
 
 private:
     void setupSession();

Modified: trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm (201492 => 201493)


--- trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVMediaCaptureSource.mm	2016-05-29 04:20:06 UTC (rev 201493)
@@ -240,7 +240,7 @@
     [audioOutput setSampleBufferDelegate:m_objcObserver.get() queue:globaAudioCaptureSerialQueue()];
 }
 
-void AVMediaCaptureSource::scheduleDeferredTask(NoncopyableFunction&& function)
+void AVMediaCaptureSource::scheduleDeferredTask(NoncopyableFunction<void ()>&& function)
 {
     ASSERT(function);
     callOnMainThread([weakThis = createWeakPtr(), function = WTFMove(function)] {

Modified: trunk/Source/WebKit/ChangeLog (201492 => 201493)


--- trunk/Source/WebKit/ChangeLog	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebKit/ChangeLog	2016-05-29 04:20:06 UTC (rev 201493)
@@ -1,3 +1,23 @@
+2016-05-28  Chris Dumez  <[email protected]>
+
+        Templatize NoncopyableFunction class similarly to std::function
+        https://bugs.webkit.org/show_bug.cgi?id=158185
+
+        Reviewed by Darin Adler.
+
+        Templatize NoncopyableFunction class similarly to std::function, so
+        that it can be used as a std::function replacement in more places.
+
+        Previously, NoncopyableFunction could only support "void()" lambdas.
+
+        * Storage/StorageSyncManager.cpp:
+        (WebCore::StorageSyncManager::dispatch):
+        * Storage/StorageSyncManager.h:
+        * Storage/StorageThread.cpp:
+        (WebCore::StorageThread::dispatch):
+        (WebCore::StorageThread::terminate):
+        * Storage/StorageThread.h:
+
 2016-05-27  Chris Dumez  <[email protected]>
 
         callOnMainThread() should not copy captured lambda variables

Modified: trunk/Source/WebKit/Storage/StorageSyncManager.cpp (201492 => 201493)


--- trunk/Source/WebKit/Storage/StorageSyncManager.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebKit/Storage/StorageSyncManager.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -63,7 +63,7 @@
     return pathByAppendingComponent(m_path, databaseIdentifier + ".localstorage");
 }
 
-void StorageSyncManager::dispatch(NoncopyableFunction&& function)
+void StorageSyncManager::dispatch(NoncopyableFunction<void ()>&& function)
 {
     ASSERT(isMainThread());
     ASSERT(m_thread);

Modified: trunk/Source/WebKit/Storage/StorageSyncManager.h (201492 => 201493)


--- trunk/Source/WebKit/Storage/StorageSyncManager.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebKit/Storage/StorageSyncManager.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -43,7 +43,7 @@
     static Ref<StorageSyncManager> create(const String& path);
     ~StorageSyncManager();
 
-    void dispatch(NoncopyableFunction&&);
+    void dispatch(NoncopyableFunction<void ()>&&);
     void close();
 
 private:

Modified: trunk/Source/WebKit/Storage/StorageThread.cpp (201492 => 201493)


--- trunk/Source/WebKit/Storage/StorageThread.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebKit/Storage/StorageThread.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -74,11 +74,11 @@
     }
 }
 
-void StorageThread::dispatch(NoncopyableFunction&& function)
+void StorageThread::dispatch(NoncopyableFunction<void ()>&& function)
 {
     ASSERT(isMainThread());
     ASSERT(!m_queue.killed() && m_threadID);
-    m_queue.append(std::make_unique<NoncopyableFunction>(WTFMove(function)));
+    m_queue.append(std::make_unique<NoncopyableFunction<void ()>>(WTFMove(function)));
 }
 
 void StorageThread::terminate()
@@ -90,7 +90,7 @@
     if (!m_threadID)
         return;
 
-    m_queue.append(std::make_unique<NoncopyableFunction>([this] {
+    m_queue.append(std::make_unique<NoncopyableFunction<void ()>>([this] {
         performTerminate();
     }));
     waitForThreadCompletion(m_threadID);

Modified: trunk/Source/WebKit/Storage/StorageThread.h (201492 => 201493)


--- trunk/Source/WebKit/Storage/StorageThread.h	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebKit/Storage/StorageThread.h	2016-05-29 04:20:06 UTC (rev 201493)
@@ -46,7 +46,7 @@
     bool start();
     void terminate();
 
-    void dispatch(NoncopyableFunction&&);
+    void dispatch(NoncopyableFunction<void ()>&&);
 
     static void releaseFastMallocFreeMemoryInAllThreads();
 
@@ -59,7 +59,7 @@
     void performTerminate();
 
     ThreadIdentifier m_threadID;
-    MessageQueue<NoncopyableFunction> m_queue;
+    MessageQueue<NoncopyableFunction<void ()>> m_queue;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebKit2/ChangeLog (201492 => 201493)


--- trunk/Source/WebKit2/ChangeLog	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebKit2/ChangeLog	2016-05-29 04:20:06 UTC (rev 201493)
@@ -1,3 +1,18 @@
+2016-05-28  Chris Dumez  <[email protected]>
+
+        Templatize NoncopyableFunction class similarly to std::function
+        https://bugs.webkit.org/show_bug.cgi?id=158185
+
+        Reviewed by Darin Adler.
+
+        Templatize NoncopyableFunction class similarly to std::function, so
+        that it can be used as a std::function replacement in more places.
+
+        Previously, NoncopyableFunction could only support "void()" lambdas.
+
+        * NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp:
+        (WebKit::NetworkCache::runTaskInQueue):
+
 2016-05-28  Alexey Proskuryakov  <[email protected]>
 
         Fix the build with newer clang and other custom configuration options

Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp (201492 => 201493)


--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp	2016-05-28 23:16:50 UTC (rev 201492)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelSoup.cpp	2016-05-29 04:20:06 UTC (rev 201493)
@@ -69,7 +69,7 @@
     return adoptRef(*new IOChannel(filePath, type));
 }
 
-static inline void runTaskInQueue(NoncopyableFunction&& task, WorkQueue* queue)
+static inline void runTaskInQueue(NoncopyableFunction<void ()>&& task, WorkQueue* queue)
 {
     if (queue) {
         queue->dispatch(WTFMove(task));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to