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

Side by Side Diff: base/observer_list.h

Issue 2137183003: Add support for dependent types in FOR_EACH_OBSERVER (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698