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

Unified Diff: base/bind_internal.h

Issue 2355763002: Support nested OnceCallback on Callback::IsCancelled (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/bind_internal.h
diff --git a/base/bind_internal.h b/base/bind_internal.h
index 5845a4d031de9c3df658820a4b2f4cc3e545fe61..0872240e4562a7b44cdc7c8aa064852d08f14258 100644
--- a/base/bind_internal.h
+++ b/base/bind_internal.h
@@ -411,17 +411,25 @@ struct CancellationChecker<
}
};
-template <typename Signature, typename... BoundArgs>
-struct CancellationChecker<BindState<Callback<Signature>, BoundArgs...>> {
+template <typename BindStateType>
+struct CallbackCancellationChecker {
static constexpr bool is_cancellable = true;
static bool Run(const BindStateBase* base) {
- using Functor = Callback<Signature>;
- using BindStateType = BindState<Functor, BoundArgs...>;
- const BindStateType* bind_state = static_cast<const BindStateType*>(base);
- return bind_state->functor_.IsCancelled();
+ return static_cast<const BindStateType*>(base)->functor_.IsCancelled();
}
};
+template <typename Signature, typename... BoundArgs>
+struct CancellationChecker<BindState<OnceCallback<Signature>, BoundArgs...>>
+ : CallbackCancellationChecker<
+ BindState<OnceCallback<Signature>, BoundArgs...>> {};
+
+template <typename Signature, typename... BoundArgs>
+struct CancellationChecker<
+ BindState<RepeatingCallback<Signature>, BoundArgs...>>
+ : CallbackCancellationChecker<
+ BindState<RepeatingCallback<Signature>, BoundArgs...>> {};
+
// BindState<>
//
// This stores all the state passed into Bind().
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698