Title: [277904] trunk/Source
Revision
277904
Author
cdu...@apple.com
Date
2021-05-21 18:53:38 -0700 (Fri, 21 May 2021)

Log Message

Use CheckedCondition in more places
https://bugs.webkit.org/show_bug.cgi?id=226113

Reviewed by Darin Adler.

Use CheckedCondition in more places to benefit from Clang Thread Safety
Analysis.

Source/WebCore:

* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::DatabaseTaskSynchronizer::waitForTaskCompletion):
(WebCore::DatabaseTaskSynchronizer::taskCompleted):
* Modules/webdatabase/DatabaseTask.h:
(WebCore::DatabaseTaskSynchronizer::WTF_GUARDED_BY_LOCK):
* platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
(webKitWebAudioSrcRenderAndPushFrames):
(webKitWebAudioSrcRenderIteration):
(webKitWebAudioSrcChangeState):
* platform/graphics/gstreamer/ImageDecoderGStreamer.cpp:
(WebCore::ImageDecoderGStreamer::setHasEOS):
(WebCore::ImageDecoderGStreamer::notifySample):
(WebCore::ImageDecoderGStreamer::InnerDecoder::handleMessage):
(WebCore::ImageDecoderGStreamer::InnerDecoder::preparePipeline):
(WebCore::ImageDecoderGStreamer::pushEncodedData):
* platform/graphics/gstreamer/ImageDecoderGStreamer.h:
* platform/graphics/gstreamer/MainThreadNotifier.h:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
(WebCore::MediaPlayerPrivateGStreamer::pushTextureToCompositor):
(WebCore::MediaPlayerPrivateGStreamer::repaint):
(WebCore::MediaPlayerPrivateGStreamer::triggerRepaint):
(WebCore::MediaPlayerPrivateGStreamer::cancelRepaint):
(WebCore::MediaPlayerPrivateGStreamer::pushNextHolePunchBuffer):
(WebCore::MediaPlayerPrivateGStreamer::waitForCDMAttachment):
(WebCore::MediaPlayerPrivateGStreamer::cdmInstanceAttached):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
(WebCore::MediaPlayerPrivateGStreamer::WTF_GUARDED_BY_LOCK):
* platform/graphics/holepunch/MediaPlayerPrivateHolePunch.cpp:
(WebCore::MediaPlayerPrivateHolePunch::pushNextHolePunchBuffer):
* platform/graphics/nicosia/NicosiaImageBufferPipe.cpp:
(Nicosia::NicosiaImageBufferPipeSource::handle):
* platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp:
(Nicosia::GCGLLayer::swapBuffersIfNeeded):
* platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp:
(WebCore::TextureMapperPlatformLayerProxy::~TextureMapperPlatformLayerProxy):
(WebCore::TextureMapperPlatformLayerProxy::activateOnCompositingThread):
(WebCore::TextureMapperPlatformLayerProxy::invalidate):
(WebCore::TextureMapperPlatformLayerProxy::releaseUnusedBuffersTimerFired):
(WebCore::TextureMapperPlatformLayerProxy::swapBuffer):
(WebCore::TextureMapperPlatformLayerProxy::dropCurrentBufferWhilePreservingTexture):
(WebCore::TextureMapperPlatformLayerProxy::scheduleUpdateOnCompositorThread):
(WebCore::TextureMapperPlatformLayerProxy::compositorThreadUpdateTimerFired):
* platform/graphics/texmap/TextureMapperPlatformLayerProxy.h:
(WebCore::TextureMapperPlatformLayerProxy::WTF_RETURNS_LOCK):
(WebCore::TextureMapperPlatformLayerProxy::WTF_GUARDED_BY_LOCK):

Source/WTF:

* wtf/RunLoop.h:
* wtf/SynchronizedFixedQueue.h:
* wtf/WTFSemaphore.h:
* wtf/WorkQueue.cpp:
(WTF::WorkQueue::concurrentApply):
* wtf/generic/RunLoopGeneric.cpp:
(WTF::RunLoop::~RunLoop):
(WTF::RunLoop::populateTasks):
(WTF::RunLoop::runImpl):
(WTF::RunLoop::stop):
(WTF::RunLoop::wakeUpWithLock):
(WTF::RunLoop::wakeUp):
(WTF::RunLoop::schedule):
(WTF::RunLoop::scheduleAndWakeUpWithLock):
(WTF::RunLoop::TimerBase::~TimerBase):
(WTF::RunLoop::TimerBase::start):
(WTF::RunLoop::TimerBase::stop):
(WTF::RunLoop::TimerBase::isActive const):
(WTF::RunLoop::TimerBase::secondsUntilFire const):
* wtf/win/RunLoopWin.cpp:
(WTF::RunLoop::TimerBase::timerFired):
(WTF::RunLoop::TimerBase::start):
(WTF::RunLoop::TimerBase::stop):
(WTF::RunLoop::TimerBase::isActive const):
(WTF::RunLoop::TimerBase::secondsUntilFire const):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (277903 => 277904)


--- trunk/Source/WTF/ChangeLog	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WTF/ChangeLog	2021-05-22 01:53:38 UTC (rev 277904)
@@ -1,3 +1,39 @@
+2021-05-21  Chris Dumez  <cdu...@apple.com>
+
+        Use CheckedCondition in more places
+        https://bugs.webkit.org/show_bug.cgi?id=226113
+
+        Reviewed by Darin Adler.
+
+        Use CheckedCondition in more places to benefit from Clang Thread Safety
+        Analysis.
+
+        * wtf/RunLoop.h:
+        * wtf/SynchronizedFixedQueue.h:
+        * wtf/WTFSemaphore.h:
+        * wtf/WorkQueue.cpp:
+        (WTF::WorkQueue::concurrentApply):
+        * wtf/generic/RunLoopGeneric.cpp:
+        (WTF::RunLoop::~RunLoop):
+        (WTF::RunLoop::populateTasks):
+        (WTF::RunLoop::runImpl):
+        (WTF::RunLoop::stop):
+        (WTF::RunLoop::wakeUpWithLock):
+        (WTF::RunLoop::wakeUp):
+        (WTF::RunLoop::schedule):
+        (WTF::RunLoop::scheduleAndWakeUpWithLock):
+        (WTF::RunLoop::TimerBase::~TimerBase):
+        (WTF::RunLoop::TimerBase::start):
+        (WTF::RunLoop::TimerBase::stop):
+        (WTF::RunLoop::TimerBase::isActive const):
+        (WTF::RunLoop::TimerBase::secondsUntilFire const):
+        * wtf/win/RunLoopWin.cpp:
+        (WTF::RunLoop::TimerBase::timerFired):
+        (WTF::RunLoop::TimerBase::start):
+        (WTF::RunLoop::TimerBase::stop):
+        (WTF::RunLoop::TimerBase::isActive const):
+        (WTF::RunLoop::TimerBase::secondsUntilFire const):
+
 2021-05-21  Wenson Hsieh  <wenson_hs...@apple.com>
 
         [macOS] Adopt QLItem in WKImageExtractionPreviewController

Modified: trunk/Source/WTF/wtf/RunLoop.h (277903 => 277904)


