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}
This commit is contained in:
Mirko Bonadei 2020-10-23 12:04:40 +02:00 committed by Commit Bot
parent 9d69cbeabf
commit 3d25935127
8 changed files with 80 additions and 80 deletions

View file

@ -539,7 +539,7 @@ if (rtc_include_tests) {
"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",

View file

@ -110,9 +110,9 @@ rtc_library("rtc_pc_base") {
"../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 @@ rtc_library("peerconnection") {
"../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",

View file

@ -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 @@ class JsepTransportController : public sigslot::has_slots<> {
// 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;

View file

@ -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"

View file

@ -48,10 +48,10 @@ rtc_source_set("untyped_function") {
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("testclient") {
]
}
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",

View file

@ -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

View file

@ -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 @@ class RoboCallerReceivers {
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 @@ extern template void RoboCallerReceivers::AddReceiver(
// 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 @@ class RoboCaller {
}
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_

View file

@ -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 @@ TEST(RoboCaller, MultipleParameterMessageTest) {
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 @@ enum State {
kChecking,
};
TEST(RoboCaller, SingleEnumValueTest) {
RoboCaller<State> c;
TEST(CallbackList, SingleEnumValueTest) {
CallbackList<State> c;
State s1 = kNew;
int index = 0;
@ -66,8 +66,8 @@ TEST(RoboCaller, SingleEnumValueTest) {
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 @@ TEST(RoboCaller, SingleEnumReferenceTest) {
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 @@ TEST(RoboCaller, ConstReferenceTest) {
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 @@ TEST(RoboCaller, PointerTest) {
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 @@ void PlusOne(int& a) {
a++;
}
TEST(RoboCaller, FunctionPtrTest) {
RoboCaller<int&> c;
TEST(CallbackList, FunctionPtrTest) {
CallbackList<int&> c;
int index = 1;
c.AddReceiver(PlusOne);
@ -132,8 +132,8 @@ struct LargeNonTrivial {
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 @@ struct LargeTrivial {
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 @@ struct OnlyNonTriviallyConstructible {
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 @@ TEST(RoboCaller, OnlyNonTriviallyMoveConstructible) {
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 @@ class A {
void increment(int& i) const { i++; }
};
TEST(RoboCaller, MemberFunctionTest) {
RoboCaller<int&> c;
TEST(CallbackList, MemberFunctionTest) {
CallbackList<int&> c;
A a;
int index = 1;