Make Port signals private
Drive-by: Move a WeakFactory last, where it needs to be.
Bug: webrtc:42222066
Change-Id: I68a8382641cad7fc52a73f71be68235de01c618d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/417940
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45983}
diff --git a/p2p/base/port.cc b/p2p/base/port.cc
index 56cf83f..1b2d53c 100644
--- a/p2p/base/port.cc
+++ b/p2p/base/port.cc
@@ -109,10 +109,10 @@
shared_socket_(shared_socket),
network_cost_(args.network->GetCost(env_.field_trials())),
role_conflict_callback_(nullptr),
- weak_factory_(this),
unknown_address_trampoline_(this),
read_packet_trampoline_(this),
- sent_packet_trampoline_(this) {
+ sent_packet_trampoline_(this),
+ weak_factory_(this) {
RTC_DCHECK_RUN_ON(thread_);
RTC_DCHECK(factory_ != nullptr);
// TODO(pthatcher): Remove this old behavior once we're sure no one
diff --git a/p2p/base/port.h b/p2p/base/port.h
index 218091a..165c40e 100644
--- a/p2p/base/port.h
+++ b/p2p/base/port.h
@@ -264,13 +264,9 @@
// are discovered that belong to port SignalAddressReady is fired.
void SubscribeCandidateReadyCallback(
absl::AnyInvocable<void(Port*, const Candidate&)> callback);
- // Downstream code uses this signal. We will continue firing it along with the
- // callback list. The signal can be deleted once all downstream usages are
- // replaced with the new CallbackList implementation.
void NotifyCandidateReady(Port* port, const Candidate& candidate) {
SignalCandidateReady(port, candidate);
}
- sigslot::signal2<Port*, const Candidate&> SignalCandidateReady;
// Provides all of the above information in one handy object.
const std::vector<Candidate>& Candidates() const override;
// Fired when candidate discovery failed using certain server.
@@ -282,7 +278,6 @@
// allocation.
void SubscribePortComplete(absl::AnyInvocable<void(Port*)> callback);
void NotifyPortComplete(Port* port) { SignalPortComplete(port); }
- sigslot::signal1<Port*> SignalPortComplete;
// This signal sent when port fails to allocate candidates and this port
// can't be used in establishing the connections. When port is in shared mode
@@ -291,10 +286,6 @@
// connection.
void SubscribePortError(absl::AnyInvocable<void(Port*)> callback);
void NotifyPortError(Port* port) { SignalPortError(port); }
- // Downstream code uses this signal. We will continue firing it along with the
- // callback list. The signal can be deleted once all downstream usages are
- // replaced with the new CallbackList implementation.
- sigslot::signal1<Port*> SignalPortError;
void SubscribePortDestroyed(
std::function<void(PortInterface*)> callback) override;
@@ -603,8 +594,19 @@
absl::AnyInvocable<void()> role_conflict_callback_ RTC_GUARDED_BY(thread_);
- // Keep as the last member variable.
- WeakPtrFactory<Port> weak_factory_ RTC_GUARDED_BY(thread_);
+ // Signals and trampolines. These will eventually be removed and replaced
+ // with straight CallbackLists (or simple callbacks).
+ // TODO: https://issues.webrtc.org/42222066 - replace and delete.
+
+ // Downstream code uses this signal. We will continue firing it along with the
+ // callback list. The signal can be deleted once all downstream usages are
+ // replaced with the new CallbackList implementation.
+ sigslot::signal2<Port*, const Candidate&> SignalCandidateReady;
+ sigslot::signal1<Port*> SignalPortComplete;
+ // Downstream code uses this signal. We will continue firing it along with the
+ // callback list. The signal can be deleted once all downstream usages are
+ // replaced with the new CallbackList implementation.
+ sigslot::signal1<Port*> SignalPortError;
SignalTrampoline<PortInterface, &PortInterface::SignalUnknownAddress>
unknown_address_trampoline_;
@@ -612,6 +614,9 @@
read_packet_trampoline_;
SignalTrampoline<PortInterface, &PortInterface::SignalSentPacket>
sent_packet_trampoline_;
+
+ // Keep as the last member variable.
+ WeakPtrFactory<Port> weak_factory_ RTC_GUARDED_BY(thread_);
};
} // namespace webrtc
diff --git a/p2p/base/stun_port.cc b/p2p/base/stun_port.cc
index 7613e86..a3122b2 100644
--- a/p2p/base/stun_port.cc
+++ b/p2p/base/stun_port.cc
@@ -613,9 +613,9 @@
// request succeeded for any stun server, or the socket is shared.
if (server_addresses_.empty() || !bind_request_succeeded_servers_.empty() ||
SharedSocket()) {
- SignalPortComplete(this);
+ NotifyPortComplete(this);
} else {
- SignalPortError(this);
+ NotifyPortError(this);
}
}
diff --git a/p2p/base/turn_port.cc b/p2p/base/turn_port.cc
index b43fe45..8db1818 100644
--- a/p2p/base/turn_port.cc
+++ b/p2p/base/turn_port.cc
@@ -52,7 +52,6 @@
#include "rtc_base/network.h"
#include "rtc_base/network/received_packet.h"
#include "rtc_base/network/sent_packet.h"
-#include "rtc_base/platform_thread_types.h"
#include "rtc_base/socket.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/ssl_certificate.h"
@@ -932,7 +931,7 @@
// port initialization. This way it will not be blocking other port
// creation.
thread()->PostTask(
- SafeTask(task_safety_.flag(), [this] { SignalPortError(this); }));
+ SafeTask(task_safety_.flag(), [this] { NotifyPortError(this); }));
std::string address = GetLocalAddress().HostAsSensitiveURIString();
int port = GetLocalAddress().port();
if (server_address_.proto == PROTO_TCP &&
diff --git a/p2p/client/basic_port_allocator.cc b/p2p/client/basic_port_allocator.cc
index feb77df..a2c8762 100644
--- a/p2p/client/basic_port_allocator.cc
+++ b/p2p/client/basic_port_allocator.cc
@@ -46,10 +46,10 @@
#include "rtc_base/ip_address.h"
#include "rtc_base/logging.h"
#include "rtc_base/net_helper.h"
+#include "rtc_base/net_helpers.h"
#include "rtc_base/network.h"
#include "rtc_base/network/received_packet.h"
#include "rtc_base/network_constants.h"
-#include "rtc_base/platform_thread_types.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/thread.h"
@@ -338,7 +338,7 @@
found_signalable_candidate = true;
port_data.set_state(PortData::STATE_INPROGRESS);
}
- port->SignalCandidateReady(port, c);
+ port->NotifyCandidateReady(port, c);
}
if (CandidatePairable(c, port)) {