Stricter compile-time thread annotations in JsepTransportController
Bug: None
Change-Id: I8a598b8b22e1067bb44a43f9bcaad3581484da0b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/201729
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33029}
diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc
index b7ab279..9b14dc0 100644
--- a/pc/jsep_transport_controller.cc
+++ b/pc/jsep_transport_controller.cc
@@ -92,8 +92,10 @@
JsepTransportController::~JsepTransportController() {
// Channel destructors may try to send packets, so this needs to happen on
// the network thread.
- network_thread_->Invoke<void>(RTC_FROM_HERE,
- [this] { DestroyAllJsepTransports_n(); });
+ network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
+ RTC_DCHECK_RUN_ON(network_thread_);
+ DestroyAllJsepTransports_n();
+ });
}
RTCError JsepTransportController::SetLocalDescription(
@@ -104,6 +106,7 @@
RTC_FROM_HERE, [=] { return SetLocalDescription(type, description); });
}
+ RTC_DCHECK_RUN_ON(network_thread_);
if (!initial_offerer_.has_value()) {
initial_offerer_.emplace(type == SdpType::kOffer);
if (*initial_offerer_) {
@@ -123,6 +126,7 @@
RTC_FROM_HERE, [=] { return SetRemoteDescription(type, description); });
}
+ RTC_DCHECK_RUN_ON(network_thread_);
return ApplyDescription_n(/*local=*/false, type, description);
}
@@ -558,7 +562,6 @@
bool local,
SdpType type,
const cricket::SessionDescription* description) {
- RTC_DCHECK_RUN_ON(network_thread_);
RTC_DCHECK(description);
if (local) {
@@ -955,7 +958,6 @@
bool local,
const cricket::ContentInfo& content_info,
const cricket::SessionDescription& description) {
- RTC_DCHECK(network_thread_->IsCurrent());
cricket::JsepTransport* transport = GetJsepTransportByName(content_info.name);
if (transport) {
return RTCError::OK();
diff --git a/pc/jsep_transport_controller.h b/pc/jsep_transport_controller.h
index f0adeed..64a5990 100644
--- a/pc/jsep_transport_controller.h
+++ b/pc/jsep_transport_controller.h
@@ -229,7 +229,8 @@
private:
RTCError ApplyDescription_n(bool local,
SdpType type,
- const cricket::SessionDescription* description);
+ const cricket::SessionDescription* description)
+ RTC_RUN_ON(network_thread_);
RTCError ValidateAndMaybeUpdateBundleGroup(
bool local,
SdpType type,
@@ -237,8 +238,10 @@
RTCError ValidateContent(const cricket::ContentInfo& content_info);
void HandleRejectedContent(const cricket::ContentInfo& content_info,
- const cricket::SessionDescription* description);
- bool HandleBundledContent(const cricket::ContentInfo& content_info);
+ const cricket::SessionDescription* description)
+ RTC_RUN_ON(network_thread_);
+ bool HandleBundledContent(const cricket::ContentInfo& content_info)
+ RTC_RUN_ON(network_thread_);
bool SetTransportForMid(const std::string& mid,
cricket::JsepTransport* jsep_transport);
@@ -295,12 +298,14 @@
RTCError MaybeCreateJsepTransport(
bool local,
const cricket::ContentInfo& content_info,
- const cricket::SessionDescription& description);
+ const cricket::SessionDescription& description)
+ RTC_RUN_ON(network_thread_);
- void MaybeDestroyJsepTransport(const std::string& mid);
- void DestroyAllJsepTransports_n();
+ void MaybeDestroyJsepTransport(const std::string& mid)
+ RTC_RUN_ON(network_thread_);
+ void DestroyAllJsepTransports_n() RTC_RUN_ON(network_thread_);
- void SetIceRole_n(cricket::IceRole ice_role);
+ void SetIceRole_n(cricket::IceRole ice_role) RTC_RUN_ON(network_thread_);
cricket::IceRole DetermineIceRole(
cricket::JsepTransport* jsep_transport,
@@ -334,24 +339,33 @@
std::vector<cricket::DtlsTransportInternal*> GetDtlsTransports();
// Handlers for signals from Transport.
- void OnTransportWritableState_n(rtc::PacketTransportInternal* transport);
- void OnTransportReceivingState_n(rtc::PacketTransportInternal* transport);
- void OnTransportGatheringState_n(cricket::IceTransportInternal* transport);
+ void OnTransportWritableState_n(rtc::PacketTransportInternal* transport)
+ RTC_RUN_ON(network_thread_);
+ void OnTransportReceivingState_n(rtc::PacketTransportInternal* transport)
+ RTC_RUN_ON(network_thread_);
+ void OnTransportGatheringState_n(cricket::IceTransportInternal* transport)
+ RTC_RUN_ON(network_thread_);
void OnTransportCandidateGathered_n(cricket::IceTransportInternal* transport,
- const cricket::Candidate& candidate);
- void OnTransportCandidateError_n(
- cricket::IceTransportInternal* transport,
- const cricket::IceCandidateErrorEvent& event);
+ const cricket::Candidate& candidate)
+ RTC_RUN_ON(network_thread_);
+ void OnTransportCandidateError_n(cricket::IceTransportInternal* transport,
+ const cricket::IceCandidateErrorEvent& event)
+ RTC_RUN_ON(network_thread_);
void OnTransportCandidatesRemoved_n(cricket::IceTransportInternal* transport,
- const cricket::Candidates& candidates);
- void OnTransportRoleConflict_n(cricket::IceTransportInternal* transport);
- void OnTransportStateChanged_n(cricket::IceTransportInternal* transport);
+ const cricket::Candidates& candidates)
+ RTC_RUN_ON(network_thread_);
+ void OnTransportRoleConflict_n(cricket::IceTransportInternal* transport)
+ RTC_RUN_ON(network_thread_);
+ void OnTransportStateChanged_n(cricket::IceTransportInternal* transport)
+ RTC_RUN_ON(network_thread_);
void OnTransportCandidatePairChanged_n(
- const cricket::CandidatePairChangeEvent& event);
- void UpdateAggregateStates_n();
+ const cricket::CandidatePairChangeEvent& event)
+ RTC_RUN_ON(network_thread_);
+ void UpdateAggregateStates_n() RTC_RUN_ON(network_thread_);
void OnRtcpPacketReceived_n(rtc::CopyOnWriteBuffer* packet,
- int64_t packet_time_us);
+ int64_t packet_time_us)
+ RTC_RUN_ON(network_thread_);
void OnDtlsHandshakeError(rtc::SSLHandshakeError error);