Index: base/callback_list.cc |
diff --git a/base/callback_list.cc b/base/callback_list.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..283b6cf0b96d2d6a63c5e1bcf9fe2b01e53cbc3c |
--- /dev/null |
+++ b/base/callback_list.cc |
@@ -0,0 +1,33 @@ |
+#include "base/callback_list.h" |
awong
2013/09/04 18:48:21
Missing copyright.
Cait (Slow)
2013/09/04 22:09:25
Done.
|
+ |
+namespace base { |
+ |
+CallbackList::CallbackList(CallbackNotificationType type) |
+ : list_impl_(new base::internal::CallbackListImpl(type)) {} |
+ |
+CallbackList::~CallbackList() {} |
+ |
+base::Closure CallbackList::Add(const base::Closure& cb) { |
+ DCHECK(!cb.is_null()); |
+ return list_impl_->AddCallback(new base::Closure(cb)); |
+} |
+ |
+void CallbackList::Run() { |
+ if (might_have_callbacks()) { |
+ internal::CallbackListImpl::Iterator it(list_impl_->GetWeakPtr()); |
+ base::Closure* cb; |
+ while((cb = static_cast<base::Closure*>(it.GetNext())) != NULL) { |
+ cb->Run(); |
+ } |
+ } |
+} |
+ |
+void CallbackList::Clear() { |
+ list_impl_->Clear(); |
+} |
+ |
+bool CallbackList::might_have_callbacks() { |
+ return list_impl_->might_have_callbacks(); |
+} |
+ |
+} // namespace base |
awong
2013/09/04 18:48:21
} // namespace base
Cait (Slow)
2013/09/04 22:09:25
Done.
|