tor-browser

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

commit 4e54bfb07729ccb6a65cd72a3e0e99b6e7f67cd3
parent 9f9e4fa892125898c7aa2c26e17a42f0c31ccf45
Author: Dan Baker <dbaker@mozilla.com>
Date:   Mon,  1 Dec 2025 20:55:39 -0700

Bug 2000941 - Vendor libwebrtc from 9c45144f9b

Upstream commit: https://webrtc.googlesource.com/src/+/9c45144f9b0c10f40d67a7f150f808ac10ea0a3a
    Introduce helper comparator to simplify using std::unique_ptr as a key

    Bug: None
    Change-Id: I8f02da33e3e5966187668fec8570ea3df09f327e
    Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/409560
    Reviewed-by: Harald Alvestrand <hta@webrtc.org>
    Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
    Cr-Commit-Position: refs/heads/main@{#45657}

Diffstat:
Mthird_party/libwebrtc/README.mozilla.last-vendor | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0001.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0027.patch | 4++--
Mthird_party/libwebrtc/moz-patch-stack/s0053.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0091.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0094.patch | 2+-
Mthird_party/libwebrtc/moz-patch-stack/s0102.patch | 6+++---
Mthird_party/libwebrtc/moz-patch-stack/s0107.patch | 2+-
Mthird_party/libwebrtc/p2p/BUILD.gn | 1+
Mthird_party/libwebrtc/p2p/test/turn_server.cc | 20++++----------------
Mthird_party/libwebrtc/p2p/test/turn_server.h | 9+++++----
Mthird_party/libwebrtc/rtc_base/BUILD.gn | 1+
Mthird_party/libwebrtc/rtc_base/memory/BUILD.gn | 4++++
Athird_party/libwebrtc/rtc_base/memory/less_unique_ptr.h | 44++++++++++++++++++++++++++++++++++++++++++++
Mthird_party/libwebrtc/rtc_base/test_echo_server.cc | 7+------
Mthird_party/libwebrtc/rtc_base/test_echo_server.h | 20++++++++++++--------
16 files changed, 84 insertions(+), 46 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-02T03:53:06.243515+00:00. +libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T03:55:23.939638+00:00. # base of lastest vendoring -7afca54e66 +9c45144f9b diff --git a/third_party/libwebrtc/moz-patch-stack/s0001.patch b/third_party/libwebrtc/moz-patch-stack/s0001.patch @@ -1392,7 +1392,7 @@ index 5ccc3d7d38..cd957416bc 100644 const bool enable_svc_for_simulcast_; std::optional<SimulcastToSvcConverter> simulcast_to_svc_converter_; diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index bcf754532a..4ee3f2e5da 100644 +index db13e5a411..324a40843d 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -449,6 +449,12 @@ rtc_library("logging") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0027.patch b/third_party/libwebrtc/moz-patch-stack/s0027.patch @@ -1008,7 +1008,7 @@ index 39aa39a41c..b26e30e8bb 100644 "/config/external/nspr", "/nsprpub/lib/ds", diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index 4ee3f2e5da..7c81cb7e11 100644 +index 324a40843d..c629c55a07 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -326,6 +326,7 @@ rtc_library("sample_counter") { @@ -1176,7 +1176,7 @@ index 4ee3f2e5da..7c81cb7e11 100644 rtc_library("ssl_adapter") { visibility = [ "*" ] -@@ -2381,7 +2405,7 @@ if (rtc_include_tests) { +@@ -2382,7 +2406,7 @@ if (rtc_include_tests) { } } diff --git a/third_party/libwebrtc/moz-patch-stack/s0053.patch b/third_party/libwebrtc/moz-patch-stack/s0053.patch @@ -29,7 +29,7 @@ index 7db75d5fd3..d0feb5007c 100644 rtc_library("task_queue_test") { visibility = [ "*" ] diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index 7c81cb7e11..4fcb24dac9 100644 +index c629c55a07..03f57cf419 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -664,10 +664,14 @@ if (is_mac || is_ios) { diff --git a/third_party/libwebrtc/moz-patch-stack/s0091.patch b/third_party/libwebrtc/moz-patch-stack/s0091.patch @@ -13,7 +13,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/4e7b3c485e549e7e3 1 file changed, 6 insertions(+) diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index 4fcb24dac9..cfd568a547 100644 +index 03f57cf419..180a0656f1 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -992,6 +992,12 @@ rtc_library("threading") { diff --git a/third_party/libwebrtc/moz-patch-stack/s0094.patch b/third_party/libwebrtc/moz-patch-stack/s0094.patch @@ -9,7 +9,7 @@ Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/ee2f06666bcc6d22c 1 file changed, 2 insertions(+) diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index cfd568a547..ac5509181c 100644 +index 180a0656f1..3ce3e5d941 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -1690,6 +1690,7 @@ if (!build_with_mozilla) { diff --git a/third_party/libwebrtc/moz-patch-stack/s0102.patch b/third_party/libwebrtc/moz-patch-stack/s0102.patch @@ -616,7 +616,7 @@ index 4c837bb838..96fbcc9539 100644 if (rtc_build_libsrtp) { diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index ac5509181c..9a77523e17 100644 +index 3ce3e5d941..f53d995584 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -9,8 +9,8 @@ @@ -630,7 +630,7 @@ index ac5509181c..9a77523e17 100644 } rtc_source_set("protobuf_utils") { -@@ -1933,8 +1933,8 @@ if (!rtc_rusty_base64) { +@@ -1934,8 +1934,8 @@ if (!rtc_rusty_base64) { ] } } else { @@ -642,7 +642,7 @@ index ac5509181c..9a77523e17 100644 rust_static_library("base64_rust_bridge") { allow_unsafe = true # Needed for FFI with cxx crate. diff --git a/rtc_base/memory/BUILD.gn b/rtc_base/memory/BUILD.gn -index 9a55af3ea9..3d272ba975 100644 +index 6256372e5c..26d9491cff 100644 --- a/rtc_base/memory/BUILD.gn +++ b/rtc_base/memory/BUILD.gn @@ -8,8 +8,8 @@ diff --git a/third_party/libwebrtc/moz-patch-stack/s0107.patch b/third_party/libwebrtc/moz-patch-stack/s0107.patch @@ -116,7 +116,7 @@ index ecbb7eae7e..a13fe19324 100644 public_configs = [] if (!build_with_chromium) { diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn -index 9a77523e17..3b7ad9be91 100644 +index f53d995584..978e369668 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -1569,6 +1569,7 @@ rtc_source_set("ssl_header") { diff --git a/third_party/libwebrtc/p2p/BUILD.gn b/third_party/libwebrtc/p2p/BUILD.gn @@ -1360,6 +1360,7 @@ rtc_library("p2p_server_utils") { "../rtc_base:ssl_adapter", "../rtc_base:stringutils", "../rtc_base:timeutils", + "../rtc_base/memory:less_unique_ptr", "../rtc_base/network:received_packet", "../rtc_base/third_party/sigslot", "//third_party/abseil-cpp/absl/algorithm:container", diff --git a/third_party/libwebrtc/p2p/test/turn_server.cc b/third_party/libwebrtc/p2p/test/turn_server.cc @@ -67,17 +67,6 @@ bool IsTurnChannelData(uint16_t msg_type) { return ((msg_type & 0xC000) == 0x4000); } -// Helper to search a map keyed by unique_ptr using raw pointer. -template <typename Map, typename Key> -Map::iterator FindByRawPtr(Map& map, Key* ptr) { - // Wrap raw pointer to unique_ptr to be able to compare it with map keys. - std::unique_ptr<Key> uptr = absl::WrapUnique(ptr); - typename Map::iterator iter = map.find(uptr); - // Do not forget to release ownership as `ptr` is passed without ownership. - uptr.release(); - return iter; -} - } // namespace int GetStunSuccessResponseTypeOrZero(const StunMessage& req) { @@ -144,7 +133,7 @@ void TurnServer::SetExternalSocketFactory(PacketSocketFactory* factory, void TurnServer::OnNewInternalConnection(Socket* socket) { RTC_DCHECK_RUN_ON(thread_); - auto iter = FindByRawPtr(server_listen_sockets_, socket); + auto iter = server_listen_sockets_.find(socket); RTC_DCHECK(iter != server_listen_sockets_.end()); // Check if someone is trying to connect to us. @@ -173,8 +162,7 @@ void TurnServer::OnNewInternalConnection(Socket* socket) { void TurnServer::OnInternalSocketClose(AsyncPacketSocket* socket, int err) { RTC_DCHECK_RUN_ON(thread_); - if (auto iter = FindByRawPtr(server_sockets_, socket); - iter != server_sockets_.end()) { + if (auto iter = server_sockets_.find(socket); iter != server_sockets_.end()) { DestroyInternalSocket(iter); } } @@ -186,7 +174,7 @@ void TurnServer::OnInternalPacket(AsyncPacketSocket* socket, if (packet.payload().size() < TURN_CHANNEL_HEADER_SIZE) { return; } - auto iter = FindByRawPtr(server_sockets_, socket); + auto iter = server_sockets_.find(socket); RTC_DCHECK(iter != server_sockets_.end()); TurnServerConnection conn(packet.source_address(), iter->second, socket); uint16_t msg_type = GetBE16(packet.payload().data()); @@ -510,7 +498,7 @@ void TurnServer::Send(TurnServerConnection* conn, const ByteBufferWriter& buf) { void TurnServer::DestroyAllocation(TurnServerAllocation* allocation) { // Removing the internal socket if the connection is not udp. AsyncPacketSocket* socket = allocation->conn()->socket(); - auto iter = FindByRawPtr(server_sockets_, socket); + auto iter = server_sockets_.find(socket); // Skip if the socket serving this allocation is UDP, as this will be shared // by all allocations. // Note: We may not find a socket if it's a TCP socket that was closed, and diff --git a/third_party/libwebrtc/p2p/test/turn_server.h b/third_party/libwebrtc/p2p/test/turn_server.h @@ -32,6 +32,7 @@ #include "rtc_base/async_packet_socket.h" #include "rtc_base/byte_buffer.h" #include "rtc_base/ip_address.h" +#include "rtc_base/memory/less_unique_ptr.h" #include "rtc_base/network/received_packet.h" #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" @@ -270,8 +271,8 @@ class TurnServer : public sigslot::has_slots<> { } private: - using ServerSocketMap = - std::map<std::unique_ptr<AsyncPacketSocket>, ProtocolType>; + using ServerSocketMap = std:: + map<std::unique_ptr<AsyncPacketSocket>, ProtocolType, less_unique_ptr>; // All private member functions and variables should have access restricted to // thread_. But compile-time annotations are missing for members access from @@ -350,8 +351,8 @@ class TurnServer : public sigslot::has_slots<> { bool enable_permission_checks_ = true; ServerSocketMap server_sockets_ RTC_GUARDED_BY(thread_); - std::map<std::unique_ptr<Socket>, ServerSocketInfo> server_listen_sockets_ - RTC_GUARDED_BY(thread_); + std::map<std::unique_ptr<Socket>, ServerSocketInfo, less_unique_ptr> + server_listen_sockets_ RTC_GUARDED_BY(thread_); std::unique_ptr<PacketSocketFactory> external_socket_factory_ RTC_GUARDED_BY(thread_); SocketAddress external_addr_ RTC_GUARDED_BY(thread_); diff --git a/third_party/libwebrtc/rtc_base/BUILD.gn b/third_party/libwebrtc/rtc_base/BUILD.gn @@ -1871,6 +1871,7 @@ rtc_library("rtc_base_tests_utils") { "../api/units:timestamp", "memory:always_valid_pointer", "memory:fifo_buffer", + "memory:less_unique_ptr", "network:received_packet", "synchronization:mutex", "third_party/sigslot", diff --git a/third_party/libwebrtc/rtc_base/memory/BUILD.gn b/third_party/libwebrtc/rtc_base/memory/BUILD.gn @@ -43,6 +43,10 @@ rtc_library("fifo_buffer") { ] } +rtc_source_set("less_unique_ptr") { + sources = [ "less_unique_ptr.h" ] +} + rtc_library("unittests") { testonly = true sources = [ diff --git a/third_party/libwebrtc/rtc_base/memory/less_unique_ptr.h b/third_party/libwebrtc/rtc_base/memory/less_unique_ptr.h @@ -0,0 +1,44 @@ +/* + * Copyright 2025 The WebRTC Project Authors. All rights reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef RTC_BASE_MEMORY_LESS_UNIQUE_PTR_H_ +#define RTC_BASE_MEMORY_LESS_UNIQUE_PTR_H_ + +#include <memory> + +namespace webrtc { + +// Helper class that can compare unique_ptr and raw ptr. When used as comparator +// in std::map, std::set with std::unique_ptr<T> as a key, it allows +// heterogeneous lookup by a raw pointer. +struct less_unique_ptr { + // Allow heterogeneous lookup, https://abseil.io/tips/144 + using is_transparent = void; + + template <typename T, typename U> + bool operator()(const std::unique_ptr<T>& lhs, + const std::unique_ptr<U>& rhs) const { + return lhs < rhs; + } + + template <typename T, typename U> + bool operator()(const std::unique_ptr<T>& lhs, const U* rhs) const { + return lhs.get() < rhs; + } + + template <typename T, typename U> + bool operator()(T* lhs, const std::unique_ptr<U>& rhs) const { + return lhs < rhs.get(); + } +}; + +} // namespace webrtc + +#endif // RTC_BASE_MEMORY_LESS_UNIQUE_PTR_H_ diff --git a/third_party/libwebrtc/rtc_base/test_echo_server.cc b/third_party/libwebrtc/rtc_base/test_echo_server.cc @@ -27,11 +27,6 @@ TestEchoServer::TestEchoServer(const Environment& env, server_socket_->SignalReadEvent.connect(this, &TestEchoServer::OnAccept); } -TestEchoServer::~TestEchoServer() { - for (ClientList::iterator it = client_sockets_.begin(); - it != client_sockets_.end(); ++it) { - delete *it; - } -} +TestEchoServer::~TestEchoServer() = default; } // namespace webrtc diff --git a/third_party/libwebrtc/rtc_base/test_echo_server.h b/third_party/libwebrtc/rtc_base/test_echo_server.h @@ -14,15 +14,16 @@ #include <stddef.h> #include <stdint.h> -#include <list> #include <memory> +#include <set> #include <utility> -#include "absl/algorithm/container.h" #include "absl/memory/memory.h" #include "api/environment/environment.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/async_tcp_socket.h" +#include "rtc_base/checks.h" +#include "rtc_base/memory/less_unique_ptr.h" #include "rtc_base/network/received_packet.h" #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" @@ -58,7 +59,7 @@ class TestEchoServer : public sigslot::has_slots<> { }); packet_socket->SubscribeCloseEvent( this, [this](AsyncPacketSocket* s, int err) { OnClose(s, err); }); - client_sockets_.push_back(packet_socket.release()); + client_sockets_.insert(std::move(packet_socket)); } } void OnPacket(AsyncPacketSocket* socket, const ReceivedIpPacket& packet) { @@ -66,17 +67,20 @@ class TestEchoServer : public sigslot::has_slots<> { socket->Send(packet.payload().data(), packet.payload().size(), options); } void OnClose(AsyncPacketSocket* socket, int err) { - ClientList::iterator it = absl::c_find(client_sockets_, socket); - client_sockets_.erase(it); + // Use `find` instead of `extract` directly because `find` allows + // heterogeneous lookup while `extract` requires key (i.e., unique_ptr) as + // the input parameter until c++23. + auto iter = client_sockets_.find(socket); + RTC_CHECK(iter != client_sockets_.end()); // `OnClose` is triggered by socket Close callback, deleting `socket` while // processing that callback might be unsafe. - Thread::Current()->PostTask([socket = absl::WrapUnique(socket)] {}); + auto node = client_sockets_.extract(iter); + Thread::Current()->PostTask([node = std::move(node)] {}); } - typedef std::list<AsyncTCPSocket*> ClientList; const Environment env_; std::unique_ptr<Socket> server_socket_; - ClientList client_sockets_; + std::set<std::unique_ptr<AsyncTCPSocket>, less_unique_ptr> client_sockets_; }; } // namespace webrtc