From 336ff921765f2799209b8ff59f736bcde3bc4e62 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Mon, 24 Nov 2025 21:58:55 +0000 Subject: [PATCH] Remove all sigslot references from libwebrtc Also change its visibility rules so that it cannot be reintroduced, but is still visible to downstream users. Bug: webrtc:42222066 Change-Id: I3235e84785eb4535696e9e6c8cfc24965b02c75d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/427560 Reviewed-by: Tomas Gunnarsson Commit-Queue: Harald Alvestrand Cr-Commit-Position: refs/heads/main@{#46303} --- BUILD.gn | 1 - examples/BUILD.gn | 1 - media/BUILD.gn | 2 - p2p/BUILD.gn | 4 - p2p/base/p2p_transport_channel_unittest.cc | 4 +- p2p/base/stun_port_unittest.cc | 3 +- p2p/base/tcp_port.h | 4 +- p2p/base/turn_port.cc | 5 +- p2p/base/turn_port_unittest.cc | 5 +- p2p/client/basic_port_allocator_unittest.cc | 4 +- p2p/dtls/dtls_ice_integrationtest.cc | 4 +- p2p/test/nat_socket_factory.cc | 3 +- pc/BUILD.gn | 1 - pc/datagram_connection_unittest.cc | 6 +- pc/jsep_transport_controller_unittest.cc | 4 +- rtc_base/BUILD.gn | 26 --- rtc_base/async_tcp_socket_unittest.cc | 3 +- rtc_base/network_unittest.cc | 3 +- rtc_base/openssl_adapter_unittest.cc | 1 - rtc_base/physical_socket_server.h | 3 +- rtc_base/sigslot_trampoline.h | 173 -------------------- rtc_base/sigslot_trampoline_unittest.cc | 93 ----------- rtc_base/ssl_adapter_unittest.cc | 7 +- rtc_base/ssl_stream_adapter_unittest.cc | 4 +- rtc_base/test_client.h | 5 +- rtc_base/third_party/sigslot/BUILD.gn | 13 +- test/network/BUILD.gn | 1 - test/peer_scenario/BUILD.gn | 1 - test/peer_scenario/scenario_connection.cc | 2 - 29 files changed, 34 insertions(+), 352 deletions(-) delete mode 100644 rtc_base/sigslot_trampoline.h delete mode 100644 rtc_base/sigslot_trampoline_unittest.cc diff --git a/BUILD.gn b/BUILD.gn index 5bbc5b79a2..9b17a0b627 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -665,7 +665,6 @@ if (rtc_include_tests && !build_with_chromium) { "rtc_base:rtc_numerics_unittests", "rtc_base:rtc_operations_chain_unittests", "rtc_base:rtc_task_queue_unittests", - "rtc_base:sigslot_trampoline_unittest", "rtc_base:sigslot_unittest", "rtc_base:task_queue_stdlib_unittest", "rtc_base:untyped_function_unittest", diff --git a/examples/BUILD.gn b/examples/BUILD.gn index 02f2592521..915d8c2fd5 100644 --- a/examples/BUILD.gn +++ b/examples/BUILD.gn @@ -721,7 +721,6 @@ if (is_linux || is_chromeos || is_win) { "../rtc_base:ssl_adapter", "../rtc_base:stringutils", "../rtc_base:threading", - "../rtc_base/third_party/sigslot", "../system_wrappers", "../test:frame_generator_capturer", "../test:platform_video_capturer", diff --git a/media/BUILD.gn b/media/BUILD.gn index d8e6464ddb..212f11de9e 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -125,7 +125,6 @@ rtc_library("rtc_media_base") { "../rtc_base/system:file_wrapper", "../rtc_base/system:no_unique_address", "../rtc_base/system:rtc_export", - "../rtc_base/third_party/sigslot", "../video/config:encoder_config", "//third_party/abseil-cpp/absl/base:core_headers", ] @@ -885,7 +884,6 @@ if (rtc_include_tests) { "../rtc_base/network:sent_packet", "../rtc_base/synchronization:mutex", "../rtc_base/system:file_wrapper", - "../rtc_base/third_party/sigslot", "../test:create_test_field_trials", "../test:test_support", "../video/config:encoder_config", diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn index adc2c36e5e..1fc84313b7 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -827,7 +827,6 @@ rtc_library("tcp_port") { "../rtc_base/containers:flat_map", "../rtc_base/network:received_packet", "../rtc_base/network:sent_packet", - "../rtc_base/third_party/sigslot", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings:string_view", @@ -919,7 +918,6 @@ rtc_library("turn_port") { "../rtc_base:stringutils", "../rtc_base/network:received_packet", "../rtc_base/network:sent_packet", - "../rtc_base/third_party/sigslot", "../system_wrappers:metrics", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/memory", @@ -1150,7 +1148,6 @@ if (rtc_include_tests) { "../rtc_base/network:received_packet", "../rtc_base/network:sent_packet", "../rtc_base/synchronization:mutex", - "../rtc_base/third_party/sigslot", "../test:test_support", "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/memory", @@ -1291,7 +1288,6 @@ if (rtc_include_tests) { "../rtc_base:timeutils", "../rtc_base/network:received_packet", "../rtc_base/network:sent_packet", - "../rtc_base/third_party/sigslot", "../system_wrappers:metrics", "../test:create_test_environment", "../test:create_test_field_trials", diff --git a/p2p/base/p2p_transport_channel_unittest.cc b/p2p/base/p2p_transport_channel_unittest.cc index b9d3a55496..b38e4eaffb 100644 --- a/p2p/base/p2p_transport_channel_unittest.cc +++ b/p2p/base/p2p_transport_channel_unittest.cc @@ -91,7 +91,6 @@ #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" #include "rtc_base/socket_server.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/time_utils.h" #include "rtc_base/virtual_socket_server.h" @@ -3589,8 +3588,7 @@ TEST_F(P2PTransportChannelMultihomedTest, StunDictionaryPerformsSync) { // A collection of tests which tests a single P2PTransportChannel by sending // pings. -class P2PTransportChannelPingTest : public ::testing::Test, - public sigslot::has_slots<> { +class P2PTransportChannelPingTest : public ::testing::Test { public: P2PTransportChannelPingTest() : vss_(std::make_unique()), diff --git a/p2p/base/stun_port_unittest.cc b/p2p/base/stun_port_unittest.cc index d318fdad58..4d7c2b18fa 100644 --- a/p2p/base/stun_port_unittest.cc +++ b/p2p/base/stun_port_unittest.cc @@ -55,7 +55,6 @@ #include "rtc_base/socket_address.h" #include "rtc_base/socket_factory.h" #include "rtc_base/socket_server.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" #include "system_wrappers/include/metrics.h" @@ -139,7 +138,7 @@ class FakeMdnsResponderProvider : public webrtc::MdnsResponderProvider { // Base class for tests connecting a StunPort to a fake STUN server // (webrtc::StunServer). -class StunPortTestBase : public ::testing::Test, public sigslot::has_slots<> { +class StunPortTestBase : public ::testing::Test { public: StunPortTestBase() : StunPortTestBase(kPrivateIP.ipaddr(), diff --git a/p2p/base/tcp_port.h b/p2p/base/tcp_port.h index 9adc6b45ea..130e2490c7 100644 --- a/p2p/base/tcp_port.h +++ b/p2p/base/tcp_port.h @@ -30,11 +30,11 @@ #include "rtc_base/async_packet_socket.h" #include "rtc_base/checks.h" #include "rtc_base/containers/flat_map.h" +#include "rtc_base/net_helper.h" #include "rtc_base/network/received_packet.h" #include "rtc_base/network/sent_packet.h" #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/weak_ptr.h" namespace webrtc { @@ -124,7 +124,7 @@ class TCPPort : public Port { friend class TCPConnection; }; -class TCPConnection : public Connection, public sigslot::has_slots<> { +class TCPConnection : public Connection { public: // Connection is outgoing unless socket is specified TCPConnection(const Environment& env, diff --git a/p2p/base/turn_port.cc b/p2p/base/turn_port.cc index e8838b21ac..2b78a7ff1c 100644 --- a/p2p/base/turn_port.cc +++ b/p2p/base/turn_port.cc @@ -56,7 +56,6 @@ #include "rtc_base/ssl_certificate.h" #include "rtc_base/string_encode.h" #include "rtc_base/strings/string_builder.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "system_wrappers/include/metrics.h" namespace webrtc { @@ -166,11 +165,11 @@ class TurnChannelBindRequest : public StunRequest { // Manages a "connection" to a remote destination. We will attempt to bring up // a channel for this remote destination to reduce the overhead of sending data. -class TurnEntry : public sigslot::has_slots<> { +class TurnEntry { public: enum BindState { STATE_UNBOUND, STATE_BINDING, STATE_BOUND }; TurnEntry(TurnPort* port, Connection* conn, int channel_id); - ~TurnEntry() override; + ~TurnEntry(); TurnPort* port() { return port_; } diff --git a/p2p/base/turn_port_unittest.cc b/p2p/base/turn_port_unittest.cc index 65c6fd2b1d..81a7c55a31 100644 --- a/p2p/base/turn_port_unittest.cc +++ b/p2p/base/turn_port_unittest.cc @@ -59,7 +59,6 @@ #include "rtc_base/network/received_packet.h" #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" #include "system_wrappers/include/metrics.h" @@ -211,9 +210,7 @@ class TestConnectionWrapper { // Note: This test uses a fake clock with a simulated network round trip // (between local port and TURN server) of kSimulatedRtt. -class TurnPortTest : public ::testing::Test, - public TurnPort::CallbacksForTest, - public sigslot::has_slots<> { +class TurnPortTest : public ::testing::Test, public TurnPort::CallbacksForTest { public: TurnPortTest() : ss_(new TurnPortTestVirtualSocketServer()), diff --git a/p2p/client/basic_port_allocator_unittest.cc b/p2p/client/basic_port_allocator_unittest.cc index 5969fd2c05..6f76a4a244 100644 --- a/p2p/client/basic_port_allocator_unittest.cc +++ b/p2p/client/basic_port_allocator_unittest.cc @@ -53,7 +53,6 @@ #include "rtc_base/network_constants.h" #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" #include "system_wrappers/include/metrics.h" @@ -154,8 +153,7 @@ void CheckStunKeepaliveIntervalOfAllReadyPorts( namespace webrtc { -class BasicPortAllocatorTestBase : public ::testing::Test, - public sigslot::has_slots<> { +class BasicPortAllocatorTestBase : public ::testing::Test { public: BasicPortAllocatorTestBase() : vss_(new VirtualSocketServer()), diff --git a/p2p/dtls/dtls_ice_integrationtest.cc b/p2p/dtls/dtls_ice_integrationtest.cc index 2228d5be18..5b97f4cd80 100644 --- a/p2p/dtls/dtls_ice_integrationtest.cc +++ b/p2p/dtls/dtls_ice_integrationtest.cc @@ -50,7 +50,6 @@ #include "rtc_base/ssl_fingerprint.h" #include "rtc_base/ssl_identity.h" #include "rtc_base/ssl_stream_adapter.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" #include "test/create_test_field_trials.h" @@ -79,8 +78,7 @@ class DtlsIceIntegrationTest : public ::testing::TestWithParam>, - public sigslot::has_slots<> { + /* 5 server_pqc= */ bool>> { public: void CandidateC2S(IceTransportInternal*, const Candidate& c) { server_thread()->PostTask( diff --git a/p2p/test/nat_socket_factory.cc b/p2p/test/nat_socket_factory.cc index c45168c035..f7f24e7cc6 100644 --- a/p2p/test/nat_socket_factory.cc +++ b/p2p/test/nat_socket_factory.cc @@ -32,7 +32,6 @@ #include "rtc_base/socket_address.h" #include "rtc_base/socket_factory.h" #include "rtc_base/socket_server.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" @@ -88,7 +87,7 @@ size_t UnpackAddressFromNAT(ArrayView buf, } // NATSocket -class NATSocket : public Socket, public sigslot::has_slots<> { +class NATSocket : public Socket { public: explicit NATSocket(NATInternalSocketFactory* sf, int family, int type) : sf_(sf), diff --git a/pc/BUILD.gn b/pc/BUILD.gn index dbfe7520a1..b97f8b54ff 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -2299,7 +2299,6 @@ if (rtc_include_tests && !build_with_chromium) { "../rtc_base/containers:flat_set", "../rtc_base/network:received_packet", "../rtc_base/network:sent_packet", - "../rtc_base/third_party/sigslot", "../system_wrappers:metrics", "../test:create_test_environment", "../test:create_test_field_trials", diff --git a/pc/datagram_connection_unittest.cc b/pc/datagram_connection_unittest.cc index 6a7de66264..4d60d3f2f0 100644 --- a/pc/datagram_connection_unittest.cc +++ b/pc/datagram_connection_unittest.cc @@ -40,7 +40,6 @@ #include "rtc_base/rtc_certificate.h" #include "rtc_base/socket_address.h" #include "rtc_base/ssl_fingerprint.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "test/gmock.h" #include "test/gtest.h" @@ -64,12 +63,11 @@ bool IsRtpOrRtcpPacket(uint8_t first_byte) { return (first_byte & 0xc0) == 0x80; } -class DatagramConnectionTest : public ::testing::Test, - public sigslot::has_slots<> { +class DatagramConnectionTest : public ::testing::Test { public: DatagramConnectionTest() : env_(CreateEnvironment()) {} - ~DatagramConnectionTest() override { + ~DatagramConnectionTest() { conn1_->Terminate([] {}); conn2_->Terminate([] {}); } diff --git a/pc/jsep_transport_controller_unittest.cc b/pc/jsep_transport_controller_unittest.cc index 4422916334..5b639911c5 100644 --- a/pc/jsep_transport_controller_unittest.cc +++ b/pc/jsep_transport_controller_unittest.cc @@ -64,7 +64,6 @@ #include "rtc_base/ssl_identity.h" #include "rtc_base/ssl_stream_adapter.h" #include "rtc_base/task_queue_for_test.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "system_wrappers/include/metrics.h" #include "test/create_test_field_trials.h" @@ -117,8 +116,7 @@ class FakeDtlsTransportFactory : public DtlsTransportFactory { }; class JsepTransportControllerTest : public JsepTransportController::Observer, - public ::testing::Test, - public sigslot::has_slots<> { + public ::testing::Test { public: JsepTransportControllerTest() : env_(CreateEnvironment(&field_trials_)), diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index e4c9a4411c..8183b1fff5 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -1029,7 +1029,6 @@ rtc_library("threading") { "synchronization:mutex", "system:no_unique_address", "system:rtc_export", - "third_party/sigslot", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/cleanup", @@ -1254,26 +1253,6 @@ rtc_library("network") { } } -rtc_source_set("sigslot_trampoline") { - sources = [ "sigslot_trampoline.h" ] - deps = [ - ":callback_list", - "third_party/sigslot", - "//third_party/abseil-cpp/absl/functional:any_invocable", - ] -} - -rtc_library("sigslot_trampoline_unittest") { - testonly = true - sources = [ "sigslot_trampoline_unittest.cc" ] - deps = [ - ":sigslot_trampoline", - "../test:test_support", - "third_party/sigslot", - "//third_party/abseil-cpp/absl/functional:any_invocable", - ] -} - rtc_library("socket_address_pair") { sources = [ "socket_address_pair.cc", @@ -1450,7 +1429,6 @@ if (rtc_include_tests) { ":socket", "../test:create_test_environment", "../test:test_support", - "third_party/sigslot", ] } } @@ -1773,7 +1751,6 @@ rtc_library("testclient") { "../test:wait_until", "network:received_packet", "synchronization:mutex", - "third_party/sigslot", ] } @@ -1838,7 +1815,6 @@ rtc_library("rtc_base_tests_utils") { ":network", ":network_constants", ":rtc_event", - ":sigslot_trampoline", ":socket", ":socket_adapters", ":socket_address", @@ -1866,7 +1842,6 @@ rtc_library("rtc_base_tests_utils") { "memory:less_unique_ptr", "network:received_packet", "synchronization:mutex", - "third_party/sigslot", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/base:core_headers", "//third_party/abseil-cpp/absl/functional:any_invocable", @@ -2384,7 +2359,6 @@ if (rtc_include_tests) { "memory:fifo_buffer", "network:received_packet", "synchronization:mutex", - "third_party/sigslot", "//testing/gtest", "//third_party/abseil-cpp/absl/algorithm:container", "//third_party/abseil-cpp/absl/functional:any_invocable", diff --git a/rtc_base/async_tcp_socket_unittest.cc b/rtc_base/async_tcp_socket_unittest.cc index 97f513258c..69a61a0eff 100644 --- a/rtc_base/async_tcp_socket_unittest.cc +++ b/rtc_base/async_tcp_socket_unittest.cc @@ -16,7 +16,6 @@ #include "rtc_base/async_packet_socket.h" #include "rtc_base/net_helpers.h" #include "rtc_base/socket.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/virtual_socket_server.h" #include "test/create_test_environment.h" #include "test/gmock.h" @@ -27,7 +26,7 @@ namespace { using ::testing::NotNull; -struct AsyncTCPSocketObserver : public sigslot::has_slots<> { +struct AsyncTCPSocketObserver { void OnReadyToSend(AsyncPacketSocket* socket) { ready_to_send = true; } bool ready_to_send = false; diff --git a/rtc_base/network_unittest.cc b/rtc_base/network_unittest.cc index ebb17c1251..9075353cab 100644 --- a/rtc_base/network_unittest.cc +++ b/rtc_base/network_unittest.cc @@ -37,7 +37,6 @@ #include "rtc_base/network_monitor_factory.h" #include "rtc_base/physical_socket_server.h" #include "rtc_base/socket_address.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "test/create_test_field_trials.h" #include "test/gmock.h" @@ -166,7 +165,7 @@ std::vector CopyNetworkPointers( } // namespace -class NetworkTest : public ::testing::Test, public sigslot::has_slots<> { +class NetworkTest : public ::testing::Test { public: void OnNetworksChanged() { callback_called_ = true; } diff --git a/rtc_base/openssl_adapter_unittest.cc b/rtc_base/openssl_adapter_unittest.cc index 3808a0d57c..7f64cbfaa2 100644 --- a/rtc_base/openssl_adapter_unittest.cc +++ b/rtc_base/openssl_adapter_unittest.cc @@ -27,7 +27,6 @@ #include "rtc_base/socket_address.h" #include "rtc_base/ssl_certificate.h" #include "rtc_base/ssl_stream_adapter.h" // IWYU pragma: keep -#include "rtc_base/third_party/sigslot/sigslot.h" // IWYU pragma: keep #include "rtc_base/thread.h" #include "test/gmock.h" #include "test/gtest.h" diff --git a/rtc_base/physical_socket_server.h b/rtc_base/physical_socket_server.h index d50f9b07ae..0fb410b284 100644 --- a/rtc_base/physical_socket_server.h +++ b/rtc_base/physical_socket_server.h @@ -20,7 +20,6 @@ #include "rtc_base/net_helpers.h" #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #if defined(WEBRTC_POSIX) #if defined(WEBRTC_LINUX) @@ -162,7 +161,7 @@ class RTC_EXPORT PhysicalSocketServer : public SocketServer { bool waiting_ = false; }; -class PhysicalSocket : public Socket, public sigslot::has_slots<> { +class PhysicalSocket : public Socket { public: PhysicalSocket(PhysicalSocketServer* ss, SOCKET s = INVALID_SOCKET); ~PhysicalSocket() override; diff --git a/rtc_base/sigslot_trampoline.h b/rtc_base/sigslot_trampoline.h deleted file mode 100644 index f99e14c602..0000000000 --- a/rtc_base/sigslot_trampoline.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * 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_SIGSLOT_TRAMPOLINE_H_ -#define RTC_BASE_SIGSLOT_TRAMPOLINE_H_ - -#include - -#include "absl/functional/any_invocable.h" -#include "rtc_base/callback_list.h" -#include "rtc_base/third_party/sigslot/sigslot.h" - -namespace webrtc { -// A template to simplify the replacement of sigslot::Signal with a -// CallbackList. - -// THIS IS A TEMPORARY OBJECT: -// Once all callers have converted to Subscribe* and Notify*, the signal -// and the trampoline can be replaced with a CallbackList, or, for the case -// where only one listener can ever exist, a simple callback. - -// Usage, for class MyClass and signal SignalMyNamedEvent: -// class MyClass { -// MyClass() -// : my_named_event_trampoline_(this) {} -// // existing: -// sigslot::signal0<> SignalMyNamedEvent; -// // new, this is what we want callers to use instead -// void NotifyMyNamedEvent() { SignalMyNamedEvent(); } -// void SubscribeMyNamedEvent(absl::AnyInvocable callback) { -// my_named_event_trampoline_.Subscribe(std::move(callback)); -// } -// private: -// SignalTrampoline -// my_named_event_trampoline_; -// } -// -// At caller, replace: -// my_class_object.SignalMyNamedEvent.connect(target, function) -// with: -// my_class_object.SubscribeMyNamedEvent([target]{ target.function(); } -// Note that the SubscribeMyNamedEvent will NOT guarantee that the target -// continues to exist; if there is any doubt about that, use a SafeInvocable: -// my_class_object.SubscibeMyNamedEvent( -// SafeInvocable(target.safety_flag_.flag(), -// [target] { target.function(); } -// WHEN REMOVING THE SIGNAL -// Make a CL that will: -// - Delete the SignalMyNamedEvent signal -// - Change my_named_event_trampoline_ to my_named_event_callbacks, -// of type CallbackList -// - Change SubscribeMyNamedEvent to call my_named_event_callbacks.AddReceiver -// - Change NotifyMyNamedEvent to call my_named_event_callbacks_.Send -// - If UnsubscribeMyNamedEvent exists, change that also. -// - Delete the initialization of my_named_event_trampoline_ from the -// relevant constructor. -// Sending this through the bots will flush out remaining references to -// SignalMyNamedEvent. -namespace internal { -template -struct member_pointer_traits; - -// Used to find the type of ClassT::Member -template -struct member_pointer_traits { - using member_type = MemberT; -}; - -template -class SignalTrampolineBase; - -template -class SignalTrampolineBase> - : public sigslot::has_slots<> { - public: - void Subscribe(absl::AnyInvocable callback) { - callbacks_.AddReceiver(std::move(callback)); - } - void Subscribe(const void* tag, absl::AnyInvocable callback) { - callbacks_.AddReceiver(tag, std::move(callback)); - } - void Unsubscribe(const void* tag) { callbacks_.RemoveReceivers(tag); } - void Notify(Args... args) { callbacks_.Send(std::forward(args)...); } - - private: - CallbackList callbacks_; -}; - -template -using SignalTrampolineMemberBase = - SignalTrampolineBase::member_type>; - -// Repeat above for mt_policy = multi_threaded_local -template -class MultiThreadSignalTrampolineBase; - -template -class MultiThreadSignalTrampolineBase< - sigslot::signal_with_thread_policy> - : public sigslot::has_slots { - public: - void Subscribe(absl::AnyInvocable callback) { - callbacks_.AddReceiver(std::move(callback)); - } - void Subscribe(const void* tag, absl::AnyInvocable callback) { - callbacks_.AddReceiver(tag, std::move(callback)); - } - void Unsubscribe(const void* tag) { callbacks_.RemoveReceivers(tag); } - void Notify(Args... args) { callbacks_.Send(std::forward(args)...); } - - private: - CallbackList callbacks_; -}; - -template -using MultiThreadSignalTrampolineMemberBase = - MultiThreadSignalTrampolineBase::member_type>; - -} // namespace internal - -template -class SignalTrampoline - : public internal::SignalTrampolineMemberBase { - private: - using Base = internal::SignalTrampolineMemberBase; - - public: - // Because a SignalTrampoline is initialized with a pointer to its - // container, it's not possible to move or copy it. - SignalTrampoline(const SignalTrampoline&) = delete; - SignalTrampoline& operator=(const SignalTrampoline&) = delete; - SignalTrampoline(SignalTrampoline&&) = delete; - SignalTrampoline& operator=(SignalTrampoline&&) = delete; - explicit SignalTrampoline(T* that) { - (that->*member_signal).connect(static_cast(this), &Base::Notify); - } -}; - -// Note that a MultiThreadSignalTrampoline MUST be a member of the object -// of type T. -template -class MultiThreadSignalTrampoline - : public internal::MultiThreadSignalTrampolineMemberBase { - private: - using Base = - internal::MultiThreadSignalTrampolineMemberBase; - - public: - explicit MultiThreadSignalTrampoline(T* that) { - (that->*member_signal).connect(static_cast(this), &Base::Notify); - owner_ = that; - } - // This disconnect avoids a lock inversion issue in sigslot. - ~MultiThreadSignalTrampoline() { - (owner_->*member_signal).disconnect(static_cast(this)); - } - - private: - T* owner_; -}; - -} // namespace webrtc - -#endif // RTC_BASE_SIGSLOT_TRAMPOLINE_H_ diff --git a/rtc_base/sigslot_trampoline_unittest.cc b/rtc_base/sigslot_trampoline_unittest.cc deleted file mode 100644 index 5c1cd3db6a..0000000000 --- a/rtc_base/sigslot_trampoline_unittest.cc +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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. - */ - -#include "rtc_base/sigslot_trampoline.h" - -#include - -#include "absl/functional/any_invocable.h" -#include "rtc_base/third_party/sigslot/sigslot.h" -#include "test/gmock.h" -#include "test/gtest.h" - -namespace webrtc { -namespace { - -using ::testing::Mock; -using ::testing::MockFunction; -using ::testing::StrictMock; - -class ClassWithSlots { - public: - ClassWithSlots() : signal_0_trampoline_(this), signal_1_trampoline_(this) {} - - sigslot::signal0<> Signal0; - void NotifySignal0() { Signal0(); } - void SubscribeSignal0(absl::AnyInvocable callback) { - signal_0_trampoline_.Subscribe(std::move(callback)); - } - sigslot::signal1 Signal1; - void NotifySignal1(int arg) { Signal1(arg); } - void SubscribeSignal1(absl::AnyInvocable callback) { - signal_1_trampoline_.Subscribe(std::move(callback)); - } - - private: - SignalTrampoline - signal_0_trampoline_; - SignalTrampoline - signal_1_trampoline_; -}; - -TEST(SigslotTrampolineTest, FireSignal0) { - ClassWithSlots item; - StrictMock> mock_slot; - item.SubscribeSignal0(mock_slot.AsStdFunction()); - Mock::VerifyAndClearExpectations(&mock_slot); // No call before Notify - EXPECT_CALL(mock_slot, Call()); - item.NotifySignal0(); -} - -TEST(SigslotTrampolineTest, FireSignal1) { - ClassWithSlots item; - StrictMock> mock_slot; - item.SubscribeSignal1(mock_slot.AsStdFunction()); - Mock::VerifyAndClearExpectations(&mock_slot); // No call before Notify - EXPECT_CALL(mock_slot, Call(7)); - item.NotifySignal1(7); -} - -class ClassWithMultiThreadSlots { - public: - ClassWithMultiThreadSlots() : signal_0_trampoline_(this) {} - void NotifySignal0() { Signal0(); } - void SubscribeSignal0(absl::AnyInvocable callback) { - signal_0_trampoline_.Subscribe(std::move(callback)); - } - - private: - sigslot::signal0 Signal0; - MultiThreadSignalTrampoline - signal_0_trampoline_; -}; - -TEST(SigslotTrampolineTest, FireSignal0MultiThread) { - ClassWithMultiThreadSlots item; - StrictMock> mock_slot; - item.SubscribeSignal0(mock_slot.AsStdFunction()); - Mock::VerifyAndClearExpectations(&mock_slot); // No call before Notify - EXPECT_CALL(mock_slot, Call()); - item.NotifySignal0(); -} - -} // namespace - -} // namespace webrtc diff --git a/rtc_base/ssl_adapter_unittest.cc b/rtc_base/ssl_adapter_unittest.cc index 81dc422cef..94b288edf8 100644 --- a/rtc_base/ssl_adapter_unittest.cc +++ b/rtc_base/ssl_adapter_unittest.cc @@ -26,7 +26,6 @@ #include "rtc_base/ssl_certificate.h" #include "rtc_base/ssl_identity.h" #include "rtc_base/ssl_stream_adapter.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/virtual_socket_server.h" #include "test/gmock.h" @@ -60,10 +59,10 @@ class MockCertVerifier : public SSLCertificateVerifier { // TODO(benwright) - Move to using INSTANTIATE_TEST_SUITE_P instead of using // duplicate test cases for simple parameter changes. -class SSLAdapterTestDummy : public sigslot::has_slots<> { +class SSLAdapterTestDummy { public: explicit SSLAdapterTestDummy() : socket_(CreateSocket()) {} - ~SSLAdapterTestDummy() override = default; + ~SSLAdapterTestDummy() = default; void CreateSSLAdapter(Socket* socket, SSLRole role) { ssl_adapter_.reset(SSLAdapter::Create(socket)); @@ -198,7 +197,7 @@ class SSLAdapterTestDummyServer : public SSLAdapterTestDummy { std::unique_ptr ssl_identity_; }; -class SSLAdapterTestBase : public ::testing::Test, public sigslot::has_slots<> { +class SSLAdapterTestBase : public ::testing::Test { public: explicit SSLAdapterTestBase(const KeyParams& key_params) : vss_(new VirtualSocketServer()), diff --git a/rtc_base/ssl_stream_adapter_unittest.cc b/rtc_base/ssl_stream_adapter_unittest.cc index 6c193236d2..ef519e32a7 100644 --- a/rtc_base/ssl_stream_adapter_unittest.cc +++ b/rtc_base/ssl_stream_adapter_unittest.cc @@ -50,7 +50,6 @@ #include "rtc_base/ssl_certificate.h" #include "rtc_base/ssl_identity.h" #include "rtc_base/stream.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/time_utils.h" #include "test/create_test_field_trials.h" @@ -406,8 +405,7 @@ class BufferQueueStream : public StreamInterface { constexpr int kBufferCapacity = 1; constexpr size_t kDefaultBufferSize = 2048; -class SSLStreamAdapterTestBase : public ::testing::Test, - public sigslot::has_slots<> { +class SSLStreamAdapterTestBase : public ::testing::Test { public: SSLStreamAdapterTestBase(absl::string_view client_cert_pem, absl::string_view client_private_key_pem, diff --git a/rtc_base/test_client.h b/rtc_base/test_client.h index 68c7705ec0..4d498b3ed6 100644 --- a/rtc_base/test_client.h +++ b/rtc_base/test_client.h @@ -25,14 +25,13 @@ #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" #include "rtc_base/synchronization/mutex.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "test/wait_until.h" namespace webrtc { // A simple client that can send TCP or UDP data and check that it receives // what it expects to receive. Useful for testing server functionality. -class TestClient : public sigslot::has_slots<> { +class TestClient { public: // Records the contents of a packet that was received. struct Packet { @@ -55,7 +54,7 @@ class TestClient : public sigslot::has_slots<> { // for a packet to be received, and thus it needs to advance the fake clock // if the test is using one, rather than just sleeping. TestClient(std::unique_ptr socket, ClockVariant clock); - ~TestClient() override; + ~TestClient(); TestClient(const TestClient&) = delete; TestClient& operator=(const TestClient&) = delete; diff --git a/rtc_base/third_party/sigslot/BUILD.gn b/rtc_base/third_party/sigslot/BUILD.gn index 186a05c404..3833cc871f 100644 --- a/rtc_base/third_party/sigslot/BUILD.gn +++ b/rtc_base/third_party/sigslot/BUILD.gn @@ -8,8 +8,19 @@ import("../../../webrtc.gni") +# This target is visible to its unittest, and is visible +# to downstream projects, but is not allowed for any other +# use in webrtc. +# TODO: https://issues.webrtc.org/463409684 - move it out of libwebrtc sources rtc_library("sigslot") { - visibility = [ "*" ] + visibility = [ + "*", + "../../../rtc_base:sigslot_unittest", + + # The denial rule must be last. This comment stops git cl format + # from moving it first. + "!../../../*", + ] sources = [ "sigslot.cc", "sigslot.h", diff --git a/test/network/BUILD.gn b/test/network/BUILD.gn index 57f8682980..e4ada7d6f1 100644 --- a/test/network/BUILD.gn +++ b/test/network/BUILD.gn @@ -172,7 +172,6 @@ if (rtc_include_tests) { "../../rtc_base:task_queue_for_test", "../../rtc_base:threading", "../../rtc_base/synchronization:mutex", - "../../rtc_base/third_party/sigslot", "//third_party/abseil-cpp/absl/functional:any_invocable", ] } diff --git a/test/peer_scenario/BUILD.gn b/test/peer_scenario/BUILD.gn index 4aca0522b3..0d1c68d99e 100644 --- a/test/peer_scenario/BUILD.gn +++ b/test/peer_scenario/BUILD.gn @@ -95,7 +95,6 @@ if (rtc_include_tests) { "../../rtc_base:stringutils", "../../rtc_base:task_queue_for_test", "../../rtc_base:threading", - "../../rtc_base/third_party/sigslot", "../../system_wrappers", "../logging:log_writer", "../network:emulated_network", diff --git a/test/peer_scenario/scenario_connection.cc b/test/peer_scenario/scenario_connection.cc index 388da871d3..c78d406dd1 100644 --- a/test/peer_scenario/scenario_connection.cc +++ b/test/peer_scenario/scenario_connection.cc @@ -51,14 +51,12 @@ #include "rtc_base/ssl_fingerprint.h" #include "rtc_base/ssl_identity.h" #include "rtc_base/task_queue_for_test.h" -#include "rtc_base/third_party/sigslot/sigslot.h" #include "rtc_base/thread.h" #include "rtc_base/thread_annotations.h" #include "test/network/network_emulation_manager.h" namespace webrtc { class ScenarioIceConnectionImpl : public ScenarioIceConnection, - public sigslot::has_slots<>, private JsepTransportController::Observer, private RtpPacketSinkInterface { public: