Rename RoboCaller to CallbackList.
As discussed on a design review, the name RoboCaller is not clear
enough and switching to CallbackList will provide readability benefits.
Bug: webrtc:11943
Change-Id: I010cf0a91b5323e4e9c96b83703be7af1e67439c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/190142
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32478}
diff --git a/BUILD.gn b/BUILD.gn
index cec97c5..dec3d6f 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -539,7 +539,7 @@
"call:fake_network_pipe_unittests",
"p2p:libstunprober_unittests",
"p2p:rtc_p2p_unittests",
- "rtc_base:robo_caller_unittests",
+ "rtc_base:callback_list_unittests",
"rtc_base:rtc_base_approved_unittests",
"rtc_base:rtc_base_unittests",
"rtc_base:rtc_json_unittests",
diff --git a/pc/BUILD.gn b/pc/BUILD.gn
index fbd0295..7c677d2 100644
--- a/pc/BUILD.gn
+++ b/pc/BUILD.gn
@@ -110,9 +110,9 @@
"../modules/rtp_rtcp:rtp_rtcp_format",
"../p2p:rtc_p2p",
"../rtc_base",
+ "../rtc_base:callback_list",
"../rtc_base:checks",
"../rtc_base:deprecation",
- "../rtc_base:robo_caller",
"../rtc_base:rtc_task_queue",
"../rtc_base:stringutils",
"../rtc_base/synchronization:mutex",
@@ -273,9 +273,9 @@
"../modules/rtp_rtcp:rtp_rtcp_format",
"../p2p:rtc_p2p",
"../rtc_base",
+ "../rtc_base:callback_list",
"../rtc_base:checks",
"../rtc_base:deprecation",
- "../rtc_base:robo_caller",
"../rtc_base:rtc_base_approved",
"../rtc_base:rtc_operations_chain",
"../rtc_base:safe_minmax",
diff --git a/pc/jsep_transport_controller.h b/pc/jsep_transport_controller.h
index f3a9294..f0adeed 100644
--- a/pc/jsep_transport_controller.h
+++ b/pc/jsep_transport_controller.h
@@ -35,7 +35,7 @@
#include "rtc_base/async_invoker.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/ref_counted_object.h"
-#include "rtc_base/robo_caller.h"
+#include "rtc_base/callback_list.h"
#include "rtc_base/third_party/sigslot/sigslot.h"
namespace rtc {
@@ -198,7 +198,7 @@
// Else if all completed => completed,
// Else if all connected => connected,
// Else => connecting
- RoboCaller<cricket::IceConnectionState> SignalIceConnectionState;
+ CallbackList<cricket::IceConnectionState> SignalIceConnectionState;
sigslot::signal1<PeerConnectionInterface::PeerConnectionState>
SignalConnectionState;
diff --git a/pc/peer_connection.cc b/pc/peer_connection.cc
index e6e8c7f..b2437fa 100644
--- a/pc/peer_connection.cc
+++ b/pc/peer_connection.cc
@@ -52,7 +52,7 @@
#include "rtc_base/logging.h"
#include "rtc_base/net_helper.h"
#include "rtc_base/network_constants.h"
-#include "rtc_base/robo_caller.h"
+#include "rtc_base/callback_list.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/string_encode.h"
#include "rtc_base/task_utils/to_queued_task.h"
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index d11c8a3..66da6e0 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -48,10 +48,10 @@
deps = [ "system:assume" ]
}
-rtc_source_set("robo_caller") {
+rtc_source_set("callback_list") {
sources = [
- "robo_caller.cc",
- "robo_caller.h",
+ "callback_list.cc",
+ "callback_list.h",
]
deps = [
":untyped_function",
@@ -1072,13 +1072,13 @@
]
}
-rtc_library("robo_caller_unittests") {
+rtc_library("callback_list_unittests") {
testonly = true
- sources = [ "robo_caller_unittest.cc" ]
+ sources = [ "callback_list_unittest.cc" ]
deps = [
+ ":callback_list",
":gunit_helpers",
- ":robo_caller",
":rtc_base",
"../api:function_view",
"../test:test_support",
diff --git a/rtc_base/robo_caller.cc b/rtc_base/callback_list.cc
similarity index 61%
rename from rtc_base/robo_caller.cc
rename to rtc_base/callback_list.cc
index a7c35cb..0b1de8e 100644
--- a/rtc_base/robo_caller.cc
+++ b/rtc_base/callback_list.cc
@@ -8,33 +8,33 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include "rtc_base/robo_caller.h"
+#include "rtc_base/callback_list.h"
namespace webrtc {
-namespace robo_caller_impl {
+namespace callback_list_impl {
-RoboCallerReceivers::RoboCallerReceivers() = default;
-RoboCallerReceivers::~RoboCallerReceivers() = default;
+CallbackListReceivers::CallbackListReceivers() = default;
+CallbackListReceivers::~CallbackListReceivers() = default;
-void RoboCallerReceivers::Foreach(
+void CallbackListReceivers::Foreach(
rtc::FunctionView<void(UntypedFunction&)> fv) {
for (auto& r : receivers_) {
fv(r);
}
}
-template void RoboCallerReceivers::AddReceiver(
+template void CallbackListReceivers::AddReceiver(
UntypedFunction::TrivialUntypedFunctionArgs<1>);
-template void RoboCallerReceivers::AddReceiver(
+template void CallbackListReceivers::AddReceiver(
UntypedFunction::TrivialUntypedFunctionArgs<2>);
-template void RoboCallerReceivers::AddReceiver(
+template void CallbackListReceivers::AddReceiver(
UntypedFunction::TrivialUntypedFunctionArgs<3>);
-template void RoboCallerReceivers::AddReceiver(
+template void CallbackListReceivers::AddReceiver(
UntypedFunction::TrivialUntypedFunctionArgs<4>);
-template void RoboCallerReceivers::AddReceiver(
+template void CallbackListReceivers::AddReceiver(
UntypedFunction::NontrivialUntypedFunctionArgs);
-template void RoboCallerReceivers::AddReceiver(
+template void CallbackListReceivers::AddReceiver(
UntypedFunction::FunctionPointerUntypedFunctionArgs);
-} // namespace robo_caller_impl
+} // namespace callback_list_impl
} // namespace webrtc
diff --git a/rtc_base/robo_caller.h b/rtc_base/callback_list.h
similarity index 67%
rename from rtc_base/robo_caller.h
rename to rtc_base/callback_list.h
index 9df6a48..218693a 100644
--- a/rtc_base/robo_caller.h
+++ b/rtc_base/callback_list.h
@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#ifndef RTC_BASE_ROBO_CALLER_H_
-#define RTC_BASE_ROBO_CALLER_H_
+#ifndef RTC_BASE_CALLBACK_LIST_H_
+#define RTC_BASE_CALLBACK_LIST_H_
#include <utility>
#include <vector>
@@ -20,16 +20,16 @@
#include "rtc_base/untyped_function.h"
namespace webrtc {
-namespace robo_caller_impl {
+namespace callback_list_impl {
-class RoboCallerReceivers {
+class CallbackListReceivers {
public:
- RoboCallerReceivers();
- RoboCallerReceivers(const RoboCallerReceivers&) = delete;
- RoboCallerReceivers& operator=(const RoboCallerReceivers&) = delete;
- RoboCallerReceivers(RoboCallerReceivers&&) = delete;
- RoboCallerReceivers& operator=(RoboCallerReceivers&&) = delete;
- ~RoboCallerReceivers();
+ CallbackListReceivers();
+ CallbackListReceivers(const CallbackListReceivers&) = delete;
+ CallbackListReceivers& operator=(const CallbackListReceivers&) = delete;
+ CallbackListReceivers(CallbackListReceivers&&) = delete;
+ CallbackListReceivers& operator=(CallbackListReceivers&&) = delete;
+ ~CallbackListReceivers();
template <typename UntypedFunctionArgsT>
RTC_NO_INLINE void AddReceiver(UntypedFunctionArgsT args) {
@@ -42,20 +42,20 @@
std::vector<UntypedFunction> receivers_;
};
-extern template void RoboCallerReceivers::AddReceiver(
+extern template void CallbackListReceivers::AddReceiver(
UntypedFunction::TrivialUntypedFunctionArgs<1>);
-extern template void RoboCallerReceivers::AddReceiver(
+extern template void CallbackListReceivers::AddReceiver(
UntypedFunction::TrivialUntypedFunctionArgs<2>);
-extern template void RoboCallerReceivers::AddReceiver(
+extern template void CallbackListReceivers::AddReceiver(
UntypedFunction::TrivialUntypedFunctionArgs<3>);
-extern template void RoboCallerReceivers::AddReceiver(
+extern template void CallbackListReceivers::AddReceiver(
UntypedFunction::TrivialUntypedFunctionArgs<4>);
-extern template void RoboCallerReceivers::AddReceiver(
+extern template void CallbackListReceivers::AddReceiver(
UntypedFunction::NontrivialUntypedFunctionArgs);
-extern template void RoboCallerReceivers::AddReceiver(
+extern template void CallbackListReceivers::AddReceiver(
UntypedFunction::FunctionPointerUntypedFunctionArgs);
-} // namespace robo_caller_impl
+} // namespace callback_list_impl
// A collection of receivers (callable objects) that can be called all at once.
// Optimized for minimal binary size.
@@ -68,13 +68,13 @@
// if they wish to stay in the CSC and another value if they wish to be removed.
// It depends on what's convenient for the callers...
template <typename... ArgT>
-class RoboCaller {
+class CallbackList {
public:
- RoboCaller() = default;
- RoboCaller(const RoboCaller&) = delete;
- RoboCaller& operator=(const RoboCaller&) = delete;
- RoboCaller(RoboCaller&&) = delete;
- RoboCaller& operator=(RoboCaller&&) = delete;
+ CallbackList() = default;
+ CallbackList(const CallbackList&) = delete;
+ CallbackList& operator=(const CallbackList&) = delete;
+ CallbackList(CallbackList&&) = delete;
+ CallbackList& operator=(CallbackList&&) = delete;
// Adds a new receiver. The receiver (a callable object or a function pointer)
// must be movable, but need not be copyable. Its call signature should be
@@ -94,9 +94,9 @@
}
private:
- robo_caller_impl::RoboCallerReceivers receivers_;
+ callback_list_impl::CallbackListReceivers receivers_;
};
} // namespace webrtc
-#endif // RTC_BASE_ROBO_CALLER_H_
+#endif // RTC_BASE_CALLBACK_LIST_H_
diff --git a/rtc_base/robo_caller_unittest.cc b/rtc_base/callback_list_unittest.cc
similarity index 74%
rename from rtc_base/robo_caller_unittest.cc
rename to rtc_base/callback_list_unittest.cc
index 3ca9051..811f85e 100644
--- a/rtc_base/robo_caller_unittest.cc
+++ b/rtc_base/callback_list_unittest.cc
@@ -12,20 +12,20 @@
#include "api/function_view.h"
#include "rtc_base/bind.h"
-#include "rtc_base/robo_caller.h"
+#include "rtc_base/callback_list.h"
#include "test/gtest.h"
namespace webrtc {
namespace {
-TEST(RoboCaller, NoRecieverSingleMessageTest) {
- RoboCaller<std::string> c;
+TEST(CallbackList, NoRecieverSingleMessageTest) {
+ CallbackList<std::string> c;
c.Send("message");
}
-TEST(RoboCaller, MultipleParameterMessageTest) {
- RoboCaller<const std::string&, std::string, std::string&&, int, int*,
+TEST(CallbackList, MultipleParameterMessageTest) {
+ CallbackList<const std::string&, std::string, std::string&&, int, int*,
std::string&>
c;
std::string str = "messege";
@@ -34,14 +34,14 @@
c.Send(str, "message1", "message0", 123, &i, str);
}
-TEST(RoboCaller, NoParameterMessageTest) {
- RoboCaller<> c;
+TEST(CallbackList, NoParameterMessageTest) {
+ CallbackList<> c;
c.Send();
}
-TEST(RoboCaller, ReferenceTest) {
- RoboCaller<int&> c;
+TEST(CallbackList, ReferenceTest) {
+ CallbackList<int&> c;
int index = 1;
c.AddReceiver([](int& index) { index++; });
@@ -55,8 +55,8 @@
kChecking,
};
-TEST(RoboCaller, SingleEnumValueTest) {
- RoboCaller<State> c;
+TEST(CallbackList, SingleEnumValueTest) {
+ CallbackList<State> c;
State s1 = kNew;
int index = 0;
@@ -66,8 +66,8 @@
EXPECT_EQ(index, 1);
}
-TEST(RoboCaller, SingleEnumReferenceTest) {
- RoboCaller<State&> c;
+TEST(CallbackList, SingleEnumReferenceTest) {
+ CallbackList<State&> c;
State s = kNew;
c.AddReceiver([](State& s) { s = kChecking; });
@@ -76,8 +76,8 @@
EXPECT_EQ(s, kChecking);
}
-TEST(RoboCaller, ConstReferenceTest) {
- RoboCaller<int&> c;
+TEST(CallbackList, ConstReferenceTest) {
+ CallbackList<int&> c;
int i = 0;
int index = 1;
@@ -87,8 +87,8 @@
EXPECT_EQ(i, 1);
}
-TEST(RoboCaller, PointerTest) {
- RoboCaller<int*> c;
+TEST(CallbackList, PointerTest) {
+ CallbackList<int*> c;
int index = 1;
c.AddReceiver([](int* index) { (*index)++; });
@@ -97,8 +97,8 @@
EXPECT_EQ(index, 2);
}
-TEST(RoboCaller, CallByValue) {
- RoboCaller<int> c;
+TEST(CallbackList, CallByValue) {
+ CallbackList<int> c;
int x = 17;
c.AddReceiver([&x](int n) { x += n; });
@@ -112,8 +112,8 @@
a++;
}
-TEST(RoboCaller, FunctionPtrTest) {
- RoboCaller<int&> c;
+TEST(CallbackList, FunctionPtrTest) {
+ CallbackList<int&> c;
int index = 1;
c.AddReceiver(PlusOne);
@@ -132,8 +132,8 @@
void operator()(int& a) { a = 1; }
};
-TEST(RoboCaller, LargeNonTrivialTest) {
- RoboCaller<int&> c;
+TEST(CallbackList, LargeNonTrivialTest) {
+ CallbackList<int&> c;
int i = 0;
static_assert(sizeof(LargeNonTrivial) > UntypedFunction::kInlineStorageSize,
"");
@@ -148,8 +148,8 @@
void operator()(int& x) { x = 1; }
};
-TEST(RoboCaller, LargeTrivial) {
- RoboCaller<int&> c;
+TEST(CallbackList, LargeTrivial) {
+ CallbackList<int&> c;
LargeTrivial lt;
int i = 0;
@@ -167,8 +167,8 @@
void operator()(int& a) { a = 1; }
};
-TEST(RoboCaller, OnlyNonTriviallyMoveConstructible) {
- RoboCaller<int&> c;
+TEST(CallbackList, OnlyNonTriviallyMoveConstructible) {
+ CallbackList<int&> c;
int i = 0;
c.AddReceiver(OnlyNonTriviallyConstructible());
@@ -177,8 +177,8 @@
EXPECT_EQ(i, 1);
}
-TEST(RoboCaller, MultipleReceiverSendTest) {
- RoboCaller<int&> c;
+TEST(CallbackList, MultipleReceiverSendTest) {
+ CallbackList<int&> c;
std::function<void(int&)> plus = PlusOne;
int index = 1;
@@ -197,8 +197,8 @@
void increment(int& i) const { i++; }
};
-TEST(RoboCaller, MemberFunctionTest) {
- RoboCaller<int&> c;
+TEST(CallbackList, MemberFunctionTest) {
+ CallbackList<int&> c;
A a;
int index = 1;