Title: [277887] trunk/Source/WebCore
- Revision
- 277887
- Author
- cdu...@apple.com
- Date
- 2021-05-21 14:15:49 -0700 (Fri, 21 May 2021)
Log Message
Adopt CheckedLock / CheckedCondition in CDMProxy
https://bugs.webkit.org/show_bug.cgi?id=226103
Reviewed by Darin Adler.
Adopt CheckedLock / CheckedCondition in CDMProxy to benefit from Clang Thread Safety
Analysis.
* platform/encryptedmedia/CDMProxy.cpp:
(WebCore::CDMProxy::updateKeyStore):
(WebCore::CDMProxy::keyHandle const):
(WebCore::CDMProxy::tryWaitForKeyHandle const):
(WebCore::CDMProxy::keyAvailable const):
* platform/encryptedmedia/CDMProxy.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (277886 => 277887)
--- trunk/Source/WebCore/ChangeLog 2021-05-21 21:12:21 UTC (rev 277886)
+++ trunk/Source/WebCore/ChangeLog 2021-05-21 21:15:49 UTC (rev 277887)
@@ -1,3 +1,20 @@
+2021-05-21 Chris Dumez <cdu...@apple.com>
+
+ Adopt CheckedLock / CheckedCondition in CDMProxy
+ https://bugs.webkit.org/show_bug.cgi?id=226103
+
+ Reviewed by Darin Adler.
+
+ Adopt CheckedLock / CheckedCondition in CDMProxy to benefit from Clang Thread Safety
+ Analysis.
+
+ * platform/encryptedmedia/CDMProxy.cpp:
+ (WebCore::CDMProxy::updateKeyStore):
+ (WebCore::CDMProxy::keyHandle const):
+ (WebCore::CDMProxy::tryWaitForKeyHandle const):
+ (WebCore::CDMProxy::keyAvailable const):
+ * platform/encryptedmedia/CDMProxy.h:
+
2021-05-21 Peng Liu <peng.l...@apple.com>
Video player enters a bad state after trying to enter picture-in-picture on YouTube.com videos
Modified: trunk/Source/WebCore/platform/encryptedmedia/CDMProxy.cpp (277886 => 277887)
--- trunk/Source/WebCore/platform/encryptedmedia/CDMProxy.cpp 2021-05-21 21:12:21 UTC (rev 277886)
+++ trunk/Source/WebCore/platform/encryptedmedia/CDMProxy.cpp 2021-05-21 21:15:49 UTC (rev 277887)
@@ -236,7 +236,7 @@
void CDMProxy::updateKeyStore(const KeyStore& newKeyStore)
{
- auto locker = holdLock(m_keysMutex);
+ Locker locker { m_keysLock };
m_keyStore.merge(newKeyStore);
LOG(EME, "EME - CDMProxy - updating key store from a session update");
m_keysCondition.notifyAll();
@@ -256,7 +256,7 @@
RefPtr<KeyHandle> CDMProxy::keyHandle(const KeyIDType& keyID) const
{
- auto locker = holdLock(m_keysMutex);
+ Locker locker { m_keysLock };
ASSERT(m_keyStore.containsKeyID(keyID));
return m_keyStore.keyHandle(keyID);
}
@@ -295,9 +295,10 @@
LOG(EME, "EME - CDMProxy - trying to wait for key ID %s", vectorToHexString(keyID).ascii().data());
bool wasKeyAvailable = false;
{
- auto locker = holdLock(m_keysMutex);
+ Locker locker { m_keysLock };
- m_keysCondition.waitFor(m_keysMutex, CDMProxy::MaxKeyWaitTimeSeconds, [this, keyID, client = WTFMove(client), &wasKeyAvailable]() {
+ m_keysCondition.waitFor(m_keysLock, CDMProxy::MaxKeyWaitTimeSeconds, [this, keyID, client = WTFMove(client), &wasKeyAvailable]() {
+ assertIsHeld(m_keysLock);
if (!client || client->isAborting())
return true;
wasKeyAvailable = keyAvailableUnlocked(keyID);
@@ -322,7 +323,7 @@
bool CDMProxy::keyAvailable(const KeyIDType& keyID) const
{
- auto locker = holdLock(m_keysMutex);
+ Locker locker { m_keysLock };
return keyAvailableUnlocked(keyID);
}
Modified: trunk/Source/WebCore/platform/encryptedmedia/CDMProxy.h (277886 => 277887)
--- trunk/Source/WebCore/platform/encryptedmedia/CDMProxy.h 2021-05-21 21:12:21 UTC (rev 277886)
+++ trunk/Source/WebCore/platform/encryptedmedia/CDMProxy.h 2021-05-21 21:15:49 UTC (rev 277887)
@@ -35,8 +35,8 @@
#include "MediaPlayerPrivate.h"
#include "SharedBuffer.h"
#include <wtf/BoxPtr.h>
+#include <wtf/CheckedCondition.h>
#include <wtf/CheckedLock.h>
-#include <wtf/Condition.h>
#if ENABLE(THUNDER)
#include "CDMOpenCDMTypes.h"
@@ -162,7 +162,7 @@
protected:
RefPtr<KeyHandle> keyHandle(const KeyIDType&) const;
bool keyAvailable(const KeyIDType&) const;
- bool keyAvailableUnlocked(const KeyIDType&) const;
+ bool keyAvailableUnlocked(const KeyIDType&) const WTF_REQUIRES_LOCK(m_keysLock);
Optional<Ref<KeyHandle>> tryWaitForKeyHandle(const KeyIDType&, WeakPtr<CDMProxyDecryptionClient>&&) const;
Optional<Ref<KeyHandle>> getOrWaitForKeyHandle(const KeyIDType&, WeakPtr<CDMProxyDecryptionClient>&&) const;
Optional<KeyHandleValueVariant> getOrWaitForKeyValue(const KeyIDType&, WeakPtr<CDMProxyDecryptionClient>&&) const;
@@ -174,11 +174,11 @@
mutable CheckedLock m_instanceLock;
CDMInstanceProxy* m_instance WTF_GUARDED_BY_LOCK(m_instanceLock);
- mutable Lock m_keysMutex;
- mutable Condition m_keysCondition;
+ mutable CheckedLock m_keysLock;
+ mutable CheckedCondition m_keysCondition;
// FIXME: Duplicated key stores in the instance and the proxy are probably not needed, but simplified
// the initial implementation in terms of threading invariants.
- KeyStore m_keyStore;
+ KeyStore m_keyStore WTF_GUARDED_BY_LOCK(m_keysLock);
};
class CDMProxyFactory {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes