diff --git a/p2p/base/ice_transport_internal.h b/p2p/base/ice_transport_internal.h index 38b6bfe303..32e913de05 100644 --- a/p2p/base/ice_transport_internal.h +++ b/p2p/base/ice_transport_internal.h @@ -306,10 +306,14 @@ class RTC_EXPORT IceTransportInternal : public rtc::PacketTransportInternal { // Signal Exposed for backwards compatibility. sigslot::signal1 SignalGatheringState; - void SetGatheringStateCallback( + void AddGatheringStateCallback( + const void* removal_tag, absl::AnyInvocable callback) { - RTC_DCHECK(!gathering_state_callback_); - gathering_state_callback_ = std::move(callback); + gathering_state_callback_list_.AddReceiver(removal_tag, + std::move(callback)); + } + void RemoveGatheringStateCallback(const void* removal_tag) { + gathering_state_callback_list_.RemoveReceivers(removal_tag); } // Handles sending and receiving of candidates. @@ -393,7 +397,7 @@ class RTC_EXPORT IceTransportInternal : public rtc::PacketTransportInternal { webrtc::CallbackList dictionary_writer_synced_callback_list_; - absl::AnyInvocable gathering_state_callback_; + webrtc::CallbackList gathering_state_callback_list_; absl::AnyInvocable candidate_error_callback_; @@ -407,9 +411,7 @@ class RTC_EXPORT IceTransportInternal : public rtc::PacketTransportInternal { private: // TODO(bugs.webrtc.org/11943): remove when removing Signal void SignalGatheringStateFired(IceTransportInternal* transport) { - if (gathering_state_callback_) { - gathering_state_callback_(transport); - } + gathering_state_callback_list_.Send(transport); } }; diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc index dae7060658..7152826725 100644 --- a/pc/jsep_transport_controller.cc +++ b/pc/jsep_transport_controller.cc @@ -439,8 +439,8 @@ JsepTransportController::CreateDtlsTransport( this, &JsepTransportController::OnTransportWritableState_n); dtls->SignalReceivingState.connect( this, &JsepTransportController::OnTransportReceivingState_n); - dtls->ice_transport()->SetGatheringStateCallback( - [this](cricket::IceTransportInternal* transport) { + dtls->ice_transport()->AddGatheringStateCallback( + this, [this](cricket::IceTransportInternal* transport) { RTC_DCHECK_RUN_ON(network_thread_); OnTransportGatheringState_n(transport); });