Add thread safety annotations for PeerConnection::*_state_
Plus all the annotations that are necessary to make things compile
again.
Bug: webrtc:9987
Change-Id: If7bbd5a468a8c50ac3cfe03cd2ed4f5b5f461195
Reviewed-on: https://webrtc-review.googlesource.com/c/123047
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26727}
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
index 385c3d0..10aa21e 100644
--- a/pc/peer_connection.cc
+++ b/pc/peer_connection.cc
@@ -1810,26 +1810,31 @@
}
PeerConnectionInterface::SignalingState PeerConnection::signaling_state() {
+ RTC_DCHECK_RUN_ON(signaling_thread());
return signaling_state_;
}
PeerConnectionInterface::IceConnectionState
PeerConnection::ice_connection_state() {
+ RTC_DCHECK_RUN_ON(signaling_thread());
return ice_connection_state_;
}
PeerConnectionInterface::IceConnectionState
PeerConnection::standardized_ice_connection_state() {
+ RTC_DCHECK_RUN_ON(signaling_thread());
return standardized_ice_connection_state_;
}
PeerConnectionInterface::PeerConnectionState
PeerConnection::peer_connection_state() {
+ RTC_DCHECK_RUN_ON(signaling_thread());
return connection_state_;
}
PeerConnectionInterface::IceGatheringState
PeerConnection::ice_gathering_state() {
+ RTC_DCHECK_RUN_ON(signaling_thread());
return ice_gathering_state_;
}
@@ -1975,6 +1980,7 @@
void PeerConnection::CreateAnswer(CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) {
+ RTC_DCHECK_RUN_ON(signaling_thread());
TRACE_EVENT0("webrtc", "PeerConnection::CreateAnswer");
if (!observer) {
RTC_LOG(LS_ERROR) << "CreateAnswer - observer is NULL.";
diff --git a/pc/peer_connection.h b/pc/peer_connection.h
index 419c608..0640458 100644
--- a/pc/peer_connection.h
+++ b/pc/peer_connection.h
@@ -522,6 +522,7 @@
void OnNegotiationNeeded();
bool IsClosed() const {
+ RTC_DCHECK_RUN_ON(signaling_thread());
return signaling_state_ == PeerConnectionInterface::kClosed;
}
@@ -1039,14 +1040,16 @@
// pointer (but not touch the object) from any thread.
RtcEventLog* const event_log_ptr_ RTC_PT_GUARDED_BY(worker_thread());
- SignalingState signaling_state_ = kStable;
- IceConnectionState ice_connection_state_ = kIceConnectionNew;
- PeerConnectionInterface::IceConnectionState
- standardized_ice_connection_state_ = kIceConnectionNew;
- PeerConnectionInterface::PeerConnectionState connection_state_ =
- PeerConnectionState::kNew;
+ SignalingState signaling_state_ RTC_GUARDED_BY(signaling_thread()) = kStable;
+ IceConnectionState ice_connection_state_ RTC_GUARDED_BY(signaling_thread()) =
+ kIceConnectionNew;
+ PeerConnectionInterface::IceConnectionState standardized_ice_connection_state_
+ RTC_GUARDED_BY(signaling_thread()) = kIceConnectionNew;
+ PeerConnectionInterface::PeerConnectionState connection_state_
+ RTC_GUARDED_BY(signaling_thread()) = PeerConnectionState::kNew;
- IceGatheringState ice_gathering_state_ = kIceGatheringNew;
+ IceGatheringState ice_gathering_state_ RTC_GUARDED_BY(signaling_thread()) =
+ kIceGatheringNew;
PeerConnectionInterface::RTCConfiguration configuration_;
// TODO(zstein): |async_resolver_factory_| can currently be nullptr if it