OLD | NEW |
---|---|
(Empty) | |
1 #include "base/callback_list.h" | |
awong
2013/09/04 18:48:21
Missing copyright.
Cait (Slow)
2013/09/04 22:09:25
Done.
| |
2 | |
3 namespace base { | |
4 | |
5 CallbackList::CallbackList(CallbackNotificationType type) | |
6 : list_impl_(new base::internal::CallbackListImpl(type)) {} | |
7 | |
8 CallbackList::~CallbackList() {} | |
9 | |
10 base::Closure CallbackList::Add(const base::Closure& cb) { | |
11 DCHECK(!cb.is_null()); | |
12 return list_impl_->AddCallback(new base::Closure(cb)); | |
13 } | |
14 | |
15 void CallbackList::Run() { | |
16 if (might_have_callbacks()) { | |
17 internal::CallbackListImpl::Iterator it(list_impl_->GetWeakPtr()); | |
18 base::Closure* cb; | |
19 while((cb = static_cast<base::Closure*>(it.GetNext())) != NULL) { | |
20 cb->Run(); | |
21 } | |
22 } | |
23 } | |
24 | |
25 void CallbackList::Clear() { | |
26 list_impl_->Clear(); | |
27 } | |
28 | |
29 bool CallbackList::might_have_callbacks() { | |
30 return list_impl_->might_have_callbacks(); | |
31 } | |
32 | |
33 } // namespace base | |
awong
2013/09/04 18:48:21
} // namespace base
Cait (Slow)
2013/09/04 22:09:25
Done.
| |
OLD | NEW |