tor-browser

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

commit b8f0508d93629b96a874ade1d541e9eaf914efa0
parent 522d4d62c606b07240c393ed383be1f9aca2778e
Author: Dan Baker <dbaker@mozilla.com>
Date:   Mon,  1 Dec 2025 19:43:13 -0700

Bug 2000941 - Vendor libwebrtc from d9aeaa0f52

Upstream commit: https://webrtc.googlesource.com/src/+/d9aeaa0f52c65798738f36764caa2910f30d8962
    In IceController pass around Last ping time as Timestamp

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

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/p2p/BUILD.gn | 3+++
Mthird_party/libwebrtc/p2p/base/basic_ice_controller.cc | 6+++---
Mthird_party/libwebrtc/p2p/base/basic_ice_controller.h | 2+-
Mthird_party/libwebrtc/p2p/base/ice_agent_interface.h | 6+++++-
Mthird_party/libwebrtc/p2p/base/ice_controller_interface.h | 23+++++++++++++++++------
Mthird_party/libwebrtc/p2p/base/p2p_transport_channel.cc | 4++--
Mthird_party/libwebrtc/p2p/base/p2p_transport_channel.h | 2+-
Mthird_party/libwebrtc/p2p/base/wrapping_active_ice_controller.cc | 2+-
Mthird_party/libwebrtc/p2p/base/wrapping_active_ice_controller_unittest.cc | 23++++++++++++-----------
Mthird_party/libwebrtc/p2p/test/mock_ice_agent.h | 2++
Mthird_party/libwebrtc/p2p/test/mock_ice_controller.h | 2++
12 files changed, 51 insertions(+), 28 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-02T02:39:49.935383+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T02:42:54.596425+00:00. # base of lastest vendoring -6ffd467db2 +d9aeaa0f52 diff --git a/third_party/libwebrtc/p2p/BUILD.gn b/third_party/libwebrtc/p2p/BUILD.gn @@ -367,6 +367,7 @@ rtc_source_set("ice_agent_interface") { ":ice_switch_reason", ":transport_description", "../api:array_view", + "../api/units:timestamp", ] } @@ -382,6 +383,8 @@ rtc_library("ice_controller_interface") { ":p2p_transport_channel_ice_field_trials", ":transport_description", "../api:array_view", + "../api/units:time_delta", + "../api/units:timestamp", "../rtc_base:checks", "../rtc_base/system:rtc_export", ] diff --git a/third_party/libwebrtc/p2p/base/basic_ice_controller.cc b/third_party/libwebrtc/p2p/base/basic_ice_controller.cc @@ -124,8 +124,8 @@ bool BasicIceController::HasPingableConnection() const { }); } -IceControllerInterface::PingResult BasicIceController::SelectConnectionToPing( - int64_t last_ping_sent_ms) { +IceControllerInterface::PingResult BasicIceController::GetConnectionToPing( + Timestamp last_ping_sent) { // When the selected connection is not receiving or not writable, or any // active connection has not been pinged enough times, use the weak ping // interval. @@ -140,7 +140,7 @@ IceControllerInterface::PingResult BasicIceController::SelectConnectionToPing( const Connection* conn = nullptr; if (Connection::AlignTime(env_.clock().CurrentTime()) >= - Timestamp::Millis(last_ping_sent_ms) + ping_interval) { + last_ping_sent + ping_interval) { conn = FindNextPingableConnection(); } return PingResult(conn, std::min(ping_interval, check_receiving_interval())); diff --git a/third_party/libwebrtc/p2p/base/basic_ice_controller.h b/third_party/libwebrtc/p2p/base/basic_ice_controller.h @@ -56,7 +56,7 @@ class BasicIceController : public IceControllerInterface { bool HasPingableConnection() const override; - PingResult SelectConnectionToPing(int64_t last_ping_sent_ms) override; + PingResult GetConnectionToPing(Timestamp last_ping_sent) override; bool GetUseCandidateAttr(const Connection* conn, NominationMode mode, diff --git a/third_party/libwebrtc/p2p/base/ice_agent_interface.h b/third_party/libwebrtc/p2p/base/ice_agent_interface.h @@ -14,6 +14,7 @@ #include <cstdint> #include "api/array_view.h" +#include "api/units/timestamp.h" #include "p2p/base/connection.h" #include "p2p/base/ice_switch_reason.h" #include "p2p/base/transport_description.h" @@ -32,7 +33,10 @@ class IceAgentInterface { // own, eg. in some switchover scenarios. Otherwise the ICE controller could // keep this state on its own. // TODO(bugs.webrtc.org/14367): route extra pings through the ICE controller. - virtual int64_t GetLastPingSentMs() const = 0; + virtual Timestamp GetLastPingSent() const = 0; + // TODO: bugs.webrtc.org/42223979 - Remove this function when chromium is + // updated to the one above. + virtual int64_t GetLastPingSentMs() const { return GetLastPingSent().ms(); } // Get the ICE role of this ICE agent. virtual IceRole GetIceRole() const = 0; diff --git a/third_party/libwebrtc/p2p/base/ice_controller_interface.h b/third_party/libwebrtc/p2p/base/ice_controller_interface.h @@ -17,6 +17,8 @@ #include <vector> #include "api/array_view.h" +#include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "p2p/base/connection.h" #include "p2p/base/ice_switch_reason.h" #include "p2p/base/ice_transport_internal.h" @@ -75,7 +77,7 @@ class IceControllerInterface { std::vector<const Connection*> connections_to_forget_state_on; }; - // This represents the result of a call to SelectConnectionToPing. + // This represents the result of a call to GetConnectionToPing. struct PingResult { PingResult(const Connection* conn, int _recheck_delay_ms) : connection(conn ? std::optional<const Connection*>(conn) @@ -92,12 +94,12 @@ class IceControllerInterface { // Connection that we should (optionally) ping. const std::optional<const Connection*> connection; - // The delay before P2PTransportChannel shall call SelectConnectionToPing() + // The delay before P2PTransportChannel shall call GetConnectionToPing() // again. // // Since the IceController determines which connection to ping and // only returns one connection at a time, the recheck_delay_ms does not have - // any obvious implication on bitrate for pings. E.g the recheck_delay_ms + // any obvious implication on bitrate for pings. E.g the recheck_delay // will be shorter if there are more connections available. const int recheck_delay_ms = 0; }; @@ -125,11 +127,20 @@ class IceControllerInterface { // Is there a pingable connection ? // This function is used to boot-strap pinging, after this returns true - // SelectConnectionToPing() will be called periodically. + // GetConnectionToPing() will be called periodically. virtual bool HasPingableConnection() const = 0; - // Select a connection to Ping, or nullptr if none. - virtual PingResult SelectConnectionToPing(int64_t last_ping_sent_ms) = 0; + // Selects a connection to Ping, or nullptr if none. + // TODO: bugs.webrtc.org/42223979 - make pure virtual when implemented by + // downstream. + virtual PingResult GetConnectionToPing(Timestamp last_ping_sent) { + return SelectConnectionToPing(last_ping_sent.ms()); + } + // TODO: bugs.webrtc.org/42223979 - Remove when downstream implementaions are + // removed. + virtual PingResult SelectConnectionToPing(int64_t last_ping_sent_ms) { + return GetConnectionToPing(Timestamp::Millis(last_ping_sent_ms)); + } // Compute the "STUN_ATTR_USE_CANDIDATE" for `conn`. virtual bool GetUseCandidateAttr(const Connection* conn, diff --git a/third_party/libwebrtc/p2p/base/p2p_transport_channel.cc b/third_party/libwebrtc/p2p/base/p2p_transport_channel.cc @@ -2064,9 +2064,9 @@ Connection* P2PTransportChannel::FindNextPingableConnection() { } } -int64_t P2PTransportChannel::GetLastPingSentMs() const { +Timestamp P2PTransportChannel::GetLastPingSent() const { RTC_DCHECK_RUN_ON(network_thread_); - return last_ping_sent_.ms(); + return last_ping_sent_; } void P2PTransportChannel::SendPingRequest(const Connection* connection) { diff --git a/third_party/libwebrtc/p2p/base/p2p_transport_channel.h b/third_party/libwebrtc/p2p/base/p2p_transport_channel.h @@ -157,7 +157,7 @@ class RTC_EXPORT P2PTransportChannel : public IceTransportInternal, // From IceAgentInterface void OnStartedPinging() override; - int64_t GetLastPingSentMs() const override; + Timestamp GetLastPingSent() const override; void UpdateConnectionStates() override; void UpdateState() override; void SendPingRequest(const Connection* connection) override; diff --git a/third_party/libwebrtc/p2p/base/wrapping_active_ice_controller.cc b/third_party/libwebrtc/p2p/base/wrapping_active_ice_controller.cc @@ -124,7 +124,7 @@ void WrappingActiveIceController::SelectAndPingConnection() { agent_.UpdateConnectionStates(); IceControllerInterface::PingResult result = - wrapped_->SelectConnectionToPing(agent_.GetLastPingSentMs()); + wrapped_->GetConnectionToPing(agent_.GetLastPingSent()); HandlePingResult(result); } diff --git a/third_party/libwebrtc/p2p/base/wrapping_active_ice_controller_unittest.cc b/third_party/libwebrtc/p2p/base/wrapping_active_ice_controller_unittest.cc @@ -15,6 +15,7 @@ #include <vector> #include "api/units/time_delta.h" +#include "api/units/timestamp.h" #include "p2p/base/connection.h" #include "p2p/base/ice_controller_factory_interface.h" #include "p2p/base/ice_controller_interface.h" @@ -253,21 +254,21 @@ TEST(WrappingActiveIceControllerTest, StartPingingAfterSortAndSwitch) { // Pinging does not start automatically, unless triggered through a sort. EXPECT_CALL(*wrapped, HasPingableConnection()).Times(0); - EXPECT_CALL(*wrapped, SelectConnectionToPing(_)).Times(0); + EXPECT_CALL(*wrapped, GetConnectionToPing).Times(0); EXPECT_CALL(agent, OnStartedPinging()).Times(0); controller.OnSortAndSwitchRequest(IceSwitchReason::DATA_RECEIVED); // Pinging does not start if no pingable connection. EXPECT_CALL(*wrapped, HasPingableConnection()).WillOnce(Return(false)); - EXPECT_CALL(*wrapped, SelectConnectionToPing(_)).Times(0); + EXPECT_CALL(*wrapped, GetConnectionToPing).Times(0); EXPECT_CALL(agent, OnStartedPinging()).Times(0); // Unblock the init task. clock.AdvanceTime(init_delay); - int recheck_delay_ms = 10; - IceControllerInterface::PingResult ping_result(kConnection, recheck_delay_ms); + TimeDelta recheck_delay = TimeDelta::Millis(10); + IceControllerInterface::PingResult ping_result(kConnection, recheck_delay); // Pinging starts when there is a pingable connection. Sequence start_pinging; @@ -275,10 +276,10 @@ TEST(WrappingActiveIceControllerTest, StartPingingAfterSortAndSwitch) { .InSequence(start_pinging) .WillOnce(Return(true)); EXPECT_CALL(agent, OnStartedPinging()).InSequence(start_pinging); - EXPECT_CALL(agent, GetLastPingSentMs()) + EXPECT_CALL(agent, GetLastPingSent) .InSequence(start_pinging) - .WillOnce(Return(123)); - EXPECT_CALL(*wrapped, SelectConnectionToPing(123)) + .WillOnce(Return(Timestamp::Millis(123))); + EXPECT_CALL(*wrapped, GetConnectionToPing(Timestamp::Millis(123))) .InSequence(start_pinging) .WillOnce(Return(ping_result)); EXPECT_CALL(agent, SendPingRequest(kConnection)).InSequence(start_pinging); @@ -288,13 +289,13 @@ TEST(WrappingActiveIceControllerTest, StartPingingAfterSortAndSwitch) { // ICE controller should recheck and ping after the recheck delay. // No ping should be sent if no connection selected to ping. - EXPECT_CALL(agent, GetLastPingSentMs()).WillOnce(Return(456)); - EXPECT_CALL(*wrapped, SelectConnectionToPing(456)) + EXPECT_CALL(agent, GetLastPingSent).WillOnce(Return(Timestamp::Millis(456))); + EXPECT_CALL(*wrapped, GetConnectionToPing(Timestamp::Millis(456))) .WillOnce(Return(IceControllerInterface::PingResult( - /* connection= */ nullptr, recheck_delay_ms))); + /* connection= */ nullptr, recheck_delay))); EXPECT_CALL(agent, SendPingRequest(kConnection)).Times(0); - clock.AdvanceTime(TimeDelta::Millis(recheck_delay_ms)); + clock.AdvanceTime(recheck_delay); } } // namespace diff --git a/third_party/libwebrtc/p2p/test/mock_ice_agent.h b/third_party/libwebrtc/p2p/test/mock_ice_agent.h @@ -14,6 +14,7 @@ #include <cstdint> #include "api/array_view.h" +#include "api/units/timestamp.h" #include "p2p/base/connection.h" #include "p2p/base/ice_agent_interface.h" #include "p2p/base/ice_switch_reason.h" @@ -26,6 +27,7 @@ class MockIceAgent : public IceAgentInterface { public: ~MockIceAgent() override = default; + MOCK_METHOD(Timestamp, GetLastPingSent, (), (override, const)); MOCK_METHOD(int64_t, GetLastPingSentMs, (), (override, const)); MOCK_METHOD(IceRole, GetIceRole, (), (override, const)); MOCK_METHOD(void, OnStartedPinging, (), (override)); diff --git a/third_party/libwebrtc/p2p/test/mock_ice_controller.h b/third_party/libwebrtc/p2p/test/mock_ice_controller.h @@ -16,6 +16,7 @@ #include <vector> #include "api/array_view.h" +#include "api/units/timestamp.h" #include "p2p/base/connection.h" #include "p2p/base/ice_controller_factory_interface.h" #include "p2p/base/ice_controller_interface.h" @@ -43,6 +44,7 @@ class MockIceController : public IceControllerInterface { MOCK_METHOD(ArrayView<const Connection*>, connections, (), (const, override)); MOCK_METHOD(bool, HasPingableConnection, (), (const, override)); MOCK_METHOD(PingResult, SelectConnectionToPing, (int64_t), (override)); + MOCK_METHOD(PingResult, GetConnectionToPing, (Timestamp), (override)); MOCK_METHOD(bool, GetUseCandidateAttr, (const Connection*, NominationMode, IceMode),