commit 207aa5c6efc2e5380243dcb00c033bc5bec5aad7
parent 0041ba25c9960ef01820c935fbc46541d5f0e4ae
Author: Dan Baker <dbaker@mozilla.com>
Date: Mon, 1 Dec 2025 17:22:02 -0700
Bug 2000941 - Vendor libwebrtc from 981d111a87
Upstream commit: https://webrtc.googlesource.com/src/+/981d111a875397315b34fa6889809c8862feb60d
Delete AsyncTCPSocket Create factory functions
These functions are only used in tests.
Deleting them moves description how construction may fail from comments
to test assertions.
Bug: None
Change-Id: I9bc162bf18dafb9c9e41ea7c63def12d0a593826
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/408540
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45581}
Diffstat:
7 files changed, 20 insertions(+), 69 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:18:55.996027+00:00.
+libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-12-02T00:21:47.001443+00:00.
# base of lastest vendoring
-5da7303512
+981d111a87
diff --git a/third_party/libwebrtc/p2p/base/async_stun_tcp_socket.cc b/third_party/libwebrtc/p2p/base/async_stun_tcp_socket.cc
@@ -42,18 +42,6 @@ inline bool IsStunMessage(uint16_t msg_type) {
return (msg_type & 0xC000) ? false : true;
}
-// AsyncStunTCPSocket
-// Binds and connects `socket` and creates AsyncTCPSocket for
-// it. Takes ownership of `socket`. Returns NULL if bind() or
-// connect() fail (`socket` is destroyed in that case).
-AsyncStunTCPSocket* AsyncStunTCPSocket::Create(
- Socket* socket,
- const SocketAddress& bind_address,
- const SocketAddress& remote_address) {
- return new AsyncStunTCPSocket(
- AsyncTCPSocketBase::ConnectSocket(socket, bind_address, remote_address));
-}
-
AsyncStunTCPSocket::AsyncStunTCPSocket(Socket* socket)
: AsyncTCPSocketBase(socket, kBufSize) {}
diff --git a/third_party/libwebrtc/p2p/base/async_stun_tcp_socket.h b/third_party/libwebrtc/p2p/base/async_stun_tcp_socket.h
@@ -18,19 +18,11 @@
#include "rtc_base/async_packet_socket.h"
#include "rtc_base/async_tcp_socket.h"
#include "rtc_base/socket.h"
-#include "rtc_base/socket_address.h"
namespace webrtc {
class AsyncStunTCPSocket : public AsyncTCPSocketBase {
public:
- // Binds and connects `socket` and creates AsyncTCPSocket for
- // it. Takes ownership of `socket`. Returns NULL if bind() or
- // connect() fail (`socket` is destroyed in that case).
- static AsyncStunTCPSocket* Create(Socket* socket,
- const SocketAddress& bind_address,
- const SocketAddress& remote_address);
-
explicit AsyncStunTCPSocket(Socket* socket);
AsyncStunTCPSocket(const AsyncStunTCPSocket&) = delete;
diff --git a/third_party/libwebrtc/p2p/base/async_stun_tcp_socket_unittest.cc b/third_party/libwebrtc/p2p/base/async_stun_tcp_socket_unittest.cc
@@ -29,10 +29,13 @@
#include "rtc_base/third_party/sigslot/sigslot.h"
#include "rtc_base/thread.h"
#include "rtc_base/virtual_socket_server.h"
+#include "test/gmock.h"
#include "test/gtest.h"
namespace webrtc {
+using ::testing::NotNull;
+
static unsigned char kStunMessageWithZeroLength[] = {
0x00, 0x01, 0x00, 0x00, // length of 0 (last 2 bytes)
0x21, 0x12, 0xA4, 0x42, '0', '1', '2', '3',
@@ -91,12 +94,14 @@ class AsyncStunTCPSocketTest : public ::testing::Test,
listen_socket_->SignalNewConnection.connect(
this, &AsyncStunTCPSocketTest::OnNewConnection);
- Socket* client = vss_->CreateSocket(kClientAddr.family(), SOCK_STREAM);
- send_socket_.reset(AsyncStunTCPSocket::Create(
- client, kClientAddr, listen_socket_->GetLocalAddress()));
+ std::unique_ptr<Socket> client =
+ absl::WrapUnique(vss_->CreateSocket(kClientAddr.family(), SOCK_STREAM));
+ ASSERT_THAT(client, NotNull());
+ ASSERT_EQ(client->Bind(kClientAddr), 0);
+ ASSERT_EQ(client->Connect(listen_socket_->GetLocalAddress()), 0);
+ send_socket_ = std::make_unique<AsyncStunTCPSocket>(client.release());
send_socket_->SignalSentPacket.connect(
this, &AsyncStunTCPSocketTest::OnSentPacket);
- ASSERT_TRUE(send_socket_.get() != nullptr);
vss_->ProcessMessagesUntilIdle();
}
diff --git a/third_party/libwebrtc/rtc_base/async_tcp_socket.cc b/third_party/libwebrtc/rtc_base/async_tcp_socket.cc
@@ -49,22 +49,6 @@ static const size_t kMinimumRecvSize = 128;
static const int kListenBacklog = 5;
-// Binds and connects `socket`
-Socket* AsyncTCPSocketBase::ConnectSocket(Socket* socket,
- const SocketAddress& bind_address,
- const SocketAddress& remote_address) {
- std::unique_ptr<Socket> owned_socket(socket);
- if (socket->Bind(bind_address) < 0) {
- RTC_LOG(LS_ERROR) << "Bind() failed with error " << socket->GetError();
- return nullptr;
- }
- if (socket->Connect(remote_address) < 0) {
- RTC_LOG(LS_ERROR) << "Connect() failed with error " << socket->GetError();
- return nullptr;
- }
- return owned_socket.release();
-}
-
AsyncTCPSocketBase::AsyncTCPSocketBase(Socket* socket, size_t max_packet_size)
: socket_(socket),
max_insize_(max_packet_size),
@@ -244,17 +228,6 @@ void AsyncTCPSocketBase::OnCloseEvent(Socket* socket, int error) {
NotifyClosed(error);
}
-// AsyncTCPSocket
-// Binds and connects `socket` and creates AsyncTCPSocket for
-// it. Takes ownership of `socket`. Returns null if bind() or
-// connect() fail (`socket` is destroyed in that case).
-AsyncTCPSocket* AsyncTCPSocket::Create(Socket* socket,
- const SocketAddress& bind_address,
- const SocketAddress& remote_address) {
- return new AsyncTCPSocket(
- AsyncTCPSocketBase::ConnectSocket(socket, bind_address, remote_address));
-}
-
AsyncTCPSocket::AsyncTCPSocket(Socket* socket)
: AsyncTCPSocketBase(socket, kBufSize) {}
diff --git a/third_party/libwebrtc/rtc_base/async_tcp_socket.h b/third_party/libwebrtc/rtc_base/async_tcp_socket.h
@@ -57,12 +57,6 @@ class AsyncTCPSocketBase : public AsyncPacketSocket {
void SetError(int error) override;
protected:
- // Binds and connects `socket` and creates AsyncTCPSocket for
- // it. Takes ownership of `socket`. Returns null if bind() or
- // connect() fail (`socket` is destroyed in that case).
- static Socket* ConnectSocket(Socket* socket,
- const SocketAddress& bind_address,
- const SocketAddress& remote_address);
int FlushOutBuffer();
// Add data to `outbuf_`.
void AppendToOutBuffer(const void* pv, size_t cb);
@@ -87,12 +81,6 @@ class AsyncTCPSocketBase : public AsyncPacketSocket {
class AsyncTCPSocket : public AsyncTCPSocketBase {
public:
- // Binds and connects `socket` and creates AsyncTCPSocket for
- // it. Takes ownership of `socket`. Returns null if bind() or
- // connect() fail (`socket` is destroyed in that case).
- static AsyncTCPSocket* Create(Socket* socket,
- const SocketAddress& bind_address,
- const SocketAddress& remote_address);
explicit AsyncTCPSocket(Socket* socket);
~AsyncTCPSocket() override {}
diff --git a/third_party/libwebrtc/rtc_base/test_client_unittest.cc b/third_party/libwebrtc/rtc_base/test_client_unittest.cc
@@ -23,6 +23,7 @@
#include "rtc_base/socket_address.h"
#include "rtc_base/test_echo_server.h"
#include "rtc_base/thread.h"
+#include "test/gmock.h"
#include "test/gtest.h"
#define MAYBE_SKIP_IPV4 \
@@ -40,6 +41,8 @@
namespace webrtc {
namespace {
+using ::testing::NotNull;
+
void TestUdpInternal(const SocketAddress& loopback) {
PhysicalSocketServer socket_server;
AutoSocketServerThread main_thread(&socket_server);
@@ -59,10 +62,12 @@ void TestTcpInternal(const SocketAddress& loopback) {
AutoSocketServerThread main_thread(&socket_server);
TestEchoServer server(&main_thread, loopback);
- Socket* socket = socket_server.CreateSocket(loopback.family(), SOCK_STREAM);
- std::unique_ptr<AsyncTCPSocket> tcp_socket = absl::WrapUnique(
- AsyncTCPSocket::Create(socket, loopback, server.address()));
- ASSERT_TRUE(tcp_socket != nullptr);
+ std::unique_ptr<Socket> socket = absl::WrapUnique(
+ socket_server.CreateSocket(loopback.family(), SOCK_STREAM));
+ ASSERT_THAT(socket, NotNull());
+ ASSERT_EQ(socket->Bind(loopback), 0);
+ ASSERT_EQ(socket->Connect(server.address()), 0);
+ auto tcp_socket = std::make_unique<AsyncTCPSocket>(socket.release());
TestClient client(std::move(tcp_socket));
SocketAddress addr = client.address(), from;