From f73f7d684c030a2523458c55d9d98e23a8eec8b2 Mon Sep 17 00:00:00 2001 From: Karl Wiberg Date: Mon, 8 Apr 2019 15:36:53 +0200 Subject: [PATCH] Add thread safety annotations for some more PeerConnection members (part 13) Plus all the annotations that were necessary to make things compile again. Bug: webrtc:9987 Change-Id: Ib0814a02bd277005c8f4c1848421b70f847b5549 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/131339 Reviewed-by: Steve Anton Commit-Queue: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#27505} --- pc/peer_connection.cc | 1 + pc/peer_connection.h | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc index 6e05d54826..e7a1a11157 100644 --- a/pc/peer_connection.cc +++ b/pc/peer_connection.cc @@ -5962,6 +5962,7 @@ cricket::DataChannelType PeerConnection::data_channel_type() const { } bool PeerConnection::IceRestartPending(const std::string& content_name) const { + RTC_DCHECK_RUN_ON(signaling_thread()); return pending_ice_restarts_.find(content_name) != pending_ice_restarts_.end(); } diff --git a/pc/peer_connection.h b/pc/peer_connection.h index 1f7228d0c2..c639a58829 100644 --- a/pc/peer_connection.h +++ b/pc/peer_connection.h @@ -275,6 +275,7 @@ class PeerConnection : public PeerConnectionInternal, bool GetSslRole(const std::string& content_name, rtc::SSLRole* role) override; void ReturnHistogramVeryQuicklyForTesting() { + RTC_DCHECK_RUN_ON(signaling_thread()); return_histogram_very_quickly_ = true; } void RequestUsagePatternReportForTesting(); @@ -1303,24 +1304,31 @@ class PeerConnection : public PeerConnectionInternal, // not set or false, SCTP is allowed (DCT_SCTP); // 2. If constraint kEnableRtpDataChannels is true, RTP is allowed (DCT_RTP); // 3. If both 1&2 are false, data channel is not allowed (DCT_NONE). - cricket::DataChannelType data_channel_type_ = cricket::DCT_NONE; - // List of content names for which the remote side triggered an ICE restart. - std::set pending_ice_restarts_; + cricket::DataChannelType data_channel_type_ = + cricket::DCT_NONE; // TODO(bugs.webrtc.org/9987): Accessed on both + // signaling and network thread. - std::unique_ptr webrtc_session_desc_factory_; + // List of content names for which the remote side triggered an ICE restart. + std::set pending_ice_restarts_ + RTC_GUARDED_BY(signaling_thread()); + + std::unique_ptr webrtc_session_desc_factory_ + RTC_GUARDED_BY(signaling_thread()); // Member variables for caching global options. - cricket::AudioOptions audio_options_; - cricket::VideoOptions video_options_; + cricket::AudioOptions audio_options_ RTC_GUARDED_BY(signaling_thread()); + cricket::VideoOptions video_options_ RTC_GUARDED_BY(signaling_thread()); - int usage_event_accumulator_ = 0; - bool return_histogram_very_quickly_ = false; + int usage_event_accumulator_ RTC_GUARDED_BY(signaling_thread()) = 0; + bool return_histogram_very_quickly_ RTC_GUARDED_BY(signaling_thread()) = + false; // This object should be used to generate any SSRC that is not explicitly // specified by the user (or by the remote party). // The generator is not used directly, instead it is passed on to the // channel manager and the session description factory. - rtc::UniqueRandomIdGenerator ssrc_generator_; + rtc::UniqueRandomIdGenerator ssrc_generator_ + RTC_GUARDED_BY(signaling_thread()); }; } // namespace webrtc