Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/observer_list.h" | 5 #include "base/observer_list.h" |
| 6 #include "base/observer_list_threadsafe.h" | 6 #include "base/observer_list_threadsafe.h" |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 898 TEST(ObserverListTest, AddObserverInTheLastObserve) { | 898 TEST(ObserverListTest, AddObserverInTheLastObserve) { |
| 899 using FooList = ObserverList<Foo>; | 899 using FooList = ObserverList<Foo>; |
| 900 FooList observer_list; | 900 FooList observer_list; |
| 901 | 901 |
| 902 AddInObserve<FooList> a(&observer_list); | 902 AddInObserve<FooList> a(&observer_list); |
| 903 Adder b(-1); | 903 Adder b(-1); |
| 904 | 904 |
| 905 a.SetToAdd(&b); | 905 a.SetToAdd(&b); |
| 906 observer_list.AddObserver(&a); | 906 observer_list.AddObserver(&a); |
| 907 | 907 |
| 908 FooList::Iterator it(&observer_list); | 908 auto it = observer_list.begin(); |
| 909 Foo* foo; | 909 while (it != observer_list.end()) { |
| 910 while ((foo = it.GetNext()) != nullptr) | 910 auto& observer = *it; |
| 911 foo->Observe(10); | 911 ++it; |
|
danakj
2016/10/14 21:52:10
Leave a comment explaining why youre doing this ++
| |
| 912 observer.Observe(10); | |
| 913 } | |
| 912 | 914 |
| 913 EXPECT_EQ(-10, b.total); | 915 EXPECT_EQ(-10, b.total); |
| 914 } | 916 } |
| 915 | 917 |
| 916 } // namespace base | 918 } // namespace base |
| OLD | NEW |