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

Unified Diff: base/callback_list.h

Issue 618573002: [Base] Use variadic template in callback_list.h (wave 1) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | base/callback_list.h.pump » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/callback_list.h
diff --git a/base/callback_list.h b/base/callback_list.h
index 5b911fd4867e1bec80ce002c57fd5d58b129247b..aeed5f1e2216211df27e66760a4b2ef2de436ad3 100644
--- a/base/callback_list.h
+++ b/base/callback_list.h
@@ -1,8 +1,3 @@
-// This file was GENERATED by command:
-// pump.py callback_list.h.pump
-// DO NOT EDIT BY HAND!!!
-
-
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -208,192 +203,21 @@ class CallbackListBase {
template <typename Sig> class CallbackList;
-template <>
-class CallbackList<void(void)>
- : public internal::CallbackListBase<Callback<void(void)> > {
- public:
- typedef Callback<void(void)> CallbackType;
-
- CallbackList() {}
-
- void Notify() {
- internal::CallbackListBase<CallbackType>::Iterator it =
- this->GetIterator();
- CallbackType* cb;
- while ((cb = it.GetNext()) != NULL) {
- cb->Run();
- }
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CallbackList);
-};
-
-template <typename A1>
-class CallbackList<void(A1)>
- : public internal::CallbackListBase<Callback<void(A1)> > {
- public:
- typedef Callback<void(A1)> CallbackType;
-
- CallbackList() {}
-
- void Notify(typename internal::CallbackParamTraits<A1>::ForwardType a1) {
- typename internal::CallbackListBase<CallbackType>::Iterator it =
- this->GetIterator();
- CallbackType* cb;
- while ((cb = it.GetNext()) != NULL) {
- cb->Run(a1);
- }
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CallbackList);
-};
-
-template <typename A1, typename A2>
-class CallbackList<void(A1, A2)>
- : public internal::CallbackListBase<Callback<void(A1, A2)> > {
- public:
- typedef Callback<void(A1, A2)> CallbackType;
-
- CallbackList() {}
-
- void Notify(typename internal::CallbackParamTraits<A1>::ForwardType a1,
- typename internal::CallbackParamTraits<A2>::ForwardType a2) {
- typename internal::CallbackListBase<CallbackType>::Iterator it =
- this->GetIterator();
- CallbackType* cb;
- while ((cb = it.GetNext()) != NULL) {
- cb->Run(a1, a2);
- }
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CallbackList);
-};
-
-template <typename A1, typename A2, typename A3>
-class CallbackList<void(A1, A2, A3)>
- : public internal::CallbackListBase<Callback<void(A1, A2, A3)> > {
- public:
- typedef Callback<void(A1, A2, A3)> CallbackType;
-
- CallbackList() {}
-
- void Notify(typename internal::CallbackParamTraits<A1>::ForwardType a1,
- typename internal::CallbackParamTraits<A2>::ForwardType a2,
- typename internal::CallbackParamTraits<A3>::ForwardType a3) {
- typename internal::CallbackListBase<CallbackType>::Iterator it =
- this->GetIterator();
- CallbackType* cb;
- while ((cb = it.GetNext()) != NULL) {
- cb->Run(a1, a2, a3);
- }
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CallbackList);
-};
-
-template <typename A1, typename A2, typename A3, typename A4>
-class CallbackList<void(A1, A2, A3, A4)>
- : public internal::CallbackListBase<Callback<void(A1, A2, A3, A4)> > {
- public:
- typedef Callback<void(A1, A2, A3, A4)> CallbackType;
-
- CallbackList() {}
-
- void Notify(typename internal::CallbackParamTraits<A1>::ForwardType a1,
- typename internal::CallbackParamTraits<A2>::ForwardType a2,
- typename internal::CallbackParamTraits<A3>::ForwardType a3,
- typename internal::CallbackParamTraits<A4>::ForwardType a4) {
- typename internal::CallbackListBase<CallbackType>::Iterator it =
- this->GetIterator();
- CallbackType* cb;
- while ((cb = it.GetNext()) != NULL) {
- cb->Run(a1, a2, a3, a4);
- }
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CallbackList);
-};
-
-template <typename A1, typename A2, typename A3, typename A4, typename A5>
-class CallbackList<void(A1, A2, A3, A4, A5)>
- : public internal::CallbackListBase<Callback<void(A1, A2, A3, A4, A5)> > {
- public:
- typedef Callback<void(A1, A2, A3, A4, A5)> CallbackType;
-
- CallbackList() {}
-
- void Notify(typename internal::CallbackParamTraits<A1>::ForwardType a1,
- typename internal::CallbackParamTraits<A2>::ForwardType a2,
- typename internal::CallbackParamTraits<A3>::ForwardType a3,
- typename internal::CallbackParamTraits<A4>::ForwardType a4,
- typename internal::CallbackParamTraits<A5>::ForwardType a5) {
- typename internal::CallbackListBase<CallbackType>::Iterator it =
- this->GetIterator();
- CallbackType* cb;
- while ((cb = it.GetNext()) != NULL) {
- cb->Run(a1, a2, a3, a4, a5);
- }
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CallbackList);
-};
-
-template <typename A1, typename A2, typename A3, typename A4, typename A5,
- typename A6>
-class CallbackList<void(A1, A2, A3, A4, A5, A6)>
- : public internal::CallbackListBase<Callback<void(A1, A2, A3, A4, A5,
- A6)> > {
- public:
- typedef Callback<void(A1, A2, A3, A4, A5, A6)> CallbackType;
-
- CallbackList() {}
-
- void Notify(typename internal::CallbackParamTraits<A1>::ForwardType a1,
- typename internal::CallbackParamTraits<A2>::ForwardType a2,
- typename internal::CallbackParamTraits<A3>::ForwardType a3,
- typename internal::CallbackParamTraits<A4>::ForwardType a4,
- typename internal::CallbackParamTraits<A5>::ForwardType a5,
- typename internal::CallbackParamTraits<A6>::ForwardType a6) {
- typename internal::CallbackListBase<CallbackType>::Iterator it =
- this->GetIterator();
- CallbackType* cb;
- while ((cb = it.GetNext()) != NULL) {
- cb->Run(a1, a2, a3, a4, a5, a6);
- }
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CallbackList);
-};
-
-template <typename A1, typename A2, typename A3, typename A4, typename A5,
- typename A6, typename A7>
-class CallbackList<void(A1, A2, A3, A4, A5, A6, A7)>
- : public internal::CallbackListBase<Callback<void(A1, A2, A3, A4, A5, A6,
- A7)> > {
+template <typename... Args>
+class CallbackList<void(Args...)>
+ : public internal::CallbackListBase<Callback<void(Args...)> > {
public:
- typedef Callback<void(A1, A2, A3, A4, A5, A6, A7)> CallbackType;
+ typedef Callback<void(Args...)> CallbackType;
CallbackList() {}
- void Notify(typename internal::CallbackParamTraits<A1>::ForwardType a1,
- typename internal::CallbackParamTraits<A2>::ForwardType a2,
- typename internal::CallbackParamTraits<A3>::ForwardType a3,
- typename internal::CallbackParamTraits<A4>::ForwardType a4,
- typename internal::CallbackParamTraits<A5>::ForwardType a5,
- typename internal::CallbackParamTraits<A6>::ForwardType a6,
- typename internal::CallbackParamTraits<A7>::ForwardType a7) {
+ void Notify(
+ typename internal::CallbackParamTraits<Args>::ForwardType... args) {
typename internal::CallbackListBase<CallbackType>::Iterator it =
this->GetIterator();
CallbackType* cb;
while ((cb = it.GetNext()) != NULL) {
- cb->Run(a1, a2, a3, a4, a5, a6, a7);
+ cb->Run(args...);
}
}
« no previous file with comments | « no previous file | base/callback_list.h.pump » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698