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

Side by Side Diff: base/observer_list_unittest.cc

Issue 2419673003: Remove base::ObserverList<T>::Iter::GetNext(). (Closed)
Patch Set: . Created 4 years, 2 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 | « base/observer_list_threadsafe.h ('k') | 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) 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
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
OLDNEW
« no previous file with comments | « base/observer_list_threadsafe.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698