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}
This commit is contained in:
Niels Möller
2021-01-18 14:00:36 +01:00
committed by Commit Bot
parent 25b8235f03
commit 5cf0ef0022
2 changed files with 40 additions and 24 deletions

View File

@ -92,8 +92,10 @@ JsepTransportController::JsepTransportController(
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 @@ RTCError JsepTransportController::SetLocalDescription(
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 @@ RTCError JsepTransportController::SetRemoteDescription(
RTC_FROM_HERE, [=] { return SetRemoteDescription(type, description); });
}
RTC_DCHECK_RUN_ON(network_thread_);
return ApplyDescription_n(/*local=*/false, type, description);
}
@ -558,7 +562,6 @@ RTCError JsepTransportController::ApplyDescription_n(
bool local,
SdpType type,
const cricket::SessionDescription* description) {
RTC_DCHECK_RUN_ON(network_thread_);
RTC_DCHECK(description);
if (local) {
@ -955,7 +958,6 @@ RTCError JsepTransportController::MaybeCreateJsepTransport(
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();

View File

@ -229,7 +229,8 @@ class JsepTransportController : public sigslot::has_slots<> {
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 @@ class JsepTransportController : public sigslot::has_slots<> {
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 @@ class JsepTransportController : public sigslot::has_slots<> {
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 @@ class JsepTransportController : public sigslot::has_slots<> {
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);