Add asserts to MediaStreamPrivate observer routines
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Oct 2019 07:44:40 +0000 (07:44 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Oct 2019 07:44:40 +0000 (07:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=202724

Reviewed by Alex Christensen.

These methods are only to be called in main thread.
Add asserts to validate this.
No change of behavior.

* platform/mediastream/MediaStreamPrivate.cpp:
(WebCore::MediaStreamPrivate::addObserver):
(WebCore::MediaStreamPrivate::removeObserver):
(WebCore::MediaStreamPrivate::forEachObserver const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250958 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/mediastream/MediaStreamPrivate.cpp

index 14339e7..074fefb 100644 (file)
@@ -1,3 +1,19 @@
+2019-10-10  youenn fablet  <youenn@apple.com>
+
+        Add asserts to MediaStreamPrivate observer routines
+        https://bugs.webkit.org/show_bug.cgi?id=202724
+
+        Reviewed by Alex Christensen.
+
+        These methods are only to be called in main thread.
+        Add asserts to validate this.
+        No change of behavior.
+
+        * platform/mediastream/MediaStreamPrivate.cpp:
+        (WebCore::MediaStreamPrivate::addObserver):
+        (WebCore::MediaStreamPrivate::removeObserver):
+        (WebCore::MediaStreamPrivate::forEachObserver const):
+
 2019-10-09  youenn fablet  <youenn@apple.com>
 
         A service worker process should not be created when enqueuing a service worker job
index d58c69d..ccb4606 100644 (file)
@@ -91,16 +91,19 @@ MediaStreamPrivate::~MediaStreamPrivate()
 
 void MediaStreamPrivate::addObserver(MediaStreamPrivate::Observer& observer)
 {
+    RELEASE_ASSERT(isMainThread());
     m_observers.add(&observer);
 }
 
 void MediaStreamPrivate::removeObserver(MediaStreamPrivate::Observer& observer)
 {
+    RELEASE_ASSERT(isMainThread());
     m_observers.remove(&observer);
 }
 
 void MediaStreamPrivate::forEachObserver(const WTF::Function<void(Observer&)>& apply) const
 {
+    RELEASE_ASSERT(isMainThread());
     for (auto* observer : copyToVector(m_observers)) {
         if (!m_observers.contains(observer))
             continue;