tor-browser

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

commit 4dd9d57508f0bec3a9a40a596f4607fa482646a8
parent 14bd24cb136b822096bbfbc0e4aded3da1f69571
Author: Dan Baker <dbaker@mozilla.com>
Date:   Mon,  1 Dec 2025 17:48:22 -0700

Bug 2000941 - Vendor libwebrtc from 96d324afa7

Upstream commit: https://webrtc.googlesource.com/src/+/96d324afa78503479016f45c3fff1856b51be023
    Use sigslot trampoline for signals on Connection

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

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/p2p/BUILD.gn | 1+
Mthird_party/libwebrtc/p2p/base/connection.cc | 6+++++-
Mthird_party/libwebrtc/p2p/base/connection.h | 29+++++++++++++++++++++++++++++
Mthird_party/libwebrtc/p2p/base/p2p_transport_channel.cc | 22++++++++++++----------
Mthird_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc | 4++--
Mthird_party/libwebrtc/p2p/base/port_unittest.cc | 23++++++++++++++---------
Mthird_party/libwebrtc/p2p/base/tcp_port_unittest.cc | 5+++--
Mthird_party/libwebrtc/p2p/base/turn_port_unittest.cc | 29++++++++++++++++++-----------
9 files changed, 86 insertions(+), 37 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-02T00:45:26.415668+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T00:48:07.016479+00:00. # base of lastest vendoring -a0e60db139 +96d324afa7 diff --git a/third_party/libwebrtc/p2p/BUILD.gn b/third_party/libwebrtc/p2p/BUILD.gn @@ -228,6 +228,7 @@ rtc_library("connection") { "../rtc_base:rate_tracker", "../rtc_base:rtc_numerics", "../rtc_base:safe_minmax", + "../rtc_base:sigslot_trampoline", "../rtc_base:socket", "../rtc_base:socket_address", "../rtc_base:stringutils", diff --git a/third_party/libwebrtc/p2p/base/connection.cc b/third_party/libwebrtc/p2p/base/connection.cc @@ -261,7 +261,11 @@ Connection::Connection(const Environment& env, delta_internal_unix_epoch_(Timestamp::Millis(TimeUTCMillis()) - time_created_), field_trials_(&kDefaultFieldTrials), - rtt_estimate_(kDefaultRttEstimateHalfTimeMs) { + rtt_estimate_(kDefaultRttEstimateHalfTimeMs), + state_change_trampoline_(this), + destroyed_trampoline_(this), + ready_to_send_trampoline_(this), + nominated_trampoline_(this) { RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK(port_); RTC_LOG(LS_INFO) << ToString() << ": Connection created"; diff --git a/third_party/libwebrtc/p2p/base/connection.h b/third_party/libwebrtc/p2p/base/connection.h @@ -45,6 +45,7 @@ #include "rtc_base/network/received_packet.h" #include "rtc_base/numerics/event_based_exponential_moving_average.h" #include "rtc_base/rate_tracker.h" +#include "rtc_base/sigslot_trampoline.h" #include "rtc_base/system/rtc_export.h" #include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread_annotations.h" @@ -159,10 +160,22 @@ class RTC_EXPORT Connection : public CandidatePairInterface { ConnectionInfo stats(); sigslot::signal1<Connection*> SignalStateChange; + void SubscribeStateChange( + absl::AnyInvocable<void(Connection* connection)> callback) { + state_change_trampoline_.Subscribe(std::move(callback)); + } // Sent when the connection has decided that it is no longer of value. It // will delete itself immediately after this call. sigslot::signal1<Connection*> SignalDestroyed; + void SubscribeDestroyed( + void* tag, + absl::AnyInvocable<void(Connection* connection)> callback) { + destroyed_trampoline_.Subscribe(tag, std::move(callback)); + } + void UnsubscribeDestroyed(void* tag) { + destroyed_trampoline_.Unsubscribe(tag); + } // The connection can send and receive packets asynchronously. This matches // the interface of AsyncPacketSocket, which may use UDP or TCP under the @@ -181,6 +194,10 @@ class RTC_EXPORT Connection : public CandidatePairInterface { void DeregisterReceivedPacketCallback(); sigslot::signal1<Connection*> SignalReadyToSend; + void SubscribeReadyToSend( + absl::AnyInvocable<void(Connection* connection)> callback) { + ready_to_send_trampoline_.Subscribe(std::move(callback)); + } // Called when a packet is received on this connection. void OnReadPacket(const ReceivedIpPacket& packet); @@ -327,6 +344,10 @@ class RTC_EXPORT Connection : public CandidatePairInterface { // This signal will be fired if this connection is nominated by the // controlling side. sigslot::signal1<Connection*> SignalNominated; + void SubscribeNominated( + absl::AnyInvocable<void(Connection* connection)> callback) { + nominated_trampoline_.Subscribe(std::move(callback)); + } IceCandidatePairState state() const; @@ -617,6 +638,14 @@ class RTC_EXPORT Connection : public CandidatePairInterface { const StunMessage* msg, const StunRequest* original_request); DtlsStunPiggybackCallbacks dtls_stun_piggyback_callbacks_; + SignalTrampoline<Connection, &Connection::SignalStateChange> + state_change_trampoline_; + SignalTrampoline<Connection, &Connection::SignalDestroyed> + destroyed_trampoline_; + SignalTrampoline<Connection, &Connection::SignalReadyToSend> + ready_to_send_trampoline_; + SignalTrampoline<Connection, &Connection::SignalNominated> + nominated_trampoline_; }; // ProxyConnection defers all the interesting work to the port. diff --git a/third_party/libwebrtc/p2p/base/p2p_transport_channel.cc b/third_party/libwebrtc/p2p/base/p2p_transport_channel.cc @@ -241,7 +241,7 @@ P2PTransportChannel::~P2PTransportChannel() { RTC_DCHECK_RUN_ON(network_thread_); std::vector<Connection*> copy(connections_.begin(), connections_.end()); for (Connection* connection : copy) { - connection->SignalDestroyed.disconnect(this); + connection->UnsubscribeDestroyed(this); RemoveConnection(connection); connection->Destroy(); } @@ -306,13 +306,15 @@ void P2PTransportChannel::AddConnection(Connection* connection) { [&](Connection* connection, const ReceivedIpPacket& packet) { OnReadPacket(connection, packet); }); - connection->SignalReadyToSend.connect(this, - &P2PTransportChannel::OnReadyToSend); - connection->SignalStateChange.connect( - this, &P2PTransportChannel::OnConnectionStateChange); - connection->SignalDestroyed.connect( - this, &P2PTransportChannel::OnConnectionDestroyed); - connection->SignalNominated.connect(this, &P2PTransportChannel::OnNominated); + connection->SubscribeReadyToSend( + [this](Connection* connection) { OnReadyToSend(connection); }); + connection->SubscribeStateChange( + [this](Connection* connection) { OnConnectionStateChange(connection); }); + connection->SubscribeDestroyed(this, [this](Connection* connection) { + OnConnectionDestroyed(connection); + }); + connection->SubscribeNominated( + [this](Connection* connection) { OnNominated(connection); }); had_connection_ = true; @@ -1722,7 +1724,7 @@ ArrayView<Connection* const> P2PTransportChannel::connections() const { void P2PTransportChannel::RemoveConnectionForTest(Connection* connection) { RTC_DCHECK_RUN_ON(network_thread_); RTC_DCHECK(FindConnection(connection)); - connection->SignalDestroyed.disconnect(this); + connection->UnsubscribeDestroyed(this); RemoveConnection(connection); RTC_DCHECK(!FindConnection(connection)); if (selected_connection_ == connection) @@ -2030,7 +2032,7 @@ void P2PTransportChannel::HandleAllTimedOut() { selected_connection_ = nullptr; update_selected_connection = true; } - connection->SignalDestroyed.disconnect(this); + connection->UnsubscribeDestroyed(this); RemoveConnection(connection); connection->Destroy(); } diff --git a/third_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc b/third_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc @@ -1003,8 +1003,8 @@ class P2PTransportChannelTestBase : public ::testing::Test, void set_force_relay(bool relay) { force_relay_ = relay; } void ConnectSignalNominated(Connection* conn) { - conn->SignalNominated.connect(this, - &P2PTransportChannelTestBase::OnNominated); + conn->SubscribeNominated( + [this](Connection* connection) { OnNominated(connection); }); } void OnNominated(Connection* conn) { nominated_ = true; } diff --git a/third_party/libwebrtc/p2p/base/port_unittest.cc b/third_party/libwebrtc/p2p/base/port_unittest.cc @@ -314,11 +314,14 @@ class TestChannel : public sigslot::has_slots<> { IceMode remote_ice_mode = (ice_mode_ == ICEMODE_FULL) ? ICEMODE_LITE : ICEMODE_FULL; conn_->set_use_candidate_attr(remote_ice_mode == ICEMODE_FULL); - conn_->SignalStateChange.connect(this, - &TestChannel::OnConnectionStateChange); - conn_->SignalDestroyed.connect(this, &TestChannel::OnDestroyed); - conn_->SignalReadyToSend.connect(this, - &TestChannel::OnConnectionReadyToSend); + conn_->SubscribeStateChange([this](Connection* connection) { + OnConnectionStateChange(connection); + }); + conn_->SubscribeDestroyed( + this, [this](Connection* connection) { OnDestroyed(connection); }); + conn_->SubscribeReadyToSend([this](Connection* connection) { + OnConnectionReadyToSend(connection); + }); connection_ready_to_send_ = false; } @@ -330,14 +333,15 @@ class TestChannel : public sigslot::has_slots<> { } void AcceptConnection(const Candidate& remote_candidate) { if (conn_) { - conn_->SignalDestroyed.disconnect(this); + conn_->UnsubscribeDestroyed(this); conn_ = nullptr; } ASSERT_TRUE(remote_request_.get() != nullptr); Candidate c = remote_candidate; c.set_address(remote_address_); conn_ = port_->CreateConnection(c, Port::ORIGIN_MESSAGE); - conn_->SignalDestroyed.connect(this, &TestChannel::OnDestroyed); + conn_->SubscribeDestroyed( + this, [this](Connection* connection) { OnDestroyed(connection); }); conn_->SendStunBindingResponse(remote_request_.get()); remote_request_.reset(); } @@ -4096,8 +4100,9 @@ class ConnectionTest : public PortTest { conn = rport_->CreateConnection(lport_->Candidates()[0], Port::ORIGIN_MESSAGE); } - conn->SignalStateChange.connect(this, - &ConnectionTest::OnConnectionStateChange); + conn->SubscribeStateChange([this](Connection* connection) { + OnConnectionStateChange(connection); + }); return conn; } diff --git a/third_party/libwebrtc/p2p/base/tcp_port_unittest.cc b/third_party/libwebrtc/p2p/base/tcp_port_unittest.cc @@ -66,13 +66,14 @@ constexpr uint64_t kTiebreakerDefault = 44444; class ConnectionObserver : public sigslot::has_slots<> { public: explicit ConnectionObserver(Connection* conn) : conn_(conn) { - conn->SignalDestroyed.connect(this, &ConnectionObserver::OnDestroyed); + conn->SubscribeDestroyed( + this, [this](Connection* connection) { OnDestroyed(connection); }); } ~ConnectionObserver() override { if (!connection_destroyed_) { RTC_DCHECK(conn_); - conn_->SignalDestroyed.disconnect(this); + conn_->UnsubscribeDestroyed(this); } } diff --git a/third_party/libwebrtc/p2p/base/turn_port_unittest.cc b/third_party/libwebrtc/p2p/base/turn_port_unittest.cc @@ -185,13 +185,14 @@ class TurnPortTestVirtualSocketServer : public VirtualSocketServer { class TestConnectionWrapper : public sigslot::has_slots<> { public: explicit TestConnectionWrapper(Connection* conn) : connection_(conn) { - conn->SignalDestroyed.connect( - this, &TestConnectionWrapper::OnConnectionDestroyed); + conn->SubscribeDestroyed(this, [this](Connection* connection) { + OnConnectionDestroyed(connection); + }); } ~TestConnectionWrapper() override { if (connection_) { - connection_->SignalDestroyed.disconnect(this); + connection_->UnsubscribeDestroyed(this); } } @@ -793,15 +794,18 @@ class TurnPortTest : public ::testing::Test, turn_packets_.push_back( Buffer(packet.payload().data(), packet.payload().size())); }); - conn1->SignalDestroyed.connect(this, - &TurnPortTest::OnConnectionSignalDestroyed); + + conn1->SubscribeDestroyed(this, [this](Connection* connection) { + OnConnectionSignalDestroyed(connection); + }); conn2->RegisterReceivedPacketCallback( [&](Connection* connection, const ReceivedIpPacket& packet) { udp_packets_.push_back( Buffer(packet.payload().data(), packet.payload().size())); }); - conn2->SignalDestroyed.connect(this, - &TurnPortTest::OnConnectionSignalDestroyed); + conn2->SubscribeDestroyed(this, [this](Connection* connection) { + OnConnectionSignalDestroyed(connection); + }); conn1->Ping(0); EXPECT_THAT(WaitUntil([&] { return conn1->write_state(); }, Eq(Connection::STATE_WRITABLE), @@ -866,15 +870,18 @@ class TurnPortTest : public ::testing::Test, turn_packets_.push_back( Buffer(packet.payload().data(), packet.payload().size())); }); - conn1->SignalDestroyed.connect(this, - &TurnPortTest::OnConnectionSignalDestroyed); + conn1->SubscribeDestroyed(this, [this](Connection* connection) { + OnConnectionSignalDestroyed(connection); + }); + conn2->RegisterReceivedPacketCallback( [&](Connection* connection, const ReceivedIpPacket& packet) { udp_packets_.push_back( Buffer(packet.payload().data(), packet.payload().size())); }); - conn2->SignalDestroyed.connect(this, - &TurnPortTest::OnConnectionSignalDestroyed); + conn2->SubscribeDestroyed(this, [this](Connection* connection) { + OnConnectionSignalDestroyed(connection); + }); conn1->Ping(0); EXPECT_THAT(WaitUntil([&] { return conn1->write_state(); },