Remove base::ObserverList<T>::Iter::GetNext().
Observer lists now support range-based for loops.
BUG=655021
[email protected]
[email protected],[email protected]
Review-Url: https://codereview.chromium.org/2419673003
Cr-Commit-Position: refs/heads/master@{#425549}
diff --git a/base/observer_list_unittest.cc b/base/observer_list_unittest.cc
index 299a33f..96156531 100644
--- a/base/observer_list_unittest.cc
+++ b/base/observer_list_unittest.cc
@@ -905,10 +905,18 @@
a.SetToAdd(&b);
observer_list.AddObserver(&a);
- FooList::Iterator it(&observer_list);
- Foo* foo;
- while ((foo = it.GetNext()) != nullptr)
- foo->Observe(10);
+ auto it = observer_list.begin();
+ while (it != observer_list.end()) {
+ auto& observer = *it;
+ // Intentionally increment the iterator before calling Observe(). The
+ // ObserverList starts with only one observer, and it == observer_list.end()
+ // should be true after the next line.
+ ++it;
+ // However, the first Observe() call will add a second observer: at this
+ // point, it != observer_list.end() should be true, and Observe() should be
+ // called on the newly added observer on the next iteration of the loop.
+ observer.Observe(10);
+ }
EXPECT_EQ(-10, b.total);
}