Skip to content

Commit

Permalink
base: Erase unused FOR_EACH_OBSERVER macro.
Browse files Browse the repository at this point in the history
We use the range based for loop from now.

BUG=655021

Review-Url: https://codereview.chromium.org/2451933003
Cr-Commit-Position: refs/heads/master@{#427623}
  • Loading branch information
loyso authored and Commit bot committed Oct 26, 2016
1 parent 5f1ebc7 commit 802c213
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 18 deletions.
9 changes: 0 additions & 9 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,6 @@
True,
(),
),
(
r'FOR_EACH_OBSERVER(',
(
'Use range-based for loops to iterate through base::ObserverList, e.g.',
' for (auto& observer : observers) { observer.Observe(); }',
),
True,
(),
),
(
r'STLDeleteContainerPointers', # http://crbug.com/555865
(
Expand Down
2 changes: 1 addition & 1 deletion base/android/java/src/org/chromium/base/ObserverList.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* The implementation (and the interface) is heavily influenced by the C++ ObserverList.
* Notable differences:
* - The iterator implements NOTIFY_EXISTING_ONLY.
* - The FOR_EACH_OBSERVER closure is left to the clients to implement in terms of iterator().
* - The range-based for loop is left to the clients to implement in terms of iterator().
* <p/>
* This class is not threadsafe. Observers MUST be added, removed and will be notified on the same
* thread this is created.
Expand Down
7 changes: 0 additions & 7 deletions base/observer_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,6 @@ class ObserverList : public ObserverListBase<ObserverType> {
}
};

// Deprecated. Use the range-based for loop instead.
#define FOR_EACH_OBSERVER(ObserverType, observer_list, func) \
do { \
for (ObserverType & o : observer_list) \
o.func; \
} while (0)

} // namespace base

#endif // BASE_OBSERVER_LIST_H_
3 changes: 2 additions & 1 deletion base/observer_list_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,8 @@ TEST(ObserverListTest, IteratorOutlivesList) {
ListDestructor a(observer_list);
observer_list->AddObserver(&a);

FOR_EACH_OBSERVER(Foo, *observer_list, Observe(0));
for (auto& observer : *observer_list)
observer.Observe(0);
// If this test fails, there'll be Valgrind errors when this function goes out
// of scope.
}
Expand Down

0 comments on commit 802c213

Please sign in to comment.