--- trunk/Source/WTF/wtf/RunLoop.h	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WTF/wtf/RunLoop.h	2021-05-22 01:53:38 UTC (rev 277904)
@@ -28,8 +28,8 @@
 #pragma once
 
 #include <functional>
+#include <wtf/CheckedCondition.h>
 #include <wtf/CheckedLock.h>
-#include <wtf/Condition.h>
 #include <wtf/Deque.h>
 #include <wtf/Forward.h>
 #include <wtf/FunctionDispatcher.h>
@@ -145,7 +145,7 @@
         Ref<RunLoop> m_runLoop;
 
 #if USE(WINDOWS_EVENT_LOOP)
-        bool isActive(const AbstractLocker&) const;
+        bool isActiveWithLock() const WTF_REQUIRES_LOCK(m_runLoop->m_loopLock);
         void timerFired();
         MonotonicTime m_nextFireDate;
         Seconds m_interval;
@@ -159,8 +159,8 @@
         bool m_isRepeating { false };
         Seconds m_interval { 0 };
 #elif USE(GENERIC_EVENT_LOOP)
-        bool isActive(const AbstractLocker&) const;
-        void stop(const AbstractLocker&);
+        bool isActiveWithLock() const WTF_REQUIRES_LOCK(m_runLoop->m_loopLock);
+        void stopWithLock() WTF_REQUIRES_LOCK(m_runLoop->m_loopLock);
 
         class ScheduledTask;
         RefPtr<ScheduledTask> m_scheduledTask;
@@ -228,7 +228,7 @@
     LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
     HWND m_runLoopMessageWindow;
 
-    Lock m_loopLock;
+    CheckedLock m_loopLock;
 #elif USE(COCOA_EVENT_LOOP)
     static void performWork(void*);
     RetainPtr<CFRunLoopRef> m_runLoop;
@@ -243,9 +243,9 @@
     WeakHashSet<Observer> m_observers;
 #elif USE(GENERIC_EVENT_LOOP)
     void schedule(Ref<TimerBase::ScheduledTask>&&);
-    void schedule(const AbstractLocker&, Ref<TimerBase::ScheduledTask>&&);
-    void wakeUp(const AbstractLocker&);
-    void scheduleAndWakeUp(const AbstractLocker&, Ref<TimerBase::ScheduledTask>&&);
+    void scheduleWithLock(Ref<TimerBase::ScheduledTask>&&) WTF_REQUIRES_LOCK(m_loopLock);
+    void wakeUpWithLock() WTF_REQUIRES_LOCK(m_loopLock);
+    void scheduleAndWakeUpWithLock(Ref<TimerBase::ScheduledTask>&&) WTF_REQUIRES_LOCK(m_loopLock);
 
     enum class RunMode {
         Iterate,
@@ -261,9 +261,9 @@
 
     friend class TimerBase;
 
-    Lock m_loopLock;
+    CheckedLock m_loopLock;
     Condition m_readyToRun;
-    Condition m_stopCondition;
+    CheckedCondition m_stopCondition;
     Vector<RefPtr<TimerBase::ScheduledTask>> m_schedules;
     Vector<Status*> m_mainLoops;
     bool m_shutdown { false };

Modified: trunk/Source/WTF/wtf/SynchronizedFixedQueue.h (277903 => 277904)


--- trunk/Source/WTF/wtf/SynchronizedFixedQueue.h	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WTF/wtf/SynchronizedFixedQueue.h	2021-05-22 01:53:38 UTC (rev 277904)
@@ -25,9 +25,9 @@
 
 #pragma once
 
-#include <wtf/Condition.h>
+#include <wtf/CheckedCondition.h>
+#include <wtf/CheckedLock.h>
 #include <wtf/Deque.h>
-#include <wtf/Lock.h>
 #include <wtf/ThreadSafeRefCounted.h>
 
 namespace WTF {
@@ -42,7 +42,7 @@
 
     void open()
     {
-        LockHolder lockHolder(m_mutex);
+        Locker locker { m_lock };
         if (m_open)
             return;
 
@@ -53,7 +53,7 @@
 
     void close()
     {
-        LockHolder lockHolder(m_mutex);
+        Locker locker { m_lock };
         if (!m_open)
             return;
 
@@ -64,16 +64,19 @@
 
     bool isOpen()
     {
-        LockHolder lockHolder(m_mutex);
+        Locker locker { m_lock };
         return m_open;
     }
 
     bool enqueue(const T& value)
     {
-        LockHolder lockHolder(m_mutex);
+        Locker locker { m_lock };
 
         // Wait for an empty place to be available in the queue.
-        m_condition.wait(m_mutex, [this]() { return !m_open || m_queue.size() < BufferSize; });
+        m_condition.wait(m_lock, [this] {
+            assertIsHeld(m_lock);
+            return !m_open || m_queue.size() < BufferSize;
+        });
 
         // The queue is closing, exit immediately.
         if (!m_open)
@@ -89,10 +92,13 @@
 
     bool dequeue(T& value)
     {
-        LockHolder lockHolder(m_mutex);
+        Locker locker { m_lock };
 
         // Wait for an item to be added.
-        m_condition.wait(m_mutex, [this]() { return !m_open || m_queue.size(); });
+        m_condition.wait(m_lock, [this] {
+            assertIsHeld(m_lock);
+            return !m_open || m_queue.size();
+        });
 
         // The queue is closing, exit immediately.
         if (!m_open)
@@ -113,11 +119,11 @@
         static_assert(!((BufferSize - 1) & BufferSize), "BufferSize must be power of 2.");
     }
 
-    Lock m_mutex;
-    Condition m_condition;
+    CheckedLock m_lock;
+    CheckedCondition m_condition;
 
-    bool m_open { true };
-    Deque<T, BufferSize> m_queue;
+    bool m_open WTF_GUARDED_BY_LOCK(m_lock) { true };
+    Deque<T, BufferSize> m_queue WTF_GUARDED_BY_LOCK(m_lock);
 };
 
 }

Modified: trunk/Source/WTF/wtf/WTFSemaphore.h (277903 => 277904)


--- trunk/Source/WTF/wtf/WTFSemaphore.h	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WTF/wtf/WTFSemaphore.h	2021-05-22 01:53:38 UTC (rev 277904)
@@ -25,8 +25,8 @@
 
 #pragma once
 
-#include <wtf/Condition.h>
-#include <wtf/Lock.h>
+#include <wtf/CheckedCondition.h>
+#include <wtf/CheckedLock.h>
 #include <wtf/Noncopyable.h>
 
 namespace WTF {
@@ -50,10 +50,10 @@
     bool waitUntil(const TimeWithDynamicClockType& timeout)
     {
         Locker locker { m_lock };
-        bool satisfied = m_condition.waitUntil(m_lock, timeout,
-            [&] {
-                return m_value;
-            });
+        bool satisfied = m_condition.waitUntil(m_lock, timeout, [&] {
+            assertIsHeld(m_lock);
+            return m_value;
+        });
         if (satisfied)
             --m_value;
         return satisfied;
@@ -70,9 +70,9 @@
     }
 
 private:
-    unsigned m_value { 0 };
-    Lock m_lock;
-    Condition m_condition;
+    unsigned m_value WTF_GUARDED_BY_LOCK(m_lock) { 0 };
+    CheckedLock m_lock;
+    CheckedCondition m_condition;
 };
 
 

Modified: trunk/Source/WTF/wtf/WorkQueue.cpp (277903 => 277904)


--- trunk/Source/WTF/wtf/WorkQueue.cpp	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WTF/wtf/WorkQueue.cpp	2021-05-22 01:53:38 UTC (rev 277904)
@@ -28,10 +28,10 @@
 #include <wtf/WorkQueue.h>
 
 #include <mutex>
-#include <wtf/Condition.h>
+#include <wtf/CheckedCondition.h>
+#include <wtf/CheckedLock.h>
 #include <wtf/Deque.h>
 #include <wtf/Function.h>
-#include <wtf/Lock.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/NumberOfCores.h>
 #include <wtf/Ref.h>
@@ -105,8 +105,7 @@
 
         void dispatch(const WTF::Function<void ()>* function)
         {
-            LockHolder holder(m_lock);
-
+            Locker locker { m_lock };
             m_queue.append(function);
             m_condition.notifyOne();
         }
@@ -118,9 +117,9 @@
                 const WTF::Function<void ()>* function;
 
                 {
-                    LockHolder holder(m_lock);
-
+                    Locker locker { m_lock };
                     m_condition.wait(m_lock, [this] {
+                        assertIsHeld(m_lock);
                         return !m_queue.isEmpty();
                     });
 
@@ -131,9 +130,9 @@
             }
         }
 
-        Lock m_lock;
-        Condition m_condition;
-        Deque<const WTF::Function<void ()>*> m_queue;
+        CheckedLock m_lock;
+        CheckedCondition m_condition;
+        Deque<const Function<void()>*> m_queue WTF_GUARDED_BY_LOCK(m_lock);
 
         Vector<Ref<Thread>> m_workers;
     };
@@ -150,10 +149,10 @@
     std::atomic<size_t> currentIndex(0);
     std::atomic<size_t> activeThreads(workerCount + 1);
 
-    Condition condition;
-    Lock lock;
+    CheckedCondition condition;
+    CheckedLock lock;
 
-    WTF::Function<void ()> applier = [&, function = WTFMove(function)] {
+    Function<void ()> applier = [&, function = WTFMove(function)] {
         size_t index;
 
         // Call the function for as long as there are iterations left.
@@ -162,7 +161,7 @@
 
         // If there are no active threads left, signal the caller.
         if (!--activeThreads) {
-            LockHolder holder(lock);
+            Locker locker { lock };
             condition.notifyOne();
         }
     };
@@ -171,7 +170,7 @@
         threadPool->dispatch(&applier);
     applier();
 
-    LockHolder holder(lock);
+    Locker locker { lock };
     condition.wait(lock, [&] { return !activeThreads; });
 }
 #endif

Modified: trunk/Source/WTF/wtf/generic/RunLoopGeneric.cpp (277903 => 277904)


--- trunk/Source/WTF/wtf/generic/RunLoopGeneric.cpp	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WTF/wtf/generic/RunLoopGeneric.cpp	2021-05-22 01:53:38 UTC (rev 277904)
@@ -105,7 +105,7 @@
 
 RunLoop::~RunLoop()
 {
-    LockHolder locker(m_loopLock);
+    Locker locker { m_loopLock };
     m_shutdown = true;
     m_readyToRun.notifyOne();
 
@@ -116,7 +116,7 @@
 
 inline bool RunLoop::populateTasks(RunMode runMode, Status& statusOfThisLoop, Deque<RefPtr<TimerBase::ScheduledTask>>& firedTimers)
 {
-    LockHolder locker(m_loopLock);
+    Locker locker { m_loopLock };
 
     if (runMode == RunMode::Drain) {
         MonotonicTime sleepUntil = MonotonicTime::infinity();
@@ -158,7 +158,7 @@
 
     Status statusOfThisLoop = Status::Clear;
     {
-        LockHolder locker(m_loopLock);
+        Locker locker { m_loopLock };
         m_mainLoops.append(&statusOfThisLoop);
     }
 
@@ -202,7 +202,7 @@
 
 void RunLoop::stop()
 {
-    LockHolder locker(m_loopLock);
+    Locker locker { m_loopLock };
     if (m_mainLoops.isEmpty())
         return;
 
@@ -213,7 +213,7 @@
     }
 }
 
-void RunLoop::wakeUp(const AbstractLocker&)
+void RunLoop::wakeUpWithLock()
 {
     m_pendingTasks = true;
     m_readyToRun.notifyOne();
@@ -224,8 +224,8 @@
 
 void RunLoop::wakeUp()
 {
-    LockHolder locker(m_loopLock);
-    wakeUp(locker);
+    Locker locker { m_loopLock };
+    wakeUpWithLock();
 }
 
 RunLoop::CycleResult RunLoop::cycle(RunLoopMode)
@@ -234,7 +234,7 @@
     return CycleResult::Continue;
 }
 
-void RunLoop::schedule(const AbstractLocker&, Ref<TimerBase::ScheduledTask>&& task)
+void RunLoop::scheduleWithLock(Ref<TimerBase::ScheduledTask>&& task)
 {
     m_schedules.append(task.ptr());
     std::push_heap(m_schedules.begin(), m_schedules.end(), TimerBase::ScheduledTask::EarliestSchedule());
@@ -242,14 +242,14 @@
 
 void RunLoop::schedule(Ref<TimerBase::ScheduledTask>&& task)
 {
-    LockHolder locker(m_loopLock);
-    schedule(locker, WTFMove(task));
+    Locker locker { m_loopLock };
+    scheduleWithLock(WTFMove(task));
 }
 
-void RunLoop::scheduleAndWakeUp(const AbstractLocker& locker, Ref<TimerBase::ScheduledTask>&& task)
+void RunLoop::scheduleAndWakeUpWithLock(Ref<TimerBase::ScheduledTask>&& task)
 {
-    schedule(locker, WTFMove(task));
-    wakeUp(locker);
+    scheduleWithLock(WTFMove(task));
+    wakeUpWithLock();
 }
 
 // Since RunLoop does not own the registered TimerBase,
@@ -262,21 +262,21 @@
 
 RunLoop::TimerBase::~TimerBase()
 {
-    LockHolder locker(m_runLoop->m_loopLock);
-    stop(locker);
+    Locker locker { m_runLoop->m_loopLock };
+    stopWithLock();
 }
 
 void RunLoop::TimerBase::start(Seconds interval, bool repeating)
 {
-    LockHolder locker(m_runLoop->m_loopLock);
-    stop(locker);
+    Locker locker { m_runLoop->m_loopLock };
+    stopWithLock();
     m_scheduledTask = ScheduledTask::create([this] {
         fired();
     }, interval, repeating);
-    m_runLoop->scheduleAndWakeUp(locker, *m_scheduledTask);
+    m_runLoop->scheduleAndWakeUpWithLock(*m_scheduledTask);
 }
 
-void RunLoop::TimerBase::stop(const AbstractLocker&)
+void RunLoop::TimerBase::stopWithLock()
 {
     if (m_scheduledTask) {
         m_scheduledTask->deactivate();
@@ -286,17 +286,17 @@
 
 void RunLoop::TimerBase::stop()
 {
-    LockHolder locker(m_runLoop->m_loopLock);
-    stop(locker);
+    Locker locker { m_runLoop->m_loopLock };
+    stopWithLock();
 }
 
 bool RunLoop::TimerBase::isActive() const
 {
-    LockHolder locker(m_runLoop->m_loopLock);
-    return isActive(locker);
+    Locker locker { m_runLoop->m_loopLock };
+    return isActiveWithLock();
 }
 
-bool RunLoop::TimerBase::isActive(const AbstractLocker&) const
+bool RunLoop::TimerBase::isActiveWithLock() const
 {
     return m_scheduledTask && m_scheduledTask->isActive();
 }
@@ -303,8 +303,8 @@
 
 Seconds RunLoop::TimerBase::secondsUntilFire() const
 {
-    LockHolder locker(m_runLoop->m_loopLock);
-    if (isActive(locker))
+    Locker locker { m_runLoop->m_loopLock };
+    if (isActiveWithLock())
         return std::max<Seconds>(m_scheduledTask->scheduledTimePoint() - MonotonicTime::now(), 0_s);
     return 0_s;
 }

Modified: trunk/Source/WTF/wtf/win/RunLoopWin.cpp (277903 => 277904)


--- trunk/Source/WTF/wtf/win/RunLoopWin.cpp	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WTF/wtf/win/RunLoopWin.cpp	2021-05-22 01:53:38 UTC (rev 277904)
@@ -149,7 +149,7 @@
 void RunLoop::TimerBase::timerFired()
 {
     {
-        LockHolder locker(m_runLoop->m_loopLock);
+        Locker locker { m_runLoop->m_loopLock };
 
         if (!m_isActive)
             return;
@@ -176,7 +176,7 @@
 
 void RunLoop::TimerBase::start(Seconds interval, bool repeat)
 {
-    LockHolder locker(m_runLoop->m_loopLock);
+    Locker locker { m_runLoop->m_loopLock };
     m_isRepeating = repeat;
     m_isActive = true;
     m_interval = interval;
@@ -186,8 +186,8 @@
 
 void RunLoop::TimerBase::stop()
 {
-    LockHolder locker(m_runLoop->m_loopLock);
-    if (!isActive(locker))
+    Locker locker { m_runLoop->m_loopLock };
+    if (!isActiveWithLock())
         return;
 
     m_isActive = false;
@@ -194,7 +194,7 @@
     ::KillTimer(m_runLoop->m_runLoopMessageWindow, bitwise_cast<uintptr_t>(this));
 }
 
-bool RunLoop::TimerBase::isActive(const AbstractLocker&) const
+bool RunLoop::TimerBase::isActiveWithLock() const
 {
     return m_isActive;
 }
@@ -201,14 +201,14 @@
 
 bool RunLoop::TimerBase::isActive() const
 {
-    LockHolder locker(m_runLoop->m_loopLock);
-    return isActive(locker);
+    Locker locker { m_runLoop->m_loopLock };
+    return isActiveWithLock();
 }
 
 Seconds RunLoop::TimerBase::secondsUntilFire() const
 {
-    LockHolder locker(m_runLoop->m_loopLock);
-    if (isActive(locker))
+    Locker locker { m_runLoop->m_loopLock };
+    if (isActiveWithLock())
         return std::max<Seconds>(m_nextFireDate - MonotonicTime::now(), 0_s);
     return 0_s;
 }

Modified: trunk/Source/WebCore/ChangeLog (277903 => 277904)


--- trunk/Source/WebCore/ChangeLog	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebCore/ChangeLog	2021-05-22 01:53:38 UTC (rev 277904)
@@ -1,3 +1,60 @@
+2021-05-21  Chris Dumez  <cdu...@apple.com>
+
+        Use CheckedCondition in more places
+        https://bugs.webkit.org/show_bug.cgi?id=226113
+
+        Reviewed by Darin Adler.
+
+        Use CheckedCondition in more places to benefit from Clang Thread Safety
+        Analysis.
+
+        * Modules/webdatabase/DatabaseTask.cpp:
+        (WebCore::DatabaseTaskSynchronizer::waitForTaskCompletion):
+        (WebCore::DatabaseTaskSynchronizer::taskCompleted):
+        * Modules/webdatabase/DatabaseTask.h:
+        (WebCore::DatabaseTaskSynchronizer::WTF_GUARDED_BY_LOCK):
+        * platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
+        (webKitWebAudioSrcRenderAndPushFrames):
+        (webKitWebAudioSrcRenderIteration):
+        (webKitWebAudioSrcChangeState):
+        * platform/graphics/gstreamer/ImageDecoderGStreamer.cpp:
+        (WebCore::ImageDecoderGStreamer::setHasEOS):
+        (WebCore::ImageDecoderGStreamer::notifySample):
+        (WebCore::ImageDecoderGStreamer::InnerDecoder::handleMessage):
+        (WebCore::ImageDecoderGStreamer::InnerDecoder::preparePipeline):
+        (WebCore::ImageDecoderGStreamer::pushEncodedData):
+        * platform/graphics/gstreamer/ImageDecoderGStreamer.h:
+        * platform/graphics/gstreamer/MainThreadNotifier.h:
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+        (WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer):
+        (WebCore::MediaPlayerPrivateGStreamer::pushTextureToCompositor):
+        (WebCore::MediaPlayerPrivateGStreamer::repaint):
+        (WebCore::MediaPlayerPrivateGStreamer::triggerRepaint):
+        (WebCore::MediaPlayerPrivateGStreamer::cancelRepaint):
+        (WebCore::MediaPlayerPrivateGStreamer::pushNextHolePunchBuffer):
+        (WebCore::MediaPlayerPrivateGStreamer::waitForCDMAttachment):
+        (WebCore::MediaPlayerPrivateGStreamer::cdmInstanceAttached):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
+        (WebCore::MediaPlayerPrivateGStreamer::WTF_GUARDED_BY_LOCK):
+        * platform/graphics/holepunch/MediaPlayerPrivateHolePunch.cpp:
+        (WebCore::MediaPlayerPrivateHolePunch::pushNextHolePunchBuffer):
+        * platform/graphics/nicosia/NicosiaImageBufferPipe.cpp:
+        (Nicosia::NicosiaImageBufferPipeSource::handle):
+        * platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp:
+        (Nicosia::GCGLLayer::swapBuffersIfNeeded):
+        * platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp:
+        (WebCore::TextureMapperPlatformLayerProxy::~TextureMapperPlatformLayerProxy):
+        (WebCore::TextureMapperPlatformLayerProxy::activateOnCompositingThread):
+        (WebCore::TextureMapperPlatformLayerProxy::invalidate):
+        (WebCore::TextureMapperPlatformLayerProxy::releaseUnusedBuffersTimerFired):
+        (WebCore::TextureMapperPlatformLayerProxy::swapBuffer):
+        (WebCore::TextureMapperPlatformLayerProxy::dropCurrentBufferWhilePreservingTexture):
+        (WebCore::TextureMapperPlatformLayerProxy::scheduleUpdateOnCompositorThread):
+        (WebCore::TextureMapperPlatformLayerProxy::compositorThreadUpdateTimerFired):
+        * platform/graphics/texmap/TextureMapperPlatformLayerProxy.h:
+        (WebCore::TextureMapperPlatformLayerProxy::WTF_RETURNS_LOCK):
+        (WebCore::TextureMapperPlatformLayerProxy::WTF_GUARDED_BY_LOCK):
+
 2021-05-21  Diego Pino Garcia  <dp...@igalia.com>
 
         Set CanvasImageSmoothing.imageSmoothingQuality value to 'low' as default

Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseTask.cpp (277903 => 277904)


--- trunk/Source/WebCore/Modules/webdatabase/DatabaseTask.cpp	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseTask.cpp	2021-05-22 01:53:38 UTC (rev 277904)
@@ -41,18 +41,16 @@
 
 void DatabaseTaskSynchronizer::waitForTaskCompletion()
 {
-    m_synchronousMutex.lock();
+    Locker locker { m_synchronousLock };
     while (!m_taskCompleted)
-        m_synchronousCondition.wait(m_synchronousMutex);
-    m_synchronousMutex.unlock();
+        m_synchronousCondition.wait(m_synchronousLock);
 }
 
 void DatabaseTaskSynchronizer::taskCompleted()
 {
-    m_synchronousMutex.lock();
+    Locker locker { m_synchronousLock };
     m_taskCompleted = true;
     m_synchronousCondition.notifyOne();
-    m_synchronousMutex.unlock();
 }
 
 DatabaseTask::DatabaseTask(Database& database, DatabaseTaskSynchronizer* synchronizer)

Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseTask.h (277903 => 277904)


--- trunk/Source/WebCore/Modules/webdatabase/DatabaseTask.h	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseTask.h	2021-05-22 01:53:38 UTC (rev 277904)
@@ -29,9 +29,9 @@
 #pragma once
 
 #include "ExceptionOr.h"
-#include <wtf/Condition.h>
+#include <wtf/CheckedCondition.h>
+#include <wtf/CheckedLock.h>
 #include <wtf/Forward.h>
-#include <wtf/Lock.h>
 
 namespace WebCore {
 
@@ -57,9 +57,9 @@
 #endif
 
 private:
-    bool m_taskCompleted { false };
-    Lock m_synchronousMutex;
-    Condition m_synchronousCondition;
+    bool m_taskCompleted WTF_GUARDED_BY_LOCK(m_synchronousLock) { false };
+    CheckedLock m_synchronousLock;
+    CheckedCondition m_synchronousCondition;
 #if ASSERT_ENABLED
     bool m_hasCheckedForTermination { false };
 #endif

Modified: trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp (277903 => 277904)


--- trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp	2021-05-22 01:53:38 UTC (rev 277904)
@@ -31,8 +31,8 @@
 #include <gst/app/gstappsrc.h>
 #include <gst/audio/audio-info.h>
 #include <gst/pbutils/missing-plugins.h>
-#include <wtf/Condition.h>
-#include <wtf/Lock.h>
+#include <wtf/CheckedCondition.h>
+#include <wtf/CheckedLock.h>
 #include <wtf/Scope.h>
 #include <wtf/glib/GUniquePtr.h>
 #include <wtf/glib/WTFGType.h>
@@ -84,9 +84,9 @@
     Lock dispatchToRenderThreadLock;
     Function<void(Function<void()>&&)> dispatchToRenderThreadFunction;
 
-    bool dispatchDone;
-    Lock dispatchLock;
-    Condition dispatchCondition;
+    bool dispatchDone WTF_GUARDED_BY_LOCK(dispatchLock);
+    CheckedLock dispatchLock;
+    CheckedCondition dispatchCondition;
 
     _WebKitWebAudioSrcPrivate()
     {
@@ -339,7 +339,7 @@
     auto* priv = src->priv;
 
     auto notifyDispatchOnExit = makeScopeExit([priv] {
-        LockHolder lock(priv->dispatchLock);
+        Locker locker { priv->dispatchLock };
         priv->dispatchDone = true;
         priv->dispatchCondition.notifyOne();
     });
@@ -404,7 +404,7 @@
     }
 
     {
-        LockHolder lock(priv->dispatchLock);
+        Locker locker { priv->dispatchLock };
         priv->dispatchDone = false;
     }
 
@@ -421,7 +421,7 @@
     }
 
     {
-        LockHolder lock(priv->dispatchLock);
+        Locker locker { priv->dispatchLock };
         if (!priv->dispatchDone)
             priv->dispatchCondition.wait(priv->dispatchLock);
     }
@@ -468,7 +468,7 @@
     }
     case GST_STATE_CHANGE_PAUSED_TO_READY:
         {
-            LockHolder lock(priv->dispatchLock);
+            Locker locker { priv->dispatchLock };
             priv->dispatchDone = false;
             priv->dispatchCondition.notifyAll();
         }

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp (277903 => 277904)


--- trunk/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp	2021-05-22 01:53:38 UTC (rev 277904)
@@ -276,13 +276,13 @@
 {
     GST_DEBUG("EOS on decoder %p", this);
     {
-        LockHolder lock(m_sampleMutex);
+        Locker locker { m_sampleLock };
         m_eos = true;
         m_sampleCondition.notifyOne();
     }
     {
-        LockHolder lock(m_handlerMutex);
-        m_handlerCondition.wait(m_handlerMutex);
+        Locker locker { m_handlerLock };
+        m_handlerCondition.wait(m_handlerLock);
     }
 }
 
@@ -289,13 +289,13 @@
 void ImageDecoderGStreamer::notifySample(GRefPtr<GstSample>&& sample)
 {
     {
-        LockHolder lock(m_sampleMutex);
+        Locker locker { m_sampleLock };
         m_sample = WTFMove(sample);
         m_sampleCondition.notifyOne();
     }
     {
-        LockHolder lock(m_handlerMutex);
-        m_handlerCondition.wait(m_handlerMutex);
+        Locker locker { m_handlerLock };
+        m_handlerCondition.wait(m_handlerLock);
     }
 }
 
@@ -306,7 +306,7 @@
     auto scopeExit = makeScopeExit([protectedThis = makeWeakPtr(this)] {
         if (!protectedThis)
             return;
-        LockHolder lock(protectedThis->m_messageLock);
+        Locker locker { protectedThis->m_messageLock };
         protectedThis->m_messageDispatched = true;
         protectedThis->m_messageCondition.notifyOne();
     });
@@ -365,7 +365,7 @@
         auto& decoder = *static_cast<ImageDecoderGStreamer::InnerDecoder*>(userData);
 
         {
-            LockHolder lock(decoder.m_messageLock);
+            Locker locker { decoder.m_messageLock };
             decoder.m_messageDispatched = false;
             decoder.m_messageCondition.notifyOne();
         }
@@ -380,7 +380,7 @@
             });
         }
         if (!decoder.m_messageDispatched) {
-            LockHolder lock(decoder.m_messageLock);
+            Locker locker { decoder.m_messageLock };
             decoder.m_messageCondition.wait(decoder.m_messageLock);
         }
         gst_message_unref(message);
@@ -426,13 +426,13 @@
     thread->detach();
     bool isEOS = false;
     {
-        LockHolder lock(m_sampleMutex);
+        Locker locker { m_sampleLock };
         isEOS = m_eos;
     }
     while (!isEOS) {
         {
-            LockHolder lock(m_sampleMutex);
-            m_sampleCondition.wait(m_sampleMutex);
+            Locker locker { m_sampleLock };
+            m_sampleCondition.wait(m_sampleLock);
             isEOS = m_eos;
             if (m_sample) {
                 auto* caps = gst_sample_get_caps(m_sample.get());
@@ -444,7 +444,7 @@
             }
         }
         {
-            LockHolder lock(m_handlerMutex);
+            Locker locker { m_handlerLock };
             m_handlerCondition.notifyAll();
         }
     }

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.h (277903 => 277904)


--- trunk/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.h	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.h	2021-05-22 01:53:38 UTC (rev 277904)
@@ -26,6 +26,8 @@
 #include "MIMETypeRegistry.h"
 #include "SampleMap.h"
 #include "SharedBuffer.h"
+#include <wtf/CheckedCondition.h>
+#include <wtf/CheckedLock.h>
 #include <wtf/Forward.h>
 #include <wtf/RunLoop.h>
 #include <wtf/WeakPtr.h>
@@ -114,9 +116,9 @@
         GRefPtr<GstElement> m_decodebin;
         RunLoop& m_runLoop;
 
-        Condition m_messageCondition;
-        Lock m_messageLock;
-        bool m_messageDispatched { false };
+        CheckedCondition m_messageCondition;
+        CheckedLock m_messageLock;
+        bool m_messageDispatched WTF_GUARDED_BY_LOCK(m_messageLock) { false };
     };
 
     void handleSample(GRefPtr<GstSample>&&);
@@ -132,11 +134,11 @@
     Optional<IntSize> m_size;
     String m_mimeType;
     RefPtr<ImageDecoderGStreamer::InnerDecoder> m_innerDecoder;
-    Condition m_sampleCondition;
-    Lock m_sampleMutex;
-    GRefPtr<GstSample> m_sample;
-    Condition m_handlerCondition;
-    Lock m_handlerMutex;
+    CheckedCondition m_sampleCondition;
+    CheckedLock m_sampleLock;
+    GRefPtr<GstSample> m_sample WTF_GUARDED_BY_LOCK(m_sampleLock);
+    CheckedCondition m_handlerCondition;
+    CheckedLock m_handlerLock;
 };
 }
 #endif

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MainThreadNotifier.h (277903 => 277904)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MainThreadNotifier.h	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MainThreadNotifier.h	2021-05-22 01:53:38 UTC (rev 277904)
@@ -68,18 +68,18 @@
     template<typename F>
     void notifyAndWait(T notificationType, F&& callbackFunctor)
     {
-        Lock mutex;
-        Condition condition;
+        CheckedLock lock;
+        CheckedCondition condition;
 
-        notify(notificationType, [functor = WTFMove(callbackFunctor), &condition, &mutex] {
+        notify(notificationType, [functor = WTFMove(callbackFunctor), &condition, &lock] {
             functor();
-            LockHolder holder(mutex);
+            Locker locker { lock };
             condition.notifyOne();
         });
 
         if (!isMainThread()) {
-            LockHolder holder(mutex);
-            condition.wait(mutex);
+            Locker locker { lock };
+            condition.wait(lock);
         }
     }
 

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (277903 => 277904)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp	2021-05-22 01:53:38 UTC (rev 277904)
@@ -252,7 +252,7 @@
 
 #if ENABLE(ENCRYPTED_MEDIA)
     {
-        LockHolder lock(m_cdmAttachmentMutex);
+        Locker cdmAttachmentLocker { m_cdmAttachmentLock };
         m_cdmAttachmentCondition.notifyAll();
     }
 #endif
@@ -2921,7 +2921,7 @@
     auto proxyOperation =
         [this, internalCompositingOperation](TextureMapperPlatformLayerProxy& proxy)
         {
-            LockHolder holder(proxy.lock());
+            Locker locker { proxy.lock() };
 
             if (!proxy.isActive())
                 return;
@@ -2939,7 +2939,7 @@
     auto proxyOperation =
         [this, internalCompositingOperation](TextureMapperPlatformLayerProxy& proxy)
         {
-            LockHolder holder(proxy.lock());
+            Locker locker { proxy.lock() };
 
             if (!proxy.isActive())
                 return;
@@ -2964,7 +2964,7 @@
 
     m_player->repaint();
 
-    LockHolder lock(m_drawMutex);
+    Locker locker { m_drawLock };
     m_drawCondition.notifyOne();
 }
 
@@ -3103,17 +3103,17 @@
     }
 
     if (!m_canRenderingBeAccelerated) {
-        LockHolder locker(m_drawMutex);
+        Locker locker { m_drawLock };
         if (m_isBeingDestroyed)
             return;
         m_drawTimer.startOneShot(0_s);
-        m_drawCondition.wait(m_drawMutex);
+        m_drawCondition.wait(m_drawLock);
         return;
     }
 
 #if USE(TEXTURE_MAPPER_GL)
     if (m_isUsingFallbackVideoSink) {
-        LockHolder lock(m_drawMutex);
+        Locker locker { m_drawLock };
         auto proxyOperation =
             [this](TextureMapperPlatformLayerProxy& proxy)
             {
@@ -3127,7 +3127,7 @@
             return;
 #endif
         m_drawTimer.startOneShot(0_s);
-        m_drawCondition.wait(m_drawMutex);
+        m_drawCondition.wait(m_drawLock);
     } else
         pushTextureToCompositor();
 #endif // USE(TEXTURE_MAPPER_GL)
@@ -3149,7 +3149,7 @@
     // This function is also used when destroying the player (destroying parameter is true), to release the gstreamer thread from
     // m_drawCondition and to ensure that new triggerRepaint calls won't wait on m_drawCondition.
     if (!m_canRenderingBeAccelerated) {
-        LockHolder locker(m_drawMutex);
+        Locker locker { m_drawLock };
         m_drawTimer.stop();
         m_isBeingDestroyed = destroying;
         m_drawCondition.notifyOne();
@@ -3180,10 +3180,14 @@
     bool shouldWait = m_videoDecoderPlatform == GstVideoDecoderPlatform::Video4Linux;
     auto proxyOperation = [shouldWait, pipeline = pipeline()](TextureMapperPlatformLayerProxy& proxy) {
         GST_DEBUG_OBJECT(pipeline, "Flushing video sample %s", shouldWait ? "synchronously" : "");
-        LockHolder locker(!shouldWait ? &proxy.lock() : nullptr);
-
-        if (proxy.isActive())
-            proxy.dropCurrentBufferWhilePreservingTexture(shouldWait);
+        if (shouldWait) {
+            if (proxy.isActive())
+                proxy.dropCurrentBufferWhilePreservingTexture(shouldWait);
+        } else {
+            Locker locker { proxy.lock() };
+            if (proxy.isActive())
+                proxy.dropCurrentBufferWhilePreservingTexture(shouldWait);
+        }
     };
 
 #if USE(NICOSIA)
@@ -3407,7 +3411,7 @@
     auto proxyOperation =
         [this](TextureMapperPlatformLayerProxy& proxy)
         {
-            LockHolder holder(proxy.lock());
+            Locker locker { proxy.lock() };
             std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer = makeUnique<TextureMapperPlatformLayerBuffer>(0, m_size, TextureMapperGL::ShouldNotBlend, GL_DONT_CARE);
             std::unique_ptr<GStreamerHolePunchClient> holePunchClient = makeUnique<GStreamerHolePunchClient>(m_videoSink.get());
             layerBuffer->setHolePunchClient(WTFMove(holePunchClient));
@@ -3576,8 +3580,9 @@
 
     bool didCDMAttach = false;
     {
-        auto cdmAttachmentLocker = holdLock(m_cdmAttachmentMutex);
-        didCDMAttach = m_cdmAttachmentCondition.waitFor(m_cdmAttachmentMutex, 4_s, [this]() {
+        Locker cdmAttachmentLocker { m_cdmAttachmentLock };
+        didCDMAttach = m_cdmAttachmentCondition.waitFor(m_cdmAttachmentLock, 4_s, [this]() {
+            assertIsHeld(m_cdmAttachmentLock);
             return isCDMAttached();
         });
     }
@@ -3624,7 +3629,7 @@
 
     GST_DEBUG_OBJECT(m_pipeline.get(), "CDM proxy instance %p dispatched as context", m_cdmInstance->proxy().get());
 
-    LockHolder lock(m_cdmAttachmentMutex);
+    Locker cdmAttachmentLocker { m_cdmAttachmentLock };
     // We must notify all waiters, since several demuxers can be simultaneously waiting for a CDM.
     m_cdmAttachmentCondition.notifyAll();
 }

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h (277903 => 277904)


--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h	2021-05-22 01:53:38 UTC (rev 277904)
@@ -38,7 +38,8 @@
 #include <gst/gst.h>
 #include <gst/pbutils/install-plugins.h>
 #include <wtf/Atomics.h>
-#include <wtf/Condition.h>
+#include <wtf/CheckedCondition.h>
+#include <wtf/CheckedLock.h>
 #include <wtf/Forward.h>
 #include <wtf/LoggerHelper.h>
 #include <wtf/RunLoop.h>
@@ -363,7 +364,7 @@
     bool m_isUsingFallbackVideoSink { false };
     bool m_canRenderingBeAccelerated { false };
 
-    bool m_isBeingDestroyed { false };
+    bool m_isBeingDestroyed WTF_GUARDED_BY_LOCK(m_drawLock) { false };
 
 #if USE(GSTREAMER_GL)
     std::unique_ptr<VideoTextureCopierGStreamer> m_videoTextureCopier;
@@ -375,8 +376,8 @@
     ImageOrientation m_videoSourceOrientation;
 
 #if ENABLE(ENCRYPTED_MEDIA)
-    Lock m_cdmAttachmentMutex;
-    Condition m_cdmAttachmentCondition;
+    CheckedLock m_cdmAttachmentLock;
+    CheckedCondition m_cdmAttachmentCondition;
     RefPtr<CDMInstanceProxy> m_cdmInstance;
 
     Lock m_protectionMutex; // Guards access to m_handledProtectionEvents.
@@ -474,9 +475,9 @@
     mutable MediaTime m_maxTimeLoadedAtLastDidLoadingProgress;
     bool m_hasVideo { false };
     bool m_hasAudio { false };
-    Condition m_drawCondition;
-    Lock m_drawMutex;
-    RunLoop::Timer<MediaPlayerPrivateGStreamer> m_drawTimer;
+    CheckedCondition m_drawCondition;
+    CheckedLock m_drawLock;
+    RunLoop::Timer<MediaPlayerPrivateGStreamer> m_drawTimer WTF_GUARDED_BY_LOCK(m_drawLock);
     RunLoop::Timer<MediaPlayerPrivateGStreamer> m_readyTimerHandler;
 #if USE(TEXTURE_MAPPER_GL)
 #if USE(NICOSIA)

Modified: trunk/Source/WebCore/platform/graphics/holepunch/MediaPlayerPrivateHolePunch.cpp (277903 => 277904)


--- trunk/Source/WebCore/platform/graphics/holepunch/MediaPlayerPrivateHolePunch.cpp	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebCore/platform/graphics/holepunch/MediaPlayerPrivateHolePunch.cpp	2021-05-22 01:53:38 UTC (rev 277904)
@@ -75,7 +75,7 @@
     auto proxyOperation =
         [this](TextureMapperPlatformLayerProxy& proxy)
         {
-            LockHolder holder(proxy.lock());
+            Locker locker { proxy.lock() };
             std::unique_ptr<TextureMapperPlatformLayerBuffer> layerBuffer = makeUnique<TextureMapperPlatformLayerBuffer>(0, m_size, TextureMapperGL::ShouldNotBlend, GL_DONT_CARE);
             proxy.pushNextBuffer(WTFMove(layerBuffer));
         };

Modified: trunk/Source/WebCore/platform/graphics/nicosia/NicosiaImageBufferPipe.cpp (277903 => 277904)


--- trunk/Source/WebCore/platform/graphics/nicosia/NicosiaImageBufferPipe.cpp	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebCore/platform/graphics/nicosia/NicosiaImageBufferPipe.cpp	2021-05-22 01:53:38 UTC (rev 277904)
@@ -95,7 +95,7 @@
         auto proxyOperation = [this] (TextureMapperPlatformLayerProxy& proxy) mutable {
             return proxy.scheduleUpdateOnCompositorThread([this] () mutable {
                 auto& proxy = downcast<Nicosia::ContentLayerTextureMapperImpl>(m_nicosiaLayer->impl()).proxy();
-                LockHolder holder(proxy.lock());
+                Locker locker { proxy.lock() };
 
                 if (!proxy.isActive())
                     return;

Modified: trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp (277903 => 277904)


--- trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebCore/platform/graphics/nicosia/texmap/NicosiaGCGLLayer.cpp	2021-05-22 01:53:38 UTC (rev 277904)
@@ -105,10 +105,10 @@
         } else
             layerBuffer->textureGL().setPendingContents(WTFMove(image));
 
-        LockHolder holder(proxy.lock());
+        Locker locker { proxy.lock() };
         proxy.pushNextBuffer(WTFMove(layerBuffer));
 #else
-        LockHolder holder(proxy.lock());
+        Locker locker { proxy.lock() };
         proxy.pushNextBuffer(makeUnique<TextureMapperPlatformLayerBuffer>(m_context.m_compositorTexture, textureSize, flags, m_context.m_internalColorFormat));
 #endif
     }

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp (277903 => 277904)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.cpp	2021-05-22 01:53:38 UTC (rev 277904)
@@ -51,7 +51,7 @@
 
 TextureMapperPlatformLayerProxy::~TextureMapperPlatformLayerProxy()
 {
-    LockHolder locker(m_lock);
+    Locker locker { m_lock };
     if (m_targetLayer)
         m_targetLayer->setContentsLayer(nullptr);
 }
@@ -67,7 +67,7 @@
     ASSERT(targetLayer);
     Function<void()> updateFunction;
     {
-        LockHolder locker(m_lock);
+        Locker locker { m_lock };
         m_compositor = compositor;
         m_targetLayer = targetLayer;
         if (m_targetLayer && m_currentBuffer)
@@ -93,7 +93,7 @@
     ASSERT(m_compositorThread == &Thread::current());
     Function<void()> updateFunction;
     {
-        LockHolder locker(m_lock);
+        Locker locker { m_lock };
         m_compositor = nullptr;
         m_targetLayer = nullptr;
 
@@ -174,7 +174,7 @@
 
 void TextureMapperPlatformLayerProxy::releaseUnusedBuffersTimerFired()
 {
-    LockHolder locker(m_lock);
+    Locker locker { m_lock };
     if (m_usedBuffers.isEmpty())
         return;
 
@@ -190,7 +190,7 @@
 void TextureMapperPlatformLayerProxy::swapBuffer()
 {
     ASSERT(m_compositorThread == &Thread::current());
-    LockHolder locker(m_lock);
+    Locker locker { m_lock };
     if (!m_targetLayer || !m_pendingBuffer)
         return;
 
@@ -218,11 +218,11 @@
 
     m_compositorThreadUpdateFunction =
         [this, shouldWait] {
-            LockHolder locker(m_lock);
+            Locker locker { m_lock };
 
             auto maybeNotifySynchronousOperation = WTF::makeScopeExit([this, shouldWait]() {
                 if (shouldWait) {
-                    LockHolder holder(m_wasBufferDroppedLock);
+                    Locker locker { m_wasBufferDroppedLock };
                     m_wasBufferDropped = true;
                     m_wasBufferDroppedCondition.notifyAll();
                 }
@@ -241,14 +241,15 @@
         };
 
     if (shouldWait) {
-        LockHolder holder(m_wasBufferDroppedLock);
+        Locker locker { m_wasBufferDroppedLock };
         m_wasBufferDropped = false;
     }
 
     m_compositorThreadUpdateTimer->startOneShot(0_s);
     if (shouldWait) {
-        LockHolder holder(m_wasBufferDroppedLock);
+        Locker locker { m_wasBufferDroppedLock };
         m_wasBufferDroppedCondition.wait(m_wasBufferDroppedLock, [this] {
+            assertIsHeld(m_wasBufferDroppedLock);
             return m_wasBufferDropped;
         });
     }
@@ -256,7 +257,7 @@
 
 bool TextureMapperPlatformLayerProxy::scheduleUpdateOnCompositorThread(Function<void()>&& updateFunction)
 {
-    LockHolder locker(m_lock);
+    Locker locker { m_lock };
     m_compositorThreadUpdateFunction = WTFMove(updateFunction);
 
     if (!m_compositorThreadUpdateTimer)
@@ -270,7 +271,7 @@
 {
     Function<void()> updateFunction;
     {
-        LockHolder locker(m_lock);
+        Locker locker { m_lock };
         if (!m_compositorThreadUpdateFunction)
             return;
         updateFunction = WTFMove(m_compositorThreadUpdateFunction);

Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.h (277903 => 277904)


--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.h	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperPlatformLayerProxy.h	2021-05-22 01:53:38 UTC (rev 277904)
@@ -28,9 +28,9 @@
 #if USE(COORDINATED_GRAPHICS)
 
 #include "TextureMapperGLHeaders.h"
-#include <wtf/Condition.h>
+#include <wtf/CheckedCondition.h>
+#include <wtf/CheckedLock.h>
 #include <wtf/Function.h>
-#include <wtf/Lock.h>
 #include <wtf/RunLoop.h>
 #include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/Vector.h>
@@ -60,7 +60,7 @@
     // To avoid multiple lock/release situation to update a single frame,
     // the implementation of TextureMapperPlatformLayerProxyProvider should
     // aquire / release the lock explicitly to use below methods.
-    Lock& lock() { return m_lock; }
+    CheckedLock& lock() WTF_RETURNS_LOCK(m_lock) { return m_lock; }
     std::unique_ptr<TextureMapperPlatformLayerBuffer> getAvailableBuffer(const IntSize&, GLint internalFormat);
     void pushNextBuffer(std::unique_ptr<TextureMapperPlatformLayerBuffer>&&);
     bool isActive();
@@ -84,11 +84,11 @@
     std::unique_ptr<TextureMapperPlatformLayerBuffer> m_currentBuffer;
     std::unique_ptr<TextureMapperPlatformLayerBuffer> m_pendingBuffer;
 
-    Lock m_lock;
+    CheckedLock m_lock;
 
-    Lock m_wasBufferDroppedLock;
-    Condition m_wasBufferDroppedCondition;
-    bool m_wasBufferDropped { false };
+    CheckedLock m_wasBufferDroppedLock;
+    CheckedCondition m_wasBufferDroppedCondition;
+    bool m_wasBufferDropped WTF_GUARDED_BY_LOCK(m_wasBufferDroppedLock) { false };
 
     Vector<std::unique_ptr<TextureMapperPlatformLayerBuffer>> m_usedBuffers;
     std::unique_ptr<RunLoop::Timer<TextureMapperPlatformLayerProxy>> m_releaseUnusedBuffersTimer;

Modified: trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp (277903 => 277904)


--- trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp	2021-05-22 01:53:38 UTC (rev 277904)
@@ -85,13 +85,13 @@
 void CompositingRunLoop::performTaskSync(Function<void ()>&& function)
 {
     ASSERT(RunLoop::isMain());
-    LockHolder locker(m_dispatchSyncConditionMutex);
+    Locker locker { m_dispatchSyncConditionLock };
     m_runLoop->dispatch([this, function = WTFMove(function)] {
         function();
-        LockHolder locker(m_dispatchSyncConditionMutex);
+        Locker locker { m_dispatchSyncConditionLock };
         m_dispatchSyncCondition.notifyOne();
     });
-    m_dispatchSyncCondition.wait(m_dispatchSyncConditionMutex);
+    m_dispatchSyncCondition.wait(m_dispatchSyncConditionLock);
 }
 
 void CompositingRunLoop::suspend()

Modified: trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h (277903 => 277904)


--- trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h	2021-05-22 01:33:40 UTC (rev 277903)
+++ trunk/Source/WebKit/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h	2021-05-22 01:53:38 UTC (rev 277904)
@@ -28,7 +28,8 @@
 #if USE(COORDINATED_GRAPHICS)
 
 #include <wtf/Atomics.h>
-#include <wtf/Condition.h>
+#include <wtf/CheckedCondition.h>
+#include <wtf/CheckedLock.h>
 #include <wtf/FastMalloc.h>
 #include <wtf/Function.h>
 #include <wtf/NeverDestroyed.h>
@@ -70,8 +71,8 @@
     RunLoop* m_runLoop { nullptr };
     RunLoop::Timer<CompositingRunLoop> m_updateTimer;
     Function<void ()> m_updateFunction;
-    Lock m_dispatchSyncConditionMutex;
-    Condition m_dispatchSyncCondition;
+    CheckedLock m_dispatchSyncConditionLock;
+    CheckedCondition m_dispatchSyncCondition;
 
     struct {
         Lock lock;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to