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_REGISTRY_H_ | 5 #ifndef BASE_CALLBACK_REGISTRY_H_ |
6 #define BASE_CALLBACK_REGISTRY_H_ | 6 #define BASE_CALLBACK_REGISTRY_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 ~Iterator() { | 118 ~Iterator() { |
119 if (list_ && --list_->active_iterator_count_ == 0) { | 119 if (list_ && --list_->active_iterator_count_ == 0) { |
120 list_->Compact(); | 120 list_->Compact(); |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 CallbackType* GetNext() { | 124 CallbackType* GetNext() { |
125 while ((list_iter_ != list_->callbacks_.end()) && list_iter_->is_null()) | 125 while ((list_iter_ != list_->callbacks_.end()) && list_iter_->is_null()) |
126 ++list_iter_; | 126 ++list_iter_; |
127 | 127 |
128 CallbackType* cb = | 128 CallbackType* cb = NULL; |
129 list_iter_ != list_->callbacks_.end() ? &(*list_iter_) : NULL; | 129 if (list_iter_ != list_->callbacks_.end()) { |
130 ++list_iter_; | 130 cb = &(*list_iter_); |
| 131 ++list_iter_; |
| 132 } |
131 return cb; | 133 return cb; |
132 } | 134 } |
133 | 135 |
134 private: | 136 private: |
135 CallbackRegistryBase<CallbackType>* list_; | 137 CallbackRegistryBase<CallbackType>* list_; |
136 typename std::list<CallbackType>::iterator list_iter_; | 138 typename std::list<CallbackType>::iterator list_iter_; |
137 }; | 139 }; |
138 | 140 |
139 CallbackRegistryBase() | 141 CallbackRegistryBase() |
140 : active_iterator_count_(0) {} | 142 : active_iterator_count_(0) {} |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 } | 207 } |
206 } | 208 } |
207 | 209 |
208 private: | 210 private: |
209 DISALLOW_COPY_AND_ASSIGN(CallbackRegistry); | 211 DISALLOW_COPY_AND_ASSIGN(CallbackRegistry); |
210 }; | 212 }; |
211 | 213 |
212 } // namespace base | 214 } // namespace base |
213 | 215 |
214 #endif // BASE_CALLBACK_REGISTRY_H_ | 216 #endif // BASE_CALLBACK_REGISTRY_H_ |
OLD | NEW |