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

Side by Side Diff: base/callback_list.cc

Issue 22877038: Add a CallbackRegistry class to base/ to manage callbacks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better documentation of test invariants Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698