| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_CALLBACK_LIST_H_ | 5 #ifndef BASE_CALLBACK_LIST_H_ |
| 6 #define BASE_CALLBACK_LIST_H_ | 6 #define BASE_CALLBACK_LIST_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/callback_internal.h" | |
| 12 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 13 #include "base/logging.h" | 12 #include "base/logging.h" |
| 14 #include "base/macros.h" | 13 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 16 | 15 |
| 17 // OVERVIEW: | 16 // OVERVIEW: |
| 18 // | 17 // |
| 19 // A container for a list of callbacks. Unlike a normal STL vector or list, | 18 // A container for a list of callbacks. Unlike a normal STL vector or list, |
| 20 // this container can be modified during iteration without invalidating the | 19 // this container can be modified during iteration without invalidating the |
| 21 // iterator. It safely handles the case of a callback removing itself | 20 // iterator. It safely handles the case of a callback removing itself |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 template <typename Sig> class CallbackList; | 203 template <typename Sig> class CallbackList; |
| 205 | 204 |
| 206 template <typename... Args> | 205 template <typename... Args> |
| 207 class CallbackList<void(Args...)> | 206 class CallbackList<void(Args...)> |
| 208 : public internal::CallbackListBase<Callback<void(Args...)> > { | 207 : public internal::CallbackListBase<Callback<void(Args...)> > { |
| 209 public: | 208 public: |
| 210 typedef Callback<void(Args...)> CallbackType; | 209 typedef Callback<void(Args...)> CallbackType; |
| 211 | 210 |
| 212 CallbackList() {} | 211 CallbackList() {} |
| 213 | 212 |
| 214 void Notify( | 213 template <typename... RunArgs> |
| 215 typename internal::CallbackParamTraits<Args>::ForwardType... args) { | 214 void Notify(RunArgs&&... args) { |
| 216 typename internal::CallbackListBase<CallbackType>::Iterator it = | 215 typename internal::CallbackListBase<CallbackType>::Iterator it = |
| 217 this->GetIterator(); | 216 this->GetIterator(); |
| 218 CallbackType* cb; | 217 CallbackType* cb; |
| 219 while ((cb = it.GetNext()) != NULL) { | 218 while ((cb = it.GetNext()) != NULL) { |
| 220 cb->Run(args...); | 219 cb->Run(args...); |
| 221 } | 220 } |
| 222 } | 221 } |
| 223 | 222 |
| 224 private: | 223 private: |
| 225 DISALLOW_COPY_AND_ASSIGN(CallbackList); | 224 DISALLOW_COPY_AND_ASSIGN(CallbackList); |
| 226 }; | 225 }; |
| 227 | 226 |
| 228 } // namespace base | 227 } // namespace base |
| 229 | 228 |
| 230 #endif // BASE_CALLBACK_LIST_H_ | 229 #endif // BASE_CALLBACK_LIST_H_ |
| OLD | NEW |