tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 811836188b9922f2edec6167756c508d880c9ea4
parent 3f4b35fd6b16cb5cd644907c639c4a1c5f1f5a30
Author: Dan Baker <dbaker@mozilla.com>
Date:   Mon,  1 Dec 2025 21:39:53 -0700

Bug 2000941 - Vendor libwebrtc from 83b0eaa6ec

Upstream commit: https://webrtc.googlesource.com/src/+/83b0eaa6ec8a54c12ef13b935fd4d3a7cf146270
    Replace PacketTransportInternal sigslot with 'sigslot trampoline'

    Bug: webrtc:42222066
    Change-Id: I82ddb27d27126baac3b67a1e58efb355b247171d
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/407046
    Commit-Queue: Lena Kaplan <lenakaplan@meta.com>
    Reviewed-by: Harald Alvestrand <hta@webrtc.org>
    Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#45673}

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/media/sctp/dcsctp_transport.cc | 9++++++---
Mthird_party/libwebrtc/p2p/BUILD.gn | 1+
Mthird_party/libwebrtc/p2p/base/p2p_transport_channel.cc | 12++++++------
Mthird_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc | 23+++++++++++++++--------
Mthird_party/libwebrtc/p2p/base/packet_transport_internal.cc | 65++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Mthird_party/libwebrtc/p2p/base/packet_transport_internal.h | 33+++++++++++++++++++++++++++++++++
Mthird_party/libwebrtc/p2p/base/regathering_controller.cc | 18++++++++++++------
Mthird_party/libwebrtc/p2p/dtls/dtls_transport.cc | 72+++++++++++++++++++++++++++++++++++++++---------------------------------
Mthird_party/libwebrtc/p2p/dtls/dtls_transport_unittest.cc | 6++++--
Mthird_party/libwebrtc/p2p/dtls/fake_dtls_transport.h | 21++++++++++++---------
Mthird_party/libwebrtc/p2p/test/fake_ice_transport.h | 8++++----
Mthird_party/libwebrtc/p2p/test/fake_packet_transport.h | 8++++----
Mthird_party/libwebrtc/p2p/test/mock_ice_transport.h | 4++--
Mthird_party/libwebrtc/pc/channel_unittest.cc | 4++--
Mthird_party/libwebrtc/pc/jsep_transport_controller.cc | 13+++++++++----
Mthird_party/libwebrtc/pc/rtp_transport.cc | 48++++++++++++++++++++++++++++++------------------
17 files changed, 245 insertions(+), 104 deletions(-)

diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor @@ -1,4 +1,4 @@ # ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc -libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T04:37:22.203847+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T04:39:39.517365+00:00. # base of lastest vendoring -5702891feb +83b0eaa6ec diff --git a/third_party/libwebrtc/media/sctp/dcsctp_transport.cc b/third_party/libwebrtc/media/sctp/dcsctp_transport.cc @@ -662,8 +662,11 @@ void DcSctpTransport::ConnectTransportSignals() { if (!transport_) { return; } - transport_->SignalWritableState.connect( - this, &DcSctpTransport::OnTransportWritableState); + transport_->SubscribeWritableState( + this, [this](PacketTransportInternal* transport) { + OnTransportWritableState(transport); + }); + transport_->RegisterReceivedPacketCallback( this, [&](PacketTransportInternal* transport, const ReceivedIpPacket& packet) { @@ -687,7 +690,7 @@ void DcSctpTransport::DisconnectTransportSignals() { if (!transport_) { return; } - transport_->SignalWritableState.disconnect(this); + transport_->UnsubscribeWritableState(this); transport_->DeregisterReceivedPacketCallback(this); transport_->SetOnCloseCallback(nullptr); transport_->UnsubscribeDtlsTransportState(this); diff --git a/third_party/libwebrtc/p2p/BUILD.gn b/third_party/libwebrtc/p2p/BUILD.gn @@ -565,6 +565,7 @@ rtc_library("packet_transport_internal") { "../rtc_base:checks", "../rtc_base:macromagic", "../rtc_base:network_route", + "../rtc_base:sigslot_trampoline", "../rtc_base:socket", "../rtc_base/network:received_packet", "../rtc_base/network:sent_packet", diff --git a/third_party/libwebrtc/p2p/base/p2p_transport_channel.cc b/third_party/libwebrtc/p2p/base/p2p_transport_channel.cc @@ -1872,7 +1872,7 @@ void P2PTransportChannel::SwitchSelectedConnectionInternal( // has been disallowed to send. if (selected_connection_->writable() || PresumedWritable(selected_connection_)) { - SignalReadyToSend(this); + NotifyReadyToSend(this); } network_route_.emplace(ConfigureNetworkRoute(selected_connection_)); @@ -1887,7 +1887,7 @@ void P2PTransportChannel::SwitchSelectedConnectionInternal( SendPingRequestInternal(conn); } - SignalNetworkRouteChanged(network_route_); + NotifyNetworkRouteChanged(network_route_); // Create event for candidate pair change. if (selected_connection_ && candidate_pair_change_callback_) { @@ -2284,7 +2284,7 @@ void P2PTransportChannel::OnSentPacket(const SentPacketInfo& sent_packet) { void P2PTransportChannel::OnReadyToSend(Connection* connection) { RTC_DCHECK_RUN_ON(network_thread_); if (connection == selected_connection_ && writable()) { - SignalReadyToSend(this); + NotifyReadyToSend(this); } } @@ -2297,9 +2297,9 @@ void P2PTransportChannel::SetWritable(bool writable) { writable_ = writable; if (writable_) { has_been_writable_ = true; - SignalReadyToSend(this); + NotifyReadyToSend(this); } - SignalWritableState(this); + NotifyWritableState(this); } void P2PTransportChannel::SetReceiving(bool receiving) { @@ -2308,7 +2308,7 @@ void P2PTransportChannel::SetReceiving(bool receiving) { return; } receiving_ = receiving; - SignalReceivingState(this); + NotifyReceivingState(this); } Candidate P2PTransportChannel::SanitizeLocalCandidate( diff --git a/third_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc b/third_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc @@ -496,8 +496,10 @@ class P2PTransportChannelTestBase : public ::testing::Test, GetEndpoint(endpoint)->async_dns_resolver_factory_); auto channel = P2PTransportChannel::Create("test content name", component, std::move(init)); - channel->SignalReadyToSend.connect( - this, &P2PTransportChannelTestBase::OnReadyToSend); + channel->SubscribeReadyToSend(this, + [this](PacketTransportInternal* transport) { + OnReadyToSend(transport); + }); channel->SubscribeCandidateGathered( [this](IceTransportInternal* transport, const Candidate& candidate) { OnCandidateGathered(transport, candidate); @@ -513,8 +515,10 @@ class P2PTransportChannelTestBase : public ::testing::Test, }); channel->SubscribeRoleConflict( [this](IceTransportInternal* transport) { OnRoleConflict(transport); }); - channel->SignalNetworkRouteChanged.connect( - this, &P2PTransportChannelTestBase::OnNetworkRouteChanged); + channel->SubscribeNetworkRouteChanged( + this, [this](std::optional<NetworkRoute> network_route) { + OnNetworkRouteChanged(network_route); + }); channel->SignalSentPacket.connect( this, &P2PTransportChannelTestBase::OnSentPacket); channel->SetIceParameters(local_ice); @@ -3597,10 +3601,13 @@ class P2PTransportChannelPingTest : public ::testing::Test, ch->SetIceRole(ICEROLE_CONTROLLING); ch->SetIceParameters(kIceParams[0]); ch->SetRemoteIceParameters(kIceParams[1]); - ch->SignalNetworkRouteChanged.connect( - this, &P2PTransportChannelPingTest::OnNetworkRouteChanged); - ch->SignalReadyToSend.connect(this, - &P2PTransportChannelPingTest::OnReadyToSend); + ch->SubscribeNetworkRouteChanged( + this, [this](std::optional<NetworkRoute> network_route) { + OnNetworkRouteChanged(network_route); + }); + ch->SubscribeReadyToSend(this, [this](PacketTransportInternal* transport) { + OnReadyToSend(transport); + }); ch->SubscribeIceTransportStateChanged( [this](IceTransportInternal* transport) { OnChannelStateChanged(transport); diff --git a/third_party/libwebrtc/p2p/base/packet_transport_internal.cc b/third_party/libwebrtc/p2p/base/packet_transport_internal.cc @@ -22,7 +22,11 @@ namespace webrtc { -PacketTransportInternal::PacketTransportInternal() = default; +PacketTransportInternal::PacketTransportInternal() + : writable_state_trampoline_(this), + ready_to_send_trampoline_(this), + receiving_state_trampoline_(this), + network_route_changed_trampoline_(this) {} PacketTransportInternal::~PacketTransportInternal() = default; @@ -69,4 +73,63 @@ void PacketTransportInternal::NotifyOnClose() { } } +void PacketTransportInternal::SubscribeWritableState( + void* tag, + absl::AnyInvocable<void(PacketTransportInternal*)> callback) { + RTC_DCHECK_RUN_ON(&network_checker_); + writable_state_trampoline_.Subscribe(tag, std::move(callback)); +} +void PacketTransportInternal::UnsubscribeWritableState(void* tag) { + RTC_DCHECK_RUN_ON(&network_checker_); + writable_state_trampoline_.Unsubscribe(tag); +} +void PacketTransportInternal::NotifyWritableState( + PacketTransportInternal* packet_transport) { + RTC_DCHECK_RUN_ON(&network_checker_); + SignalWritableState(packet_transport); +} + +void PacketTransportInternal::SubscribeReadyToSend( + void* tag, + absl::AnyInvocable<void(PacketTransportInternal*)> callback) { + RTC_DCHECK_RUN_ON(&network_checker_); + ready_to_send_trampoline_.Subscribe(tag, std::move(callback)); +} +void PacketTransportInternal::UnsubscribeReadyToSend(void* tag) { + RTC_DCHECK_RUN_ON(&network_checker_); + ready_to_send_trampoline_.Unsubscribe(tag); +} +void PacketTransportInternal::NotifyReadyToSend( + PacketTransportInternal* packet_transport) { + RTC_DCHECK_RUN_ON(&network_checker_); + SignalReadyToSend(packet_transport); +} + +void PacketTransportInternal::SubscribeReceivingState( + absl::AnyInvocable<void(PacketTransportInternal*)> callback) { + RTC_DCHECK_RUN_ON(&network_checker_); + receiving_state_trampoline_.Subscribe(std::move(callback)); +} +void PacketTransportInternal::NotifyReceivingState( + PacketTransportInternal* packet_transport) { + RTC_DCHECK_RUN_ON(&network_checker_); + SignalReceivingState(packet_transport); +} + +void PacketTransportInternal::SubscribeNetworkRouteChanged( + void* tag, + absl::AnyInvocable<void(std::optional<NetworkRoute>)> callback) { + RTC_DCHECK_RUN_ON(&network_checker_); + network_route_changed_trampoline_.Subscribe(tag, std::move(callback)); +} +void PacketTransportInternal::UnsubscribeNetworkRouteChanged(void* tag) { + RTC_DCHECK_RUN_ON(&network_checker_); + network_route_changed_trampoline_.Unsubscribe(tag); +} +void PacketTransportInternal::NotifyNetworkRouteChanged( + std::optional<webrtc::NetworkRoute> network_route) { + RTC_DCHECK_RUN_ON(&network_checker_); + SignalNetworkRouteChanged(network_route); +} + } // namespace webrtc diff --git a/third_party/libwebrtc/p2p/base/packet_transport_internal.h b/third_party/libwebrtc/p2p/base/packet_transport_internal.h @@ -14,6 +14,7 @@ #include <cstddef> #include <optional> #include <string> +#include <utility> #include "absl/functional/any_invocable.h" #include "api/sequence_checker.h" @@ -22,6 +23,7 @@ #include "rtc_base/network/received_packet.h" #include "rtc_base/network/sent_packet.h" #include "rtc_base/network_route.h" +#include "rtc_base/sigslot_trampoline.h" #include "rtc_base/socket.h" #include "rtc_base/system/rtc_export.h" #include "rtc_base/third_party/sigslot/sigslot.h" @@ -70,6 +72,11 @@ class RTC_EXPORT PacketTransportInternal : public sigslot::has_slots<> { // Emitted when the writable state, represented by `writable()`, changes. sigslot::signal1<PacketTransportInternal*> SignalWritableState; + void SubscribeWritableState( + void* tag, + absl::AnyInvocable<void(PacketTransportInternal*)> callback); + void UnsubscribeWritableState(void* tag); + void NotifyWritableState(PacketTransportInternal* packet_transport); // Emitted when the PacketTransportInternal is ready to send packets. "Ready // to send" is more sensitive than the writable state; a transport may be @@ -77,9 +84,17 @@ class RTC_EXPORT PacketTransportInternal : public sigslot::has_slots<> { // underlying transport's socket buffer may be full, as indicated by // SendPacket's return code and/or GetError. sigslot::signal1<PacketTransportInternal*> SignalReadyToSend; + void SubscribeReadyToSend( + void* tag, + absl::AnyInvocable<void(PacketTransportInternal*)> callback); + void UnsubscribeReadyToSend(void* tag); + void NotifyReadyToSend(PacketTransportInternal* packet_transport); // Emitted when receiving state changes to true. sigslot::signal1<PacketTransportInternal*> SignalReceivingState; + void SubscribeReceivingState( + absl::AnyInvocable<void(PacketTransportInternal*)> callback); + void NotifyReceivingState(PacketTransportInternal* packet_transport); // Callback is invoked each time a packet is received on this channel. void RegisterReceivedPacketCallback( @@ -95,6 +110,12 @@ class RTC_EXPORT PacketTransportInternal : public sigslot::has_slots<> { // Signalled when the current network route has changed. sigslot::signal1<std::optional<NetworkRoute>> SignalNetworkRouteChanged; + void SubscribeNetworkRouteChanged( + void* tag, + absl::AnyInvocable<void(std::optional<NetworkRoute>)> callback); + void UnsubscribeNetworkRouteChanged(void* tag); + void NotifyNetworkRouteChanged( + std::optional<webrtc::NetworkRoute> network_route); // Signalled when the transport is closed. void SetOnCloseCallback(absl::AnyInvocable<void() &&> callback); @@ -112,6 +133,18 @@ class RTC_EXPORT PacketTransportInternal : public sigslot::has_slots<> { CallbackList<PacketTransportInternal*, const ReceivedIpPacket&> received_packet_callback_list_ RTC_GUARDED_BY(&network_checker_); absl::AnyInvocable<void() &&> on_close_; + SignalTrampoline<PacketTransportInternal, + &PacketTransportInternal::SignalWritableState> + writable_state_trampoline_; + SignalTrampoline<PacketTransportInternal, + &PacketTransportInternal::SignalReadyToSend> + ready_to_send_trampoline_; + SignalTrampoline<PacketTransportInternal, + &PacketTransportInternal::SignalReceivingState> + receiving_state_trampoline_; + SignalTrampoline<PacketTransportInternal, + &PacketTransportInternal::SignalNetworkRouteChanged> + network_route_changed_trampoline_; }; } // namespace webrtc diff --git a/third_party/libwebrtc/p2p/base/regathering_controller.cc b/third_party/libwebrtc/p2p/base/regathering_controller.cc @@ -31,12 +31,18 @@ BasicRegatheringController::BasicRegatheringController( [this](IceTransportInternal* transport) { OnIceTransportStateChanged(transport); }); - ice_transport->SignalWritableState.connect( - this, &BasicRegatheringController::OnIceTransportWritableState); - ice_transport->SignalReceivingState.connect( - this, &BasicRegatheringController::OnIceTransportReceivingState); - ice_transport->SignalNetworkRouteChanged.connect( - this, &BasicRegatheringController::OnIceTransportNetworkRouteChanged); + ice_transport->SubscribeWritableState( + this, [this](PacketTransportInternal* transport) { + OnIceTransportWritableState(transport); + }); + ice_transport->SubscribeReceivingState( + [this](PacketTransportInternal* transport) { + OnIceTransportReceivingState(transport); + }); + ice_transport->SubscribeNetworkRouteChanged( + this, [this](std::optional<NetworkRoute> network_route) { + OnIceTransportNetworkRouteChanged(network_route); + }); } BasicRegatheringController::~BasicRegatheringController() { diff --git a/third_party/libwebrtc/p2p/dtls/dtls_transport.cc b/third_party/libwebrtc/p2p/dtls/dtls_transport.cc @@ -613,8 +613,10 @@ int DtlsTransportInternalImpl::SetOption(Socket::Option opt, int value) { void DtlsTransportInternalImpl::ConnectToIceTransport() { RTC_DCHECK(ice_transport_); - ice_transport_->SignalWritableState.connect( - this, &DtlsTransportInternalImpl::OnWritableState); + ice_transport_->SubscribeWritableState( + this, [this](PacketTransportInternal* transport) { + OnWritableState(transport); + }); ice_transport_->RegisterReceivedPacketCallback( this, [&](PacketTransportInternal* transport, const ReceivedIpPacket& packet) { @@ -623,32 +625,36 @@ void DtlsTransportInternalImpl::ConnectToIceTransport() { ice_transport_->SignalSentPacket.connect( this, &DtlsTransportInternalImpl::OnSentPacket); - ice_transport_->SignalReadyToSend.connect( - this, &DtlsTransportInternalImpl::OnReadyToSend); - ice_transport_->SignalReceivingState.connect( - this, &DtlsTransportInternalImpl::OnReceivingState); - ice_transport_->SignalNetworkRouteChanged.connect( - this, &DtlsTransportInternalImpl::OnNetworkRouteChanged); - ice_transport_->SetDtlsStunPiggybackCallbacks( - DtlsStunPiggybackCallbacks( - [&](auto stun_message_type) { - std::optional<absl::string_view> data; - std::optional<std::vector<uint32_t>> ack; - if (dtls_in_stun_) { - data = dtls_stun_piggyback_controller_.GetDataToPiggyback( - stun_message_type); - ack = dtls_stun_piggyback_controller_.GetAckToPiggyback( - stun_message_type); - } - return std::make_pair(data, ack); - }, - [&](std::optional<ArrayView<uint8_t>> data, - std::optional<std::vector<uint32_t>> acks) { - if (!dtls_in_stun_) { - return; - } - dtls_stun_piggyback_controller_.ReportDataPiggybacked(data, acks); - })); + ice_transport_->SubscribeReadyToSend( + this, + [this](PacketTransportInternal* transport) { OnReadyToSend(transport); }); + ice_transport_->SubscribeReceivingState( + [this](PacketTransportInternal* transport) { + OnReceivingState(transport); + }); + ice_transport_->SubscribeNetworkRouteChanged( + this, [this](std::optional<NetworkRoute> network_route) { + OnNetworkRouteChanged(network_route); + }); + ice_transport_->SetDtlsStunPiggybackCallbacks(DtlsStunPiggybackCallbacks( + [&](auto stun_message_type) { + std::optional<absl::string_view> data; + std::optional<std::vector<uint32_t>> ack; + if (dtls_in_stun_) { + data = dtls_stun_piggyback_controller_.GetDataToPiggyback( + stun_message_type); + ack = dtls_stun_piggyback_controller_.GetAckToPiggyback( + stun_message_type); + } + return std::make_pair(data, ack); + }, + [&](std::optional<ArrayView<uint8_t>> data, + std::optional<std::vector<uint32_t>> acks) { + if (!dtls_in_stun_) { + return; + } + dtls_stun_piggyback_controller_.ReportDataPiggybacked(data, acks); + })); SetPiggybackDtlsDataCallback([this](PacketTransportInternal* transport, const ReceivedIpPacket& packet) { RTC_DCHECK(dtls_active_); @@ -847,7 +853,7 @@ void DtlsTransportInternalImpl::OnReadyToSend( PacketTransportInternal* /* transport */) { RTC_DCHECK_RUN_ON(&thread_checker_); if (writable()) { - SignalReadyToSend(this); + NotifyReadyToSend(this); } } @@ -922,7 +928,7 @@ void DtlsTransportInternalImpl::OnDtlsEvent(int sig, int err) { void DtlsTransportInternalImpl::OnNetworkRouteChanged( std::optional<NetworkRoute> network_route) { RTC_DCHECK_RUN_ON(&thread_checker_); - SignalNetworkRouteChanged(network_route); + NotifyNetworkRouteChanged(network_route); } void DtlsTransportInternalImpl::MaybeStartDtls() { @@ -988,7 +994,7 @@ void DtlsTransportInternalImpl::set_receiving(bool receiving) { return; } receiving_ = receiving; - SignalReceivingState(this); + NotifyReceivingState(this); } void DtlsTransportInternalImpl::set_writable(bool writable) { @@ -1009,9 +1015,9 @@ void DtlsTransportInternalImpl::set_writable(bool writable) { RTC_LOG(LS_VERBOSE) << ToString() << ": set_writable to: " << writable; writable_ = writable; if (writable_) { - SignalReadyToSend(this); + NotifyReadyToSend(this); } - SignalWritableState(this); + NotifyWritableState(this); } void DtlsTransportInternalImpl::set_dtls_state(DtlsTransportState state) { diff --git a/third_party/libwebrtc/p2p/dtls/dtls_transport_unittest.cc b/third_party/libwebrtc/p2p/dtls/dtls_transport_unittest.cc @@ -143,8 +143,10 @@ class DtlsTestClient : public sigslot::has_slots<> { ssl_max_version_); // Note: Certificate may be null here if testing passthrough. dtls_transport_->SetLocalCertificate(certificate_); - dtls_transport_->SignalWritableState.connect( - this, &DtlsTestClient::OnTransportWritableState); + dtls_transport_->SubscribeWritableState( + this, [this](PacketTransportInternal* transport) { + OnTransportWritableState(transport); + }); dtls_transport_->RegisterReceivedPacketCallback( this, [&](PacketTransportInternal* transport, const ReceivedIpPacket& packet) { diff --git a/third_party/libwebrtc/p2p/dtls/fake_dtls_transport.h b/third_party/libwebrtc/p2p/dtls/fake_dtls_transport.h @@ -59,8 +59,10 @@ class FakeDtlsTransport : public DtlsTransportInternal { const ReceivedIpPacket& packet) { OnIceTransportReadPacket(transport, packet); }); - ice_transport_->SignalNetworkRouteChanged.connect( - this, &FakeDtlsTransport::OnNetworkRouteChanged); + ice_transport_->SubscribeNetworkRouteChanged( + this, [this](std::optional<NetworkRoute> network_route) { + OnNetworkRouteChanged(network_route); + }); } explicit FakeDtlsTransport(std::unique_ptr<FakeIceTransport> ice) @@ -74,8 +76,10 @@ class FakeDtlsTransport : public DtlsTransportInternal { const ReceivedIpPacket& packet) { OnIceTransportReadPacket(transport, packet); }); - ice_transport_->SignalNetworkRouteChanged.connect( - this, &FakeDtlsTransport::OnNetworkRouteChanged); + ice_transport_->SubscribeNetworkRouteChanged( + this, [this](std::optional<NetworkRoute> network_route) { + OnNetworkRouteChanged(network_route); + }); } // If this constructor is called, a new fake ICE transport will be created, @@ -294,7 +298,7 @@ class FakeDtlsTransport : public DtlsTransportInternal { return; } receiving_ = receiving; - SignalReceivingState(this); + NotifyReceivingState(this); } void set_writable(bool writable) { @@ -303,13 +307,13 @@ class FakeDtlsTransport : public DtlsTransportInternal { } writable_ = writable; if (writable_) { - SignalReadyToSend(this); + NotifyReadyToSend(this); } - SignalWritableState(this); + NotifyWritableState(this); } void OnNetworkRouteChanged(std::optional<NetworkRoute> network_route) { - SignalNetworkRouteChanged(network_route); + NotifyNetworkRouteChanged(network_route); } FakeIceTransport* ice_transport_; @@ -334,5 +338,4 @@ class FakeDtlsTransport : public DtlsTransportInternal { } // namespace webrtc - #endif // P2P_DTLS_FAKE_DTLS_TRANSPORT_H_ diff --git a/third_party/libwebrtc/p2p/test/fake_ice_transport.h b/third_party/libwebrtc/p2p/test/fake_ice_transport.h @@ -388,7 +388,7 @@ class FakeIceTransport : public IceTransportInternal { network_route_ = network_route; SendTask(network_thread_, [this] { RTC_DCHECK_RUN_ON(network_thread_); - SignalNetworkRouteChanged(network_route_); + NotifyNetworkRouteChanged(network_route_); }); } @@ -505,9 +505,9 @@ class FakeIceTransport : public IceTransportInternal { RTC_LOG(LS_INFO) << "Change writable_ to " << writable; writable_ = writable; if (writable_) { - SignalReadyToSend(this); + NotifyReadyToSend(this); } - SignalWritableState(this); + NotifyWritableState(this); } void set_receiving(bool receiving) @@ -516,7 +516,7 @@ class FakeIceTransport : public IceTransportInternal { return; } receiving_ = receiving; - SignalReceivingState(this); + NotifyReceivingState(this); } bool SendPacketInternal(const CopyOnWriteBuffer& packet, diff --git a/third_party/libwebrtc/p2p/test/fake_packet_transport.h b/third_party/libwebrtc/p2p/test/fake_packet_transport.h @@ -106,7 +106,7 @@ class FakePacketTransport : public PacketTransportInternal { } void SetNetworkRoute(std::optional<NetworkRoute> network_route) { network_route_ = network_route; - SignalNetworkRouteChanged(network_route); + NotifyNetworkRouteChanged(network_route); } using PacketTransportInternal::NotifyOnClose; @@ -119,9 +119,9 @@ class FakePacketTransport : public PacketTransportInternal { } writable_ = writable; if (writable_) { - SignalReadyToSend(this); + NotifyReadyToSend(this); } - SignalWritableState(this); + NotifyWritableState(this); } void set_receiving(bool receiving) { @@ -129,7 +129,7 @@ class FakePacketTransport : public PacketTransportInternal { return; } receiving_ = receiving; - SignalReceivingState(this); + NotifyReceivingState(this); } void SendPacketInternal(const CopyOnWriteBuffer& packet, diff --git a/third_party/libwebrtc/p2p/test/mock_ice_transport.h b/third_party/libwebrtc/p2p/test/mock_ice_transport.h @@ -31,8 +31,8 @@ namespace webrtc { class MockIceTransport : public IceTransportInternal { public: MockIceTransport() { - SignalReadyToSend(this); - SignalWritableState(this); + NotifyReadyToSend(this); + NotifyWritableState(this); } MOCK_METHOD(int, diff --git a/third_party/libwebrtc/pc/channel_unittest.cc b/third_party/libwebrtc/pc/channel_unittest.cc @@ -1046,7 +1046,7 @@ class ChannelTest : public ::testing::Test { SendTask(network_thread_, [this] { webrtc::NetworkRoute network_route; // The transport channel becomes disconnected. - fake_rtp_dtls_transport1_->ice_transport()->SignalNetworkRouteChanged( + fake_rtp_dtls_transport1_->ice_transport()->NotifyNetworkRouteChanged( std::optional<webrtc::NetworkRoute>(network_route)); }); WaitForThreads(); @@ -1064,7 +1064,7 @@ class ChannelTest : public ::testing::Test { network_route.last_sent_packet_id = kLastPacketId; network_route.packet_overhead = kTransportOverheadPerPacket; // The transport channel becomes connected. - fake_rtp_dtls_transport1_->ice_transport()->SignalNetworkRouteChanged( + fake_rtp_dtls_transport1_->ice_transport()->NotifyNetworkRouteChanged( std::optional<webrtc::NetworkRoute>(network_route)); }); diff --git a/third_party/libwebrtc/pc/jsep_transport_controller.cc b/third_party/libwebrtc/pc/jsep_transport_controller.cc @@ -514,10 +514,15 @@ JsepTransportController::CreateDtlsTransport(const ContentInfo& content_info, } // Connect to signals offered by the DTLS and ICE transport. - dtls->SignalWritableState.connect( - this, &JsepTransportController::OnTransportWritableState_n); - dtls->SignalReceivingState.connect( - this, &JsepTransportController::OnTransportReceivingState_n); + dtls->SubscribeWritableState(this, + [this](PacketTransportInternal* transport) { + RTC_DCHECK_RUN_ON(network_thread_); + OnTransportWritableState_n(transport); + }); + dtls->SubscribeReceivingState([this](PacketTransportInternal* transport) { + RTC_DCHECK_RUN_ON(network_thread_); + OnTransportReceivingState_n(transport); + }); dtls->ice_transport()->AddGatheringStateCallback( this, [this](IceTransportInternal* transport) { RTC_DCHECK_RUN_ON(network_thread_); diff --git a/third_party/libwebrtc/pc/rtp_transport.cc b/third_party/libwebrtc/pc/rtp_transport.cc @@ -66,26 +66,32 @@ void RtpTransport::SetRtpPacketTransport( return; } if (rtp_packet_transport_) { - rtp_packet_transport_->SignalReadyToSend.disconnect(this); + rtp_packet_transport_->UnsubscribeReadyToSend(this); rtp_packet_transport_->DeregisterReceivedPacketCallback(this); - rtp_packet_transport_->SignalNetworkRouteChanged.disconnect(this); - rtp_packet_transport_->SignalWritableState.disconnect(this); + rtp_packet_transport_->UnsubscribeNetworkRouteChanged(this); + rtp_packet_transport_->UnsubscribeWritableState(this); rtp_packet_transport_->SignalSentPacket.disconnect(this); // Reset the network route of the old transport. SendNetworkRouteChanged(std::optional<NetworkRoute>()); } if (new_packet_transport) { - new_packet_transport->SignalReadyToSend.connect( - this, &RtpTransport::OnReadyToSend); + new_packet_transport->SubscribeReadyToSend( + this, [this](PacketTransportInternal* transport) { + OnReadyToSend(transport); + }); new_packet_transport->RegisterReceivedPacketCallback( this, [&](PacketTransportInternal* transport, const ReceivedIpPacket& packet) { OnReadPacket(transport, packet); }); - new_packet_transport->SignalNetworkRouteChanged.connect( - this, &RtpTransport::OnNetworkRouteChanged); - new_packet_transport->SignalWritableState.connect( - this, &RtpTransport::OnWritableState); + new_packet_transport->SubscribeNetworkRouteChanged( + this, [this](std::optional<NetworkRoute> network_route) { + OnNetworkRouteChanged(network_route); + }); + new_packet_transport->SubscribeWritableState( + this, [this](PacketTransportInternal* transport) { + OnWritableState(transport); + }); new_packet_transport->SignalSentPacket.connect(this, &RtpTransport::OnSentPacket); // Set the network route for the new transport. @@ -103,26 +109,32 @@ void RtpTransport::SetRtcpPacketTransport( return; } if (rtcp_packet_transport_) { - rtcp_packet_transport_->SignalReadyToSend.disconnect(this); + rtcp_packet_transport_->UnsubscribeReadyToSend(this); rtcp_packet_transport_->DeregisterReceivedPacketCallback(this); - rtcp_packet_transport_->SignalNetworkRouteChanged.disconnect(this); - rtcp_packet_transport_->SignalWritableState.disconnect(this); + rtcp_packet_transport_->UnsubscribeNetworkRouteChanged(this); + rtcp_packet_transport_->UnsubscribeWritableState(this); rtcp_packet_transport_->SignalSentPacket.disconnect(this); // Reset the network route of the old transport. SendNetworkRouteChanged(std::optional<NetworkRoute>()); } if (new_packet_transport) { - new_packet_transport->SignalReadyToSend.connect( - this, &RtpTransport::OnReadyToSend); + new_packet_transport->SubscribeReadyToSend( + this, [this](PacketTransportInternal* transport) { + OnReadyToSend(transport); + }); new_packet_transport->RegisterReceivedPacketCallback( this, [&](PacketTransportInternal* transport, const ReceivedIpPacket& packet) { OnReadPacket(transport, packet); }); - new_packet_transport->SignalNetworkRouteChanged.connect( - this, &RtpTransport::OnNetworkRouteChanged); - new_packet_transport->SignalWritableState.connect( - this, &RtpTransport::OnWritableState); + new_packet_transport->SubscribeNetworkRouteChanged( + this, [this](std::optional<NetworkRoute> network_route) { + OnNetworkRouteChanged(network_route); + }); + new_packet_transport->SubscribeWritableState( + this, [this](PacketTransportInternal* transport) { + OnWritableState(transport); + }); new_packet_transport->SignalSentPacket.connect(this, &RtpTransport::OnSentPacket); // Set the network route for the new transport.