commit e0e4055de4dc8e1af4577a771e812e18a3429336
parent ddb60a461c96533894354083f43fdc63bbb4d393
Author: Dan Baker <dbaker@mozilla.com>
Date: Mon, 1 Dec 2025 22:06:51 -0700
Bug 2000941 - Vendor libwebrtc from 9d96efa663
Upstream commit: https://webrtc.googlesource.com/src/+/9d96efa6636285658882298af94ade2b40f90f62
Remove signals from p2p/base/connection.h
Bug: webrtc:42222066
Change-Id: I227d7b38d9d4ba8c2876b3b9384493d1e306dd56
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/410100
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45684}
Diffstat:
5 files changed, 49 insertions(+), 43 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-02T05:04:15.351620+00:00.
+libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T05:06:36.728612+00:00.
# base of lastest vendoring
-b71605e1a0
+9d96efa663
diff --git a/third_party/libwebrtc/p2p/base/connection.cc b/third_party/libwebrtc/p2p/base/connection.cc
@@ -261,11 +261,7 @@ Connection::Connection(const Environment& env,
delta_internal_unix_epoch_(Timestamp::Millis(TimeUTCMillis()) -
time_created_),
field_trials_(&kDefaultFieldTrials),
- rtt_estimate_(kDefaultRttEstimateHalfTimeMs),
- state_change_trampoline_(this),
- destroyed_trampoline_(this),
- ready_to_send_trampoline_(this),
- nominated_trampoline_(this) {
+ rtt_estimate_(kDefaultRttEstimateHalfTimeMs) {
RTC_DCHECK_RUN_ON(network_thread_);
RTC_DCHECK(port_);
RTC_LOG(LS_INFO) << ToString() << ": Connection created";
@@ -339,7 +335,7 @@ void Connection::set_write_state(WriteState value) {
if (value != old_value) {
RTC_LOG(LS_VERBOSE) << ToString() << ": set_write_state from: " << old_value
<< " to " << value;
- SignalStateChange(this);
+ NotifyStateChange(this);
}
}
@@ -367,7 +363,7 @@ void Connection::UpdateReceiving(Timestamp now) {
RTC_LOG(LS_VERBOSE) << ToString() << ": set_receiving to " << receiving;
receiving_ = receiving;
receiving_unchanged_since_ = now;
- SignalStateChange(this);
+ NotifyStateChange(this);
}
void Connection::set_state(IceCandidatePairState state) {
@@ -385,7 +381,7 @@ void Connection::set_connected(bool value) {
connected_ = value;
if (value != old_value) {
RTC_LOG(LS_VERBOSE) << ToString() << ": Change connected_ to " << value;
- SignalStateChange(this);
+ NotifyStateChange(this);
}
}
@@ -755,7 +751,7 @@ void Connection::HandleStunBindingOrGoogPingRequest(IceMessage* msg) {
// We don't un-nominate a connection, so we only keep a larger nomination.
if (nomination > remote_nomination_) {
set_remote_nomination(nomination);
- SignalNominated(this);
+ NotifyNominated(this);
}
}
// Set the remote cost if the network_info attribute is available.
@@ -770,7 +766,7 @@ void Connection::HandleStunBindingOrGoogPingRequest(IceMessage* msg) {
remote_candidate_.set_network_cost(network_cost);
// Network cost change will affect the connection ranking, so signal
// state change to force a re-sort in P2PTransportChannel.
- SignalStateChange(this);
+ NotifyStateChange(this);
}
}
@@ -911,7 +907,7 @@ void Connection::set_remote_nomination(uint32_t remote_nomination) {
void Connection::OnReadyToSend() {
RTC_DCHECK_RUN_ON(network_thread_);
- SignalReadyToSend(this);
+ NotifyReadyToSend(this);
}
bool Connection::pruned() const {
@@ -948,9 +944,11 @@ bool Connection::Shutdown() {
// intentionally to avoid a situation whereby the signal might have dangling
// pointers to objects that have been deleted by the time the async task
// that deletes the connection object runs.
- auto destroyed_signals = SignalDestroyed;
- SignalDestroyed.disconnect_all();
- destroyed_signals(this);
+ // Note: With CallbackList, there's no way of clearing all callbacks.
+ // It would be cleaner if all callbacks used a safety flag on objects
+ // whose existence they care about.
+ // TODO: issues.webrtc.org/42222066 - figure out if this matters.
+ NotifyDestroyed(this);
LogCandidatePairConfig(IceCandidatePairConfigType::kDestroyed);
@@ -1792,9 +1790,9 @@ void Connection::MaybeUpdateLocalCandidate(StunRequest* request,
RTC_LOG(LS_INFO) << ToString()
<< ": Updating local candidate type to srflx.";
local_candidate_ = candidate;
- // SignalStateChange to force a re-sort in P2PTransportChannel as this
+ // NotifyStateChange to force a re-sort in P2PTransportChannel as this
// Connection's local candidate has changed.
- SignalStateChange(this);
+ NotifyStateChange(this);
}
return;
}
@@ -1828,9 +1826,9 @@ void Connection::MaybeUpdateLocalCandidate(StunRequest* request,
RTC_LOG(LS_INFO) << ToString() << ": Updating local candidate type to prflx.";
port_->AddPrflxCandidate(local_candidate_);
- // SignalStateChange to force a re-sort in P2PTransportChannel as this
+ // NotifyStateChange to force a re-sort in P2PTransportChannel as this
// Connection's local candidate has changed.
- SignalStateChange(this);
+ NotifyStateChange(this);
}
bool Connection::rtt_converged() const {
@@ -1873,7 +1871,7 @@ void Connection::SetLocalCandidateNetworkCost(uint16_t cost) {
// Network cost change will affect the connection selection criteria.
// Signal the connection state change to force a re-sort in
// P2PTransportChannel.
- SignalStateChange(this);
+ NotifyStateChange(this);
}
bool Connection::ShouldSendGoogPing(const StunMessage* message) {
diff --git a/third_party/libwebrtc/p2p/base/connection.h b/third_party/libwebrtc/p2p/base/connection.h
@@ -159,22 +159,19 @@ class RTC_EXPORT Connection : public CandidatePairInterface {
// populated (default value false).
ConnectionInfo stats();
- sigslot::signal1<Connection*> SignalStateChange;
void SubscribeStateChange(
absl::AnyInvocable<void(Connection* connection)> callback) {
- state_change_trampoline_.Subscribe(std::move(callback));
+ state_change_callbacks_.AddReceiver(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));
+ destroyed_callbacks_.AddReceiver(tag, std::move(callback));
}
void UnsubscribeDestroyed(void* tag) {
- destroyed_trampoline_.Unsubscribe(tag);
+ destroyed_callbacks_.RemoveReceivers(tag);
}
// The connection can send and receive packets asynchronously. This matches
@@ -193,12 +190,10 @@ class RTC_EXPORT Connection : public CandidatePairInterface {
received_packet_callback);
void DeregisterReceivedPacketCallback();
- sigslot::signal1<Connection*> SignalReadyToSend;
void SubscribeReadyToSend(
absl::AnyInvocable<void(Connection* connection)> callback) {
- ready_to_send_trampoline_.Subscribe(std::move(callback));
+ ready_to_send_callbacks_.AddReceiver(std::move(callback));
}
-
// Called when a packet is received on this connection.
void OnReadPacket(const ReceivedIpPacket& packet);
[[deprecated("Pass a ReceivedIpPacket")]] void
@@ -343,12 +338,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));
+ nominated_callbacks_.AddReceiver(std::move(callback));
}
-
IceCandidatePairState state() const;
int num_pings_sent() const;
@@ -470,6 +463,10 @@ class RTC_EXPORT Connection : public CandidatePairInterface {
return Timestamp::Millis(time.us() / 1000);
}
+ void NotifyNominatedForTesting(Connection* connection) {
+ NotifyNominated(connection);
+ }
+
protected:
// A ConnectionRequest is a simple STUN ping used to determine writability.
class ConnectionRequest;
@@ -534,6 +531,19 @@ class RTC_EXPORT Connection : public CandidatePairInterface {
// to last message ack:ed STUN_BINDING_REQUEST.
bool ShouldSendGoogPing(const StunMessage* message)
RTC_RUN_ON(network_thread_);
+ // Firing of callbacks.
+ void NotifyStateChange(Connection* connection) {
+ state_change_callbacks_.Send(connection);
+ }
+ void NotifyDestroyed(Connection* connection) {
+ destroyed_callbacks_.Send(connection);
+ }
+ void NotifyReadyToSend(Connection* connection) {
+ ready_to_send_callbacks_.Send(connection);
+ }
+ void NotifyNominated(Connection* connection) {
+ nominated_callbacks_.Send(connection);
+ }
const Environment env_;
@@ -638,14 +648,11 @@ 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_;
+
+ CallbackList<Connection*> state_change_callbacks_;
+ CallbackList<Connection*> destroyed_callbacks_;
+ CallbackList<Connection*> ready_to_send_callbacks_;
+ CallbackList<Connection*> nominated_callbacks_;
};
// ProxyConnection defers all the interesting work to the port.
diff --git a/third_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc b/third_party/libwebrtc/p2p/base/p2p_transport_channel_unittest.cc
@@ -3698,7 +3698,7 @@ class P2PTransportChannelPingTest : public ::testing::Test,
void NominateConnection(Connection* conn, uint32_t remote_nomination = 1U) {
conn->set_remote_nomination(remote_nomination);
- conn->SignalNominated(conn);
+ conn->NotifyNominatedForTesting(conn);
}
void OnNetworkRouteChanged(std::optional<NetworkRoute> network_route) {
diff --git a/third_party/libwebrtc/p2p/base/tcp_port.cc b/third_party/libwebrtc/p2p/base/tcp_port.cc
@@ -358,7 +358,8 @@ TCPConnection::TCPConnection(const Environment& env,
RTC_DCHECK_EQ(port()->GetProtocol(),
PROTO_TCP); // Needs to be TCPPort.
- SignalDestroyed.connect(this, &TCPConnection::OnDestroyed);
+ SubscribeDestroyed(
+ this, [this](Connection* connection) { OnDestroyed(connection); });
if (outgoing_) {
CreateOutgoingTcpSocket();