From 106d92d4c930088d2e7ae6ca74fa863a5edb9db8 Mon Sep 17 00:00:00 2001 From: Karl Wiberg Date: Thu, 14 Feb 2019 10:17:47 +0100 Subject: [PATCH] Add thread safety annotation for PeerConnection::SignalDataChannelCreated_ Plus all the annotations that are necessary to make things compile again. Bug: webrtc:9987 Change-Id: I53caa3c6644c5d0fcb50f7c1e89e853eddd769a5 Reviewed-on: https://webrtc-review.googlesource.com/c/122882 Reviewed-by: Steve Anton Commit-Queue: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#26705} --- pc/peer_connection.cc | 1 + pc/peer_connection.h | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 66d08a36e7..fccd6df73a 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -1827,6 +1827,7 @@ PeerConnection::ice_gathering_state() { rtc::scoped_refptr PeerConnection::CreateDataChannel( const std::string& label, const DataChannelInit* config) { + RTC_DCHECK_RUN_ON(signaling_thread()); TRACE_EVENT0("webrtc", "PeerConnection::CreateDataChannel"); bool first_datachannel = !HasDataChannels(); diff --git a/pc/peer_connection.h b/pc/peer_connection.h index 7c144ce3bc..660788fb80 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -429,7 +429,8 @@ class PeerConnection : public PeerConnectionInternal, cricket::ContentSource source, const SessionDescriptionInterface& new_session, const SessionDescriptionInterface* old_local_description, - const SessionDescriptionInterface* old_remote_description); + const SessionDescriptionInterface* old_remote_description) + RTC_RUN_ON(signaling_thread()); // Either creates or destroys the transceiver's BaseChannel according to the // given media section. @@ -443,7 +444,8 @@ class PeerConnection : public PeerConnectionInternal, // media section. RTCError UpdateDataChannel(cricket::ContentSource source, const cricket::ContentInfo& content, - const cricket::ContentGroup* bundle_group); + const cricket::ContentGroup* bundle_group) + RTC_RUN_ON(signaling_thread()); // Associate the given transceiver according to the JSEP rules. RTCErrorOr< @@ -629,18 +631,20 @@ class PeerConnection : public PeerConnectionInternal, cricket::MediaType media_type); void UpdateLocalRtpDataChannels(const cricket::StreamParamsVec& streams); - void UpdateRemoteRtpDataChannels(const cricket::StreamParamsVec& streams); + void UpdateRemoteRtpDataChannels(const cricket::StreamParamsVec& streams) + RTC_RUN_ON(signaling_thread()); void UpdateClosingRtpDataChannels( const std::vector& active_channels, bool is_local_update); void CreateRemoteRtpDataChannel(const std::string& label, - uint32_t remote_ssrc); + uint32_t remote_ssrc) + RTC_RUN_ON(signaling_thread()); // Creates channel and adds it to the collection of DataChannels that will // be offered in a SessionDescription. rtc::scoped_refptr InternalCreateDataChannel( const std::string& label, - const InternalDataChannelInit* config); + const InternalDataChannelInit* config) RTC_RUN_ON(signaling_thread()); // Checks if any data channel has been added. bool HasDataChannels() const; @@ -651,7 +655,9 @@ class PeerConnection : public PeerConnectionInternal, void OnDataChannelDestroyed(); // Called when a valid data channel OPEN message is received. void OnDataChannelOpenMessage(const std::string& label, - const InternalDataChannelInit& config); + const InternalDataChannelInit& config) + RTC_RUN_ON(signaling_thread()); + // Parses and handles open messages. Returns true if the message is an open // message, false otherwise. bool HandleOpenMessage_s(const cricket::ReceiveDataParams& params, @@ -992,7 +998,8 @@ class PeerConnection : public PeerConnectionInternal, return media_transport; } - sigslot::signal1 SignalDataChannelCreated_; + sigslot::signal1 SignalDataChannelCreated_ + RTC_GUARDED_BY(signaling_thread()); // Storing the factory as a scoped reference pointer ensures that the memory // in the PeerConnectionFactoryImpl remains available as long as the