OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_OBSERVER_LIST_H__ | 5 #ifndef BASE_OBSERVER_LIST_H__ |
6 #define BASE_OBSERVER_LIST_H__ | 6 #define BASE_OBSERVER_LIST_H__ |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <limits> | 9 #include <limits> |
10 #include <vector> | 10 #include <vector> |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 ObserverListBase<ObserverType>::Compact(); | 196 ObserverListBase<ObserverType>::Compact(); |
197 DCHECK_EQ(ObserverListBase<ObserverType>::size(), 0U); | 197 DCHECK_EQ(ObserverListBase<ObserverType>::size(), 0U); |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 bool might_have_observers() const { | 201 bool might_have_observers() const { |
202 return ObserverListBase<ObserverType>::size() != 0; | 202 return ObserverListBase<ObserverType>::size() != 0; |
203 } | 203 } |
204 }; | 204 }; |
205 | 205 |
206 #define FOR_EACH_OBSERVER(ObserverType, observer_list, func) \ | 206 #define FOR_EACH_OBSERVER(ObserverType, observer_list, func) \ |
207 do { \ | 207 do { \ |
208 if ((observer_list).might_have_observers()) { \ | 208 if ((observer_list).might_have_observers()) { \ |
209 ObserverListBase<ObserverType>::Iterator it(observer_list); \ | 209 ObserverListBase<ObserverType>::Iterator \ |
210 ObserverType* obs; \ | 210 it_inside_observer_macro(observer_list); \ |
211 while ((obs = it.GetNext()) != NULL) \ | 211 ObserverType* obs; \ |
212 obs->func; \ | 212 while ((obs = it_inside_observer_macro.GetNext()) != NULL) \ |
213 } \ | 213 obs->func; \ |
| 214 } \ |
214 } while (0) | 215 } while (0) |
215 | 216 |
216 #endif // BASE_OBSERVER_LIST_H__ | 217 #endif // BASE_OBSERVER_LIST_H__ |
OLD | NEW |