commit 180ed3aebb002386420d0c005cbf64d229035692
parent 75295210de9821c5cde68c0c3497bff0c72958c6
Author: Dan Baker <dbaker@mozilla.com>
Date: Mon, 27 Oct 2025 14:31:13 -0600
Bug 1995393 - Vendor libwebrtc from be54081491
Upstream commit: https://webrtc.googlesource.com/src/+/be540814919046a580d7ecc05e360e515f517ce9
Remove Connection constructors that do not provide Environment
Make all Connection' data members private per https://google.github.io/styleguide/cppguide.html#Access_Control
Bug: webrtc:42223992
Change-Id: I4c4d44ef6f5e0346c80acb90a796f3592e341bf7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/406220
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45463}
Diffstat:
4 files changed, 50 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-10-27T20:28:59.769238+00:00.
+libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-27T20:31:01.527389+00:00.
# base of lastest vendoring
-4f37653632
+be54081491
diff --git a/third_party/libwebrtc/p2p/base/connection.cc b/third_party/libwebrtc/p2p/base/connection.cc
@@ -227,20 +227,12 @@ int Connection::ConnectionRequest::resend_delay() {
return CONNECTION_RESPONSE_TIMEOUT;
}
-Connection::Connection(const Environment& /*env*/,
+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)
- : network_thread_(port->thread()),
+ : env_(env),
+ network_thread_(port->thread()),
id_(CreateRandomId()),
port_(std::move(port)),
local_candidate_(port_->Candidates()[index]),
@@ -1883,14 +1875,6 @@ 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,
@@ -1900,23 +1884,23 @@ ProxyConnection::ProxyConnection(const Environment& env,
int ProxyConnection::Send(const void* data,
size_t size,
const AsyncSocketPacketOptions& options) {
- RTC_DCHECK(port_) << ToDebugId() << ": port_ null in Send()";
- if (!port_)
+ RTC_DCHECK(port() != nullptr) << ToDebugId() << ": port_ null in Send()";
+ if (port() == nullptr)
return SOCKET_ERROR;
- stats_.sent_total_packets++;
+ mutable_stats().sent_total_packets++;
int sent =
- port_->SendTo(data, size, remote_candidate_.address(), options, true);
+ port()->SendTo(data, size, remote_candidate().address(), options, true);
int64_t now = TimeMillis();
if (sent <= 0) {
RTC_DCHECK(sent < 0);
- error_ = port_->GetError();
- stats_.sent_discarded_packets++;
- stats_.sent_discarded_bytes += size;
+ error_ = port()->GetError();
+ mutable_stats().sent_discarded_packets++;
+ mutable_stats().sent_discarded_bytes += size;
} else {
- send_rate_tracker_.AddSamplesAtTime(now, sent);
+ send_rate_tracker().AddSamplesAtTime(now, sent);
}
- last_send_data_ = now;
+ set_last_send_data(now);
return sent;
}
diff --git a/third_party/libwebrtc/p2p/base/connection.h b/third_party/libwebrtc/p2p/base/connection.h
@@ -372,11 +372,6 @@ 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,
@@ -411,21 +406,10 @@ class RTC_EXPORT Connection : public CandidatePairInterface {
// The local port where this connection sends and receives packets.
PortInterface* port() { return port_.get(); }
- // NOTE: A pointer to the network thread is held by `port_` so in theory we
- // shouldn't need to hold on to this pointer here, but rather defer to
- // port_->thread(). However, some tests delete the classes in the wrong order
- // so `port_` may be deleted before an instance of this class is deleted.
- // TODO(tommi): This ^^^ should be fixed.
- TaskQueueBase* const network_thread_;
- const uint32_t id_;
- WeakPtr<PortInterface> port_;
- Candidate local_candidate_ RTC_GUARDED_BY(network_thread_);
- Candidate remote_candidate_;
-
- ConnectionInfo stats_;
- RateTracker recv_rate_tracker_;
- RateTracker send_rate_tracker_;
- int64_t last_send_data_ = 0;
+ const Environment& env() { return env_; }
+ ConnectionInfo& mutable_stats() { return stats_; }
+ RateTracker& send_rate_tracker() { return send_rate_tracker_; }
+ void set_last_send_data(int64_t now_ms) { last_send_data_ = now_ms; }
private:
// Update the local candidate based on the mapped address attribute.
@@ -444,6 +428,24 @@ class RTC_EXPORT Connection : public CandidatePairInterface {
bool ShouldSendGoogPing(const StunMessage* message)
RTC_RUN_ON(network_thread_);
+ const Environment env_;
+
+ // NOTE: A pointer to the network thread is held by `port_` so in theory we
+ // shouldn't need to hold on to this pointer here, but rather defer to
+ // port_->thread(). However, some tests delete the classes in the wrong order
+ // so `port_` may be deleted before an instance of this class is deleted.
+ // TODO(tommi): This ^^^ should be fixed.
+ TaskQueueBase* const network_thread_;
+ const uint32_t id_;
+ WeakPtr<PortInterface> port_;
+ Candidate local_candidate_ RTC_GUARDED_BY(network_thread_);
+ Candidate remote_candidate_;
+
+ ConnectionInfo stats_;
+ RateTracker recv_rate_tracker_;
+ RateTracker send_rate_tracker_;
+ int64_t last_send_data_ = 0;
+
WriteState write_state_ RTC_GUARDED_BY(network_thread_);
bool receiving_ RTC_GUARDED_BY(network_thread_);
bool connected_ RTC_GUARDED_BY(network_thread_);
@@ -535,11 +537,6 @@ 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,
diff --git a/third_party/libwebrtc/p2p/base/tcp_port.cc b/third_party/libwebrtc/p2p/base/tcp_port.cc
@@ -355,7 +355,7 @@ TCPConnection::TCPConnection(const Environment& env,
connection_pending_(false),
pretending_to_be_writable_(false),
reconnection_timeout_(CONNECTION_WRITE_CONNECT_TIMEOUT) {
- RTC_DCHECK_RUN_ON(network_thread_);
+ RTC_DCHECK_RUN_ON(network_thread());
RTC_DCHECK_EQ(port()->GetProtocol(),
PROTO_TCP); // Needs to be TCPPort.
@@ -370,7 +370,7 @@ TCPConnection::TCPConnection(const Environment& env,
<< socket_->GetLocalAddress().ToSensitiveString()
<< ", port() Network:" << port()->Network()->ToString();
RTC_DCHECK(absl::c_any_of(
- port_->Network()->GetIPs(), [this](const InterfaceAddress& addr) {
+ port()->Network()->GetIPs(), [this](const InterfaceAddress& addr) {
return socket_->GetLocalAddress().ipaddr() == addr;
}));
ConnectSocketSignals(socket);
@@ -378,7 +378,7 @@ TCPConnection::TCPConnection(const Environment& env,
}
TCPConnection::~TCPConnection() {
- RTC_DCHECK_RUN_ON(network_thread_);
+ RTC_DCHECK_RUN_ON(network_thread());
}
int TCPConnection::Send(const void* data,
@@ -405,19 +405,19 @@ int TCPConnection::Send(const void* data,
error_ = ENOTCONN;
return SOCKET_ERROR;
}
- stats_.sent_total_packets++;
+ mutable_stats().sent_total_packets++;
AsyncSocketPacketOptions modified_options(options);
tcp_port()->CopyPortInformationToPacketInfo(
&modified_options.info_signaled_after_sent);
int sent = socket_->Send(data, size, modified_options);
int64_t now = TimeMillis();
if (sent < 0) {
- stats_.sent_discarded_packets++;
+ mutable_stats().sent_discarded_packets++;
error_ = socket_->GetError();
} else {
- send_rate_tracker_.AddSamplesAtTime(now, sent);
+ send_rate_tracker().AddSamplesAtTime(now, sent);
}
- last_send_data_ = now;
+ set_last_send_data(now);
return sent;
}
@@ -451,7 +451,7 @@ void TCPConnection::OnConnectionRequestResponse(StunRequest* req,
void TCPConnection::OnConnect(AsyncPacketSocket* socket) {
RTC_DCHECK_EQ(socket, socket_.get());
- if (!port_) {
+ if (port() == nullptr) {
RTC_LOG(LS_ERROR) << "TCPConnection: Port has been deleted.";
return;
}
@@ -471,7 +471,7 @@ void TCPConnection::OnConnect(AsyncPacketSocket* socket) {
// Note that, aside from minor differences in log statements, this logic is
// identical to that in TurnPort.
const SocketAddress& socket_address = socket->GetLocalAddress();
- if (absl::c_any_of(port_->Network()->GetIPs(),
+ if (absl::c_any_of(port()->Network()->GetIPs(),
[socket_address](const InterfaceAddress& addr) {
return socket_address.ipaddr() == addr;
})) {
@@ -482,21 +482,21 @@ void TCPConnection::OnConnect(AsyncPacketSocket* socket) {
RTC_LOG(LS_WARNING) << "Socket is bound to the address:"
<< socket_address.ipaddr().ToSensitiveString()
<< ", rather than an address associated with network:"
- << port_->Network()->ToString()
+ << port()->Network()->ToString()
<< ". Still allowing it since it's localhost.";
- } else if (IPIsAny(port_->Network()->GetBestIP())) {
+ } else if (IPIsAny(port()->Network()->GetBestIP())) {
RTC_LOG(LS_WARNING)
<< "Socket is bound to the address:"
<< socket_address.ipaddr().ToSensitiveString()
<< ", rather than an address associated with network:"
- << port_->Network()->ToString()
+ << port()->Network()->ToString()
<< ". Still allowing it since it's the 'any' address"
", possibly caused by multiple_routes being disabled.";
} else {
RTC_LOG(LS_WARNING) << "Dropping connection as TCP socket bound to IP "
<< socket_address.ipaddr().ToSensitiveString()
<< ", rather than an address associated with network:"
- << port_->Network()->ToString();
+ << port()->Network()->ToString();
OnClose(socket, 0);
return;
}
@@ -512,7 +512,7 @@ void TCPConnection::OnClose(AsyncPacketSocket* socket, int error) {
RTC_DCHECK_EQ(socket, socket_.get());
RTC_LOG(LS_INFO) << ToString() << ": Connection closed with error " << error;
- if (!port_) {
+ if (port() == nullptr) {
RTC_LOG(LS_ERROR) << "TCPConnection: Port has been deleted.";
return;
}