| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 229 } |
| 230 | 230 |
| 231 bool might_have_observers() const { | 231 bool might_have_observers() const { |
| 232 return ObserverListBase<ObserverType>::size() != 0; | 232 return ObserverListBase<ObserverType>::size() != 0; |
| 233 } | 233 } |
| 234 }; | 234 }; |
| 235 | 235 |
| 236 #define FOR_EACH_OBSERVER(ObserverType, observer_list, func) \ | 236 #define FOR_EACH_OBSERVER(ObserverType, observer_list, func) \ |
| 237 do { \ | 237 do { \ |
| 238 if ((observer_list).might_have_observers()) { \ | 238 if ((observer_list).might_have_observers()) { \ |
| 239 base::ObserverListBase<ObserverType>::Iterator it_inside_observer_macro( \ | 239 typename base::ObserverListBase<ObserverType>::Iterator \ |
| 240 &observer_list); \ | 240 it_inside_observer_macro(&observer_list); \ |
| 241 ObserverType* obs; \ | 241 ObserverType* obs; \ |
| 242 while ((obs = it_inside_observer_macro.GetNext()) != nullptr) \ | 242 while ((obs = it_inside_observer_macro.GetNext()) != nullptr) \ |
| 243 obs->func; \ | 243 obs->func; \ |
| 244 } \ | 244 } \ |
| 245 } while (0) | 245 } while (0) |
| 246 | 246 |
| 247 } // namespace base | 247 } // namespace base |
| 248 | 248 |
| 249 #endif // BASE_OBSERVER_LIST_H_ | 249 #endif // BASE_OBSERVER_LIST_H_ |
| OLD | NEW |