Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2321)

Unified Diff: base/callback_unittest.cc

Issue 2034633002: Decouple Invoker from BindState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove base::internal::MakeUnboundRunType Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/callback.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/callback_unittest.cc
diff --git a/base/callback_unittest.cc b/base/callback_unittest.cc
index 176ea0650ab6c9eb5664ed6ad23d3b821ad12634..ce453a10758e72f9a8799ba2db2b350588c508a6 100644
--- a/base/callback_unittest.cc
+++ b/base/callback_unittest.cc
@@ -14,63 +14,38 @@
namespace base {
-namespace {
-
-struct FakeInvoker {
- // MSVC 2013 doesn't support Type Alias of function types.
- // Revisit this after we update it to newer version.
- typedef void RunType(internal::BindStateBase*);
- static void Run(internal::BindStateBase*) {
- }
-};
-
-} // namespace
-
-namespace internal {
+void NopInvokeFunc(internal::BindStateBase*) {}
// White-box testpoints to inject into a Callback<> object for checking
// comparators and emptiness APIs. Use a BindState that is specialized
// based on a type we declared in the anonymous namespace above to remove any
// chance of colliding with another instantiation and breaking the
// one-definition-rule.
-template <>
-struct BindState<void(), void(), FakeInvoker>
- : public BindStateBase {
- public:
- BindState() : BindStateBase(&Destroy) {}
- using InvokerType = FakeInvoker;
+struct FakeBindState1 : internal::BindStateBase {
+ FakeBindState1() : BindStateBase(&Destroy) {}
private:
- ~BindState() {}
- static void Destroy(BindStateBase* self) {
- delete static_cast<BindState*>(self);
+ ~FakeBindState1() {}
+ static void Destroy(internal::BindStateBase* self) {
+ delete static_cast<FakeBindState1*>(self);
}
};
-template <>
-struct BindState<void(), void(), FakeInvoker, FakeInvoker>
- : public BindStateBase {
- public:
- BindState() : BindStateBase(&Destroy) {}
- using InvokerType = FakeInvoker;
+struct FakeBindState2 : internal::BindStateBase {
+ FakeBindState2() : BindStateBase(&Destroy) {}
private:
- ~BindState() {}
- static void Destroy(BindStateBase* self) {
- delete static_cast<BindState*>(self);
+ ~FakeBindState2() {}
+ static void Destroy(internal::BindStateBase* self) {
+ delete static_cast<FakeBindState2*>(self);
}
};
-} // namespace internal
namespace {
-using FakeBindState1 = internal::BindState<void(), void(), FakeInvoker>;
-using FakeBindState2 =
- internal::BindState<void(), void(), FakeInvoker, FakeInvoker>;
-
class CallbackTest : public ::testing::Test {
public:
CallbackTest()
- : callback_a_(new FakeBindState1()),
- callback_b_(new FakeBindState2()) {
+ : callback_a_(new FakeBindState1(), &NopInvokeFunc),
+ callback_b_(new FakeBindState2(), &NopInvokeFunc) {
}
~CallbackTest() override {}
@@ -113,7 +88,7 @@ TEST_F(CallbackTest, Equals) {
EXPECT_FALSE(callback_b_.Equals(callback_a_));
// We should compare based on instance, not type.
- Callback<void()> callback_c(new FakeBindState1());
+ Callback<void()> callback_c(new FakeBindState1(), &NopInvokeFunc);
Callback<void()> callback_a2 = callback_a_;
EXPECT_TRUE(callback_a_.Equals(callback_a2));
EXPECT_FALSE(callback_a_.Equals(callback_c));
« no previous file with comments | « base/callback.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698