Rename [Un]SubscribeClose event subscription methods for clarity.

This is following up on a discussion here:
https://webrtc-review.googlesource.com/c/src/+/318061

Bug: none
Change-Id: Idb572ca6d0aad8d791eb6ba80dc0f48292f9f244
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/318883
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40698}
This commit is contained in:
Tommi 2023-09-05 09:36:24 +02:00 committed by WebRTC LUCI CQ
parent 85c05a8a17
commit 2afd284016
6 changed files with 20 additions and 19 deletions

View file

@ -625,8 +625,8 @@ void TCPConnection::ConnectSocketSignals(rtc::AsyncPacketSocket* socket) {
}
socket->SignalReadPacket.connect(this, &TCPConnection::OnReadPacket);
socket->SignalReadyToSend.connect(this, &TCPConnection::OnReadyToSend);
socket->SubscribeClose(this, [this, safety = network_safety_.flag()](
rtc::AsyncPacketSocket* s, int err) {
socket->SubscribeCloseEvent(this, [this, safety = network_safety_.flag()](
rtc::AsyncPacketSocket* s, int err) {
if (safety->alive())
OnClose(s, err);
});
@ -638,7 +638,7 @@ void TCPConnection::DisconnectSocketSignals(rtc::AsyncPacketSocket* socket) {
}
socket->SignalReadPacket.disconnect(this);
socket->SignalReadyToSend.disconnect(this);
socket->UnsubscribeClose(this);
socket->UnsubscribeCloseEvent(this);
}
} // namespace cricket

View file

@ -299,7 +299,7 @@ TurnPort::~TurnPort() {
entries_.clear();
if (socket_)
socket_->UnsubscribeClose(this);
socket_->UnsubscribeCloseEvent(this);
if (!SharedSocket()) {
delete socket_;
@ -447,9 +447,9 @@ bool TurnPort::CreateTurnClientSocket() {
if (server_address_.proto == PROTO_TCP ||
server_address_.proto == PROTO_TLS) {
socket_->SignalConnect.connect(this, &TurnPort::OnSocketConnect);
socket_->SubscribeClose(this, [this](rtc::AsyncPacketSocket* s, int err) {
OnSocketClose(s, err);
});
socket_->SubscribeCloseEvent(
this,
[this](rtc::AsyncPacketSocket* s, int err) { OnSocketClose(s, err); });
} else {
state_ = STATE_CONNECTED;
}
@ -541,7 +541,7 @@ void TurnPort::OnAllocateMismatch() {
"STUN_ERROR_ALLOCATION_MISMATCH, retry: "
<< allocate_mismatch_retries_ + 1;
socket_->UnsubscribeClose(this);
socket_->UnsubscribeCloseEvent(this);
if (SharedSocket()) {
ResetSharedSocket();

View file

@ -147,10 +147,10 @@ void TurnServer::AcceptConnection(rtc::Socket* server_socket) {
cricket::AsyncStunTCPSocket* tcp_socket =
new cricket::AsyncStunTCPSocket(accepted_socket);
tcp_socket->SubscribeClose(this,
[this](rtc::AsyncPacketSocket* s, int err) {
OnInternalSocketClose(s, err);
});
tcp_socket->SubscribeCloseEvent(this,
[this](rtc::AsyncPacketSocket* s, int err) {
OnInternalSocketClose(s, err);
});
// Finally add the socket so it can start communicating with the client.
AddInternalSocket(tcp_socket, info.proto);
}
@ -515,7 +515,7 @@ void TurnServer::DestroyInternalSocket(rtc::AsyncPacketSocket* socket) {
InternalSocketMap::iterator iter = server_sockets_.find(socket);
if (iter != server_sockets_.end()) {
rtc::AsyncPacketSocket* socket = iter->first;
socket->UnsubscribeClose(this);
socket->UnsubscribeCloseEvent(this);
socket->SignalReadPacket.disconnect(this);
server_sockets_.erase(iter);
std::unique_ptr<rtc::AsyncPacketSocket> socket_to_delete =

View file

@ -26,14 +26,14 @@ PacketOptions::~PacketOptions() = default;
AsyncPacketSocket::~AsyncPacketSocket() = default;
void AsyncPacketSocket::SubscribeClose(
void AsyncPacketSocket::SubscribeCloseEvent(
const void* removal_tag,
std::function<void(AsyncPacketSocket*, int)> callback) {
RTC_DCHECK_RUN_ON(&network_checker_);
on_close_.AddReceiver(removal_tag, std::move(callback));
}
void AsyncPacketSocket::UnsubscribeClose(const void* removal_tag) {
void AsyncPacketSocket::UnsubscribeCloseEvent(const void* removal_tag) {
RTC_DCHECK_RUN_ON(&network_checker_);
on_close_.RemoveReceivers(removal_tag);
}

View file

@ -110,9 +110,10 @@ class RTC_EXPORT AsyncPacketSocket : public sigslot::has_slots<> {
virtual void SetError(int error) = 0;
// Register a callback to be called when the socket is closed.
void SubscribeClose(const void* removal_tag,
std::function<void(AsyncPacketSocket*, int)> callback);
void UnsubscribeClose(const void* removal_tag);
void SubscribeCloseEvent(
const void* removal_tag,
std::function<void(AsyncPacketSocket*, int)> callback);
void UnsubscribeCloseEvent(const void* removal_tag);
// Emitted each time a packet is read. Used only for UDP and
// connected TCP sockets.

View file

@ -46,7 +46,7 @@ class TestEchoServer : public sigslot::has_slots<> {
if (raw_socket) {
AsyncTCPSocket* packet_socket = new AsyncTCPSocket(raw_socket);
packet_socket->SignalReadPacket.connect(this, &TestEchoServer::OnPacket);
packet_socket->SubscribeClose(
packet_socket->SubscribeCloseEvent(
this, [this](AsyncPacketSocket* s, int err) { OnClose(s, err); });
client_sockets_.push_back(packet_socket);
}