Rename CancerStickCastle to RoboCaller.

The name was chosen because just like a real-world robocaller
[https://en.wikipedia.org/wiki/Robocall], webrtc::RoboCaller will
call multiple recipients and give all of them the same message,
without giving them the chance to reply.

Change-Id: Ia95f4543b15b48fa6388a50706e489dfccc19f71
Bug: webrtc:11943
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/184621
Commit-Queue: Lahiru Ginnaliya Gamathige <glahiru@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32152}
This commit is contained in:
Lahiru Ginnaliya Gamathige 2020-09-21 12:28:48 -07:00 committed by Commit Bot
parent d41c2a6b8a
commit 52fa992ccc
5 changed files with 57 additions and 58 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:cancer_stick_castle_unittests",
"rtc_base:robo_caller_unittests",
"rtc_base:rtc_base_approved_unittests",
"rtc_base:rtc_base_unittests",
"rtc_base:rtc_json_unittests",

View File

@ -48,10 +48,10 @@ rtc_source_set("untyped_function") {
deps = [ "system:assume" ]
}
rtc_source_set("cancer_stick_castle") {
rtc_source_set("robo_caller") {
sources = [
"cancer_stick_castle.cc",
"cancer_stick_castle.h",
"robo_caller.cc",
"robo_caller.h",
]
deps = [
":untyped_function",
@ -1073,13 +1073,13 @@ rtc_library("testclient") {
]
}
rtc_library("cancer_stick_castle_unittests") {
rtc_library("robo_caller_unittests") {
testonly = true
sources = [ "cancer_stick_castle_unittest.cc" ]
sources = [ "robo_caller_unittest.cc" ]
deps = [
":cancer_stick_castle",
":gunit_helpers",
":robo_caller",
":rtc_base",
"../api:function_view",
"../test:test_support",

View File

@ -8,24 +8,24 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "rtc_base/cancer_stick_castle.h"
#include "rtc_base/robo_caller.h"
namespace webrtc {
namespace cancer_stick_castle_impl {
namespace robo_caller_impl {
CancerStickCastleReceivers::CancerStickCastleReceivers() = default;
CancerStickCastleReceivers::~CancerStickCastleReceivers() = default;
RoboCallerReceivers::RoboCallerReceivers() = default;
RoboCallerReceivers::~RoboCallerReceivers() = default;
void CancerStickCastleReceivers::AddReceiverImpl(UntypedFunction* f) {
void RoboCallerReceivers::AddReceiverImpl(UntypedFunction* f) {
receivers_.push_back(std::move(*f));
}
void CancerStickCastleReceivers::Foreach(
void RoboCallerReceivers::Foreach(
rtc::FunctionView<void(UntypedFunction&)> fv) {
for (auto& r : receivers_) {
fv(r);
}
}
} // namespace cancer_stick_castle_impl
} // namespace robo_caller_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_CANCER_STICK_CASTLE_H_
#define RTC_BASE_CANCER_STICK_CASTLE_H_
#ifndef RTC_BASE_ROBO_CALLER_H_
#define RTC_BASE_ROBO_CALLER_H_
#include <utility>
#include <vector>
@ -19,17 +19,16 @@
#include "rtc_base/untyped_function.h"
namespace webrtc {
namespace cancer_stick_castle_impl {
namespace robo_caller_impl {
class CancerStickCastleReceivers {
class RoboCallerReceivers {
public:
CancerStickCastleReceivers();
CancerStickCastleReceivers(const CancerStickCastleReceivers&) = delete;
CancerStickCastleReceivers& operator=(const CancerStickCastleReceivers&) =
delete;
CancerStickCastleReceivers(CancerStickCastleReceivers&&) = delete;
CancerStickCastleReceivers& operator=(CancerStickCastleReceivers&&) = delete;
~CancerStickCastleReceivers();
RoboCallerReceivers();
RoboCallerReceivers(const RoboCallerReceivers&) = delete;
RoboCallerReceivers& operator=(const RoboCallerReceivers&) = delete;
RoboCallerReceivers(RoboCallerReceivers&&) = delete;
RoboCallerReceivers& operator=(RoboCallerReceivers&&) = delete;
~RoboCallerReceivers();
void AddReceiver(UntypedFunction&& f) {
AddReceiverImpl(&f);
@ -45,7 +44,7 @@ class CancerStickCastleReceivers {
std::vector<UntypedFunction> receivers_;
};
} // namespace cancer_stick_castle_impl
} // namespace robo_caller_impl
// A collection of receivers (callable objects) that can be called all at once.
// Optimized for minimal binary size.
@ -58,13 +57,13 @@ class CancerStickCastleReceivers {
// 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 CancerStickCastle {
class RoboCaller {
public:
CancerStickCastle() = default;
CancerStickCastle(const CancerStickCastle&) = delete;
CancerStickCastle& operator=(const CancerStickCastle&) = delete;
CancerStickCastle(CancerStickCastle&&) = delete;
CancerStickCastle& operator=(CancerStickCastle&&) = delete;
RoboCaller() = default;
RoboCaller(const RoboCaller&) = delete;
RoboCaller& operator=(const RoboCaller&) = delete;
RoboCaller(RoboCaller&&) = delete;
RoboCaller& operator=(RoboCaller&&) = 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
@ -83,9 +82,9 @@ class CancerStickCastle {
}
private:
cancer_stick_castle_impl::CancerStickCastleReceivers receivers_;
robo_caller_impl::RoboCallerReceivers receivers_;
};
} // namespace webrtc
#endif // RTC_BASE_CANCER_STICK_CASTLE_H_
#endif // RTC_BASE_ROBO_CALLER_H_

View File

@ -12,21 +12,21 @@
#include "api/function_view.h"
#include "rtc_base/bind.h"
#include "rtc_base/cancer_stick_castle.h"
#include "rtc_base/robo_caller.h"
#include "test/gtest.h"
namespace webrtc {
namespace {
TEST(CancerStickCastle, NoRecieverSingleMessageTest) {
CancerStickCastle<std::string> c;
TEST(RoboCaller, NoRecieverSingleMessageTest) {
RoboCaller<std::string> c;
c.Send("message");
}
TEST(CancerStickCastle, MultipleParameterMessageTest) {
CancerStickCastle<const std::string&, std::string, std::string&&, int, int*,
std::string&>
TEST(RoboCaller, MultipleParameterMessageTest) {
RoboCaller<const std::string&, std::string, std::string&&, int, int*,
std::string&>
c;
std::string str = "messege";
int i = 10;
@ -34,14 +34,14 @@ TEST(CancerStickCastle, MultipleParameterMessageTest) {
c.Send(str, "message1", "message0", 123, &i, str);
}
TEST(CancerStickCastle, NoParameterMessageTest) {
CancerStickCastle<> c;
TEST(RoboCaller, NoParameterMessageTest) {
RoboCaller<> c;
c.Send();
}
TEST(CancerStickCastle, ReferenceTest) {
CancerStickCastle<int&> c;
TEST(RoboCaller, ReferenceTest) {
RoboCaller<int&> c;
int index = 1;
c.AddReceiver([](int& index) { index++; });
@ -50,8 +50,8 @@ TEST(CancerStickCastle, ReferenceTest) {
EXPECT_EQ(index, 2);
}
TEST(CancerStickCastle, ConstReferenceTest) {
CancerStickCastle<int&> c;
TEST(RoboCaller, ConstReferenceTest) {
RoboCaller<int&> c;
int i = 0;
int index = 1;
@ -61,8 +61,8 @@ TEST(CancerStickCastle, ConstReferenceTest) {
EXPECT_EQ(i, 1);
}
TEST(CancerStickCastle, PointerTest) {
CancerStickCastle<int*> c;
TEST(RoboCaller, PointerTest) {
RoboCaller<int*> c;
int index = 1;
c.AddReceiver([](int* index) { (*index)++; });
@ -75,8 +75,8 @@ void PlusOne(int& a) {
a++;
}
TEST(CancerStickCastle, FunctionPtrTest) {
CancerStickCastle<int&> c;
TEST(RoboCaller, FunctionPtrTest) {
RoboCaller<int&> c;
int index = 1;
c.AddReceiver(PlusOne);
@ -95,8 +95,8 @@ struct LargeNonTrivial {
void operator()(int& a) { a = 1; }
};
TEST(CancerStickCastle, LargeNonTrivialTest) {
CancerStickCastle<int&> c;
TEST(RoboCaller, LargeNonTrivialTest) {
RoboCaller<int&> c;
int i = 0;
static_assert(sizeof(LargeNonTrivial) > 16, "");
c.AddReceiver(LargeNonTrivial());
@ -112,8 +112,8 @@ struct LargeTrivial {
void operator()(int& x) { x = 1; }
};
TEST(CancerStickCastle, LargeTrivial) {
CancerStickCastle<int&> c;
TEST(RoboCaller, LargeTrivial) {
RoboCaller<int&> c;
LargeTrivial lt;
int i = 0;
@ -131,8 +131,8 @@ struct OnlyNonTriviallyConstructible {
void operator()(int& a) { a = 1; }
};
TEST(CancerStickCastle, OnlyNonTriviallyMoveConstructible) {
CancerStickCastle<int&> c;
TEST(RoboCaller, OnlyNonTriviallyMoveConstructible) {
RoboCaller<int&> c;
int i = 0;
c.AddReceiver(OnlyNonTriviallyConstructible());
@ -141,8 +141,8 @@ TEST(CancerStickCastle, OnlyNonTriviallyMoveConstructible) {
EXPECT_EQ(i, 1);
}
TEST(CancerStickCastle, MultipleReceiverSendTest) {
CancerStickCastle<int&> c;
TEST(RoboCaller, MultipleReceiverSendTest) {
RoboCaller<int&> c;
std::function<void(int&)> plus = PlusOne;
int index = 1;