tor-browser

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

commit 3aacd81882f261d8b888546455efc811da576b7a
parent 5e973be67a99b0026d530046064e54c6c73443c5
Author: Dan Baker <dbaker@mozilla.com>
Date:   Fri, 24 Oct 2025 14:00:29 -0600

Bug 1995393 - Vendor libwebrtc from 962a3d52c2

Upstream commit: https://webrtc.googlesource.com/src/+/962a3d52c2184aa4df57d28f8967c08f5c4df6fd
    Add option to propagate clock into Connection

    Deprecate Connection constructor that doesn't take Environment and thus
    doesn't provide injectable clock.

    Bug: webrtc:42223992
    Change-Id: Iea35949b60916c8b31250d77e6a9ee5f9bf994e3
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/404583
    Reviewed-by: Per Kjellander <perkj@webrtc.org>
    Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#45401}

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/p2p/BUILD.gn | 2++
Mthird_party/libwebrtc/p2p/base/connection.cc | 22+++++++++++++++++++++-
Mthird_party/libwebrtc/p2p/base/connection.h | 13+++++++++++++
Mthird_party/libwebrtc/p2p/base/port.cc | 4++--
Mthird_party/libwebrtc/p2p/base/port.h | 4+---
Mthird_party/libwebrtc/p2p/base/port_unittest.cc | 3++-
Mthird_party/libwebrtc/p2p/base/stun_port.cc | 4++--
Mthird_party/libwebrtc/p2p/base/tcp_port.cc | 10++++++----
Mthird_party/libwebrtc/p2p/base/tcp_port.h | 4+++-
Mthird_party/libwebrtc/p2p/base/turn_port.cc | 2+-
11 files changed, 55 insertions(+), 17 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-10-24T19:57:27.900215+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-24T20:00:15.478822+00:00. # base of lastest vendoring -1d43877169 +962a3d52c2 diff --git a/third_party/libwebrtc/p2p/BUILD.gn b/third_party/libwebrtc/p2p/BUILD.gn @@ -195,6 +195,7 @@ rtc_library("connection") { "../api:packet_socket_factory", "../api:rtc_error", "../api:sequence_checker", + "../api/environment", "../api/task_queue", "../api/transport:enums", "../api/transport:stun_types", @@ -805,6 +806,7 @@ rtc_library("tcp_port") { "../api:candidate", "../api:packet_socket_factory", "../api:sequence_checker", + "../api/environment", "../api/task_queue:pending_task_safety_flag", "../api/transport:stun_types", "../api/units:time_delta", diff --git a/third_party/libwebrtc/p2p/base/connection.cc b/third_party/libwebrtc/p2p/base/connection.cc @@ -25,6 +25,7 @@ #include "absl/strings/string_view.h" #include "api/array_view.h" #include "api/candidate.h" +#include "api/environment/environment.h" #include "api/rtc_error.h" #include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" @@ -226,6 +227,16 @@ int Connection::ConnectionRequest::resend_delay() { return CONNECTION_RESPONSE_TIMEOUT; } +Connection::Connection(const Environment& /*env*/, + WeakPtr<PortInterface> port, + size_t index, + const Candidate& remote_candidate) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + : Connection(std::move(port), index, remote_candidate) { +} +#pragma clang diagnostic pop + Connection::Connection(WeakPtr<PortInterface> port, size_t index, const Candidate& remote_candidate) @@ -252,7 +263,7 @@ Connection::Connection(WeakPtr<PortInterface> port, last_ping_response_received_(0), state_(IceCandidatePairState::WAITING), time_created_ms_(TimeMillis()), - delta_internal_unix_epoch_ms_(TimeUTCMillis() - TimeMillis()), + delta_internal_unix_epoch_ms_(TimeUTCMillis() - time_created_ms_), field_trials_(&kDefaultFieldTrials), rtt_estimate_(DEFAULT_RTT_ESTIMATE_HALF_TIME_MS) { RTC_DCHECK_RUN_ON(network_thread_); @@ -1872,10 +1883,19 @@ void Connection::ForgetLearnedState() { pings_since_last_response_.clear(); } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" ProxyConnection::ProxyConnection(WeakPtr<PortInterface> port, size_t index, const Candidate& remote_candidate) : Connection(std::move(port), index, remote_candidate) {} +#pragma clang diagnostic pop + +ProxyConnection::ProxyConnection(const Environment& env, + WeakPtr<PortInterface> port, + size_t index, + const Candidate& remote_candidate) + : Connection(env, std::move(port), index, remote_candidate) {} int ProxyConnection::Send(const void* data, size_t size, diff --git a/third_party/libwebrtc/p2p/base/connection.h b/third_party/libwebrtc/p2p/base/connection.h @@ -23,6 +23,7 @@ #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" #include "api/candidate.h" +#include "api/environment/environment.h" #include "api/rtc_error.h" #include "api/sequence_checker.h" #include "api/task_queue/task_queue_base.h" @@ -371,10 +372,16 @@ class RTC_EXPORT Connection : public CandidatePairInterface { class ConnectionRequest; // Constructs a new connection to the given remote port. + [[deprecated("bugs.webrtc.org/42223992")]] Connection(WeakPtr<PortInterface> port, size_t index, const Candidate& candidate); + Connection(const Environment& env, + WeakPtr<PortInterface> port, + size_t index, + const Candidate& candidate); + // Called back when StunRequestManager has a stun packet to send void OnSendStunPacket(const void* data, size_t size, StunRequest* req); @@ -528,10 +535,16 @@ class RTC_EXPORT Connection : public CandidatePairInterface { // ProxyConnection defers all the interesting work to the port. class ProxyConnection : public Connection { public: + [[deprecated("bugs.webrtc.org/42223992")]] ProxyConnection(WeakPtr<PortInterface> port, size_t index, const Candidate& remote_candidate); + ProxyConnection(const Environment& env, + WeakPtr<PortInterface> port, + size_t index, + const Candidate& remote_candidate); + int Send(const void* data, size_t size, const AsyncSocketPacketOptions& options) override; diff --git a/third_party/libwebrtc/p2p/base/port.cc b/third_party/libwebrtc/p2p/base/port.cc @@ -245,7 +245,7 @@ void Port::AddAddress(const SocketAddress& address, c.set_priority( c.GetPriority(type_preference, network_->preference(), relay_preference, - field_trials().IsEnabled( + env().field_trials().IsEnabled( "WebRTC-IncreaseIceCandidatePriorityHostSrflx"))); #if RTC_DCHECK_IS_ON if (protocol == TCP_PROTOCOL_NAME && c.is_local()) { @@ -889,7 +889,7 @@ std::string Port::ToString() const { // TODO(honghaiz): Make the network cost configurable from user setting. void Port::UpdateNetworkCost() { RTC_DCHECK_RUN_ON(thread_); - uint16_t new_cost = network_->GetCost(field_trials()); + uint16_t new_cost = network_->GetCost(env().field_trials()); if (network_cost_ == new_cost) { return; } diff --git a/third_party/libwebrtc/p2p/base/port.h b/third_party/libwebrtc/p2p/base/port.h @@ -26,7 +26,6 @@ #include "absl/strings/string_view.h" #include "api/candidate.h" #include "api/environment/environment.h" -#include "api/field_trials_view.h" #include "api/local_network_access_permission.h" #include "api/packet_socket_factory.h" #include "api/sequence_checker.h" @@ -465,8 +464,7 @@ class RTC_EXPORT Port : public PortInterface, public sigslot::has_slots<> { mdns_name_registration_status_ = status; } - const FieldTrialsView& field_trials() const { return env_.field_trials(); } - + const Environment& env() const { return env_; } IceCandidateType type() const { return type_; } // Requests the Local Network Access Permission if necessary. Asynchronously diff --git a/third_party/libwebrtc/p2p/base/port_unittest.cc b/third_party/libwebrtc/p2p/base/port_unittest.cc @@ -209,7 +209,8 @@ class TestPort : public Port { Connection* CreateConnection(const Candidate& remote_candidate, CandidateOrigin /* origin */) override { - Connection* conn = new ProxyConnection(NewWeakPtr(), 0, remote_candidate); + Connection* conn = + new ProxyConnection(env(), NewWeakPtr(), 0, remote_candidate); AddOrReplaceConnection(conn); // Set use-candidate attribute flag as this will add USE-CANDIDATE attribute // in STUN binding requests. diff --git a/third_party/libwebrtc/p2p/base/stun_port.cc b/third_party/libwebrtc/p2p/base/stun_port.cc @@ -287,7 +287,7 @@ Connection* UDPPort::CreateConnection(const Candidate& address, mdns_name_registration_status() != MdnsNameRegistrationStatus::kNotStarted); - Connection* conn = new ProxyConnection(NewWeakPtr(), 0, address); + Connection* conn = new ProxyConnection(env(), NewWeakPtr(), 0, address); AddOrReplaceConnection(conn); return conn; } @@ -445,7 +445,7 @@ void UDPPort::ResolveStunAddress(const SocketAddress& stun_addr) { RTC_LOG(LS_INFO) << ToString() << ": Starting STUN host lookup for " << stun_addr.ToSensitiveString(); - resolver_->Resolve(stun_addr, Network()->family(), field_trials()); + resolver_->Resolve(stun_addr, Network()->family(), env().field_trials()); } void UDPPort::OnResolveResult(const SocketAddress& input, int error) { diff --git a/third_party/libwebrtc/p2p/base/tcp_port.cc b/third_party/libwebrtc/p2p/base/tcp_port.cc @@ -76,6 +76,7 @@ #include "absl/memory/memory.h" #include "absl/strings/string_view.h" #include "api/candidate.h" +#include "api/environment/environment.h" #include "api/packet_socket_factory.h" #include "api/sequence_checker.h" #include "api/task_queue/pending_task_safety_flag.h" @@ -161,10 +162,10 @@ Connection* TCPPort::CreateConnection(const Candidate& address, // so we need to hand off the "read packet" responsibility to // TCPConnection. socket->DeregisterReceivedPacketCallback(); - conn = new TCPConnection(NewWeakPtr(), address, socket); + conn = new TCPConnection(env(), NewWeakPtr(), address, socket); } else { // Outgoing connection, which will create a new socket. - conn = new TCPConnection(NewWeakPtr(), address); + conn = new TCPConnection(env(), NewWeakPtr(), address); } AddOrReplaceConnection(conn); return conn; @@ -343,10 +344,11 @@ void TCPPort::OnReadyToSend(AsyncPacketSocket* socket) { // `ice_unwritable_timeout` in IceConfig when determining the writability state. // Replace this constant with the config parameter assuming the default value if // we decide it is also applicable here. -TCPConnection::TCPConnection(WeakPtr<Port> tcp_port, +TCPConnection::TCPConnection(const Environment& env, + WeakPtr<Port> tcp_port, const Candidate& candidate, AsyncPacketSocket* socket) - : Connection(std::move(tcp_port), 0, candidate), + : Connection(env, std::move(tcp_port), 0, candidate), socket_(socket), error_(0), outgoing_(socket == nullptr), diff --git a/third_party/libwebrtc/p2p/base/tcp_port.h b/third_party/libwebrtc/p2p/base/tcp_port.h @@ -19,6 +19,7 @@ #include "absl/memory/memory.h" #include "absl/strings/string_view.h" #include "api/candidate.h" +#include "api/environment/environment.h" #include "api/sequence_checker.h" #include "api/task_queue/pending_task_safety_flag.h" #include "api/transport/stun.h" @@ -126,7 +127,8 @@ class TCPPort : public Port { class TCPConnection : public Connection, public sigslot::has_slots<> { public: // Connection is outgoing unless socket is specified - TCPConnection(WeakPtr<Port> tcp_port, + TCPConnection(const Environment& env, + WeakPtr<Port> tcp_port, const Candidate& candidate, AsyncPacketSocket* socket = nullptr); ~TCPConnection() override; diff --git a/third_party/libwebrtc/p2p/base/turn_port.cc b/third_party/libwebrtc/p2p/base/turn_port.cc @@ -623,7 +623,7 @@ Connection* TurnPort::CreateConnection(const Candidate& remote_candidate, if (local_candidate.is_relay() && local_candidate.address().family() == remote_candidate.address().family()) { ProxyConnection* conn = - new ProxyConnection(NewWeakPtr(), index, remote_candidate); + new ProxyConnection(env(), NewWeakPtr(), index, remote_candidate); // Create an entry, if needed, so we can get our permissions set up // correctly. if (CreateOrRefreshEntry(conn, next_channel_number_)) {