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

Issue 2419673003: Remove base::ObserverList<T>::Iter::GetNext(). (Closed)

Created:
4 years, 2 months ago by dcheng
Modified:
4 years, 2 months ago
CC:
chromium-reviews
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Remove base::ObserverList<T>::Iter::GetNext(). Observer lists now support range-based for loops. BUG=655021 R=danakj@chromium.org TBR=marq@chromium.org,sky@chromium.org Committed: https://crrev.com/c9dd01442c877d2f76cf750e7b52a59caba4b22b Cr-Commit-Position: refs/heads/master@{#425549}

Patch Set 1 #

Total comments: 2

Patch Set 2 : . #

Patch Set 3 : . #

Total comments: 1

Patch Set 4 : Add confusing comments #

Patch Set 5 : One more fix #

Patch Set 6 : ios fix too #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+20 lines, -34 lines) Patch
M base/observer_list.h View 2 chunks +0 lines, -12 lines 0 comments Download
M base/observer_list_threadsafe.h View 1 chunk +2 lines, -5 lines 0 comments Download
M base/observer_list_unittest.cc View 1 2 3 1 chunk +12 lines, -4 lines 1 comment Download
M ios/web/web_state/web_state_impl.mm View 1 2 3 4 5 1 chunk +4 lines, -8 lines 0 comments Download
M ui/base/win/osk_display_manager.cc View 1 2 3 4 1 chunk +2 lines, -5 lines 0 comments Download

Messages

Total messages: 32 (18 generated)
dcheng
Note that this depends on at least 9 other CLs landing first. There may be ...
4 years, 2 months ago (2016-10-12 23:45:18 UTC) #2
danakj
https://codereview.chromium.org/2419673003/diff/1/base/observer_list_unittest.cc File base/observer_list_unittest.cc (left): https://codereview.chromium.org/2419673003/diff/1/base/observer_list_unittest.cc#oldcode898 base/observer_list_unittest.cc:898: TEST(ObserverListTest, AddObserverInTheLastObserve) { Why kill the test?
4 years, 2 months ago (2016-10-13 19:38:13 UTC) #3
loyso (OOO)
https://codereview.chromium.org/2419673003/diff/1/base/observer_list_unittest.cc File base/observer_list_unittest.cc (left): https://codereview.chromium.org/2419673003/diff/1/base/observer_list_unittest.cc#oldcode898 base/observer_list_unittest.cc:898: TEST(ObserverListTest, AddObserverInTheLastObserve) { On 2016/10/13 19:38:13, danakj wrote: > ...
4 years, 2 months ago (2016-10-13 23:33:52 UTC) #5
loyso (OOO)
^ ++it; // everywhere, of course
4 years, 2 months ago (2016-10-13 23:38:10 UTC) #6
loyso (OOO)
One more correction: auto it = observers.begin(); auto end = observers.end(); while(it != end) { ...
4 years, 2 months ago (2016-10-13 23:40:14 UTC) #7
loyso (OOO)
On 2016/10/13 23:40:14, loyso wrote: > auto it = observers.begin(); > auto end = observers.end(); ...
4 years, 2 months ago (2016-10-13 23:45:06 UTC) #8
dcheng
On 2016/10/13 23:45:06, loyso wrote: > On 2016/10/13 23:40:14, loyso wrote: > > auto it ...
4 years, 2 months ago (2016-10-14 21:32:22 UTC) #9
danakj
LGTM https://codereview.chromium.org/2419673003/diff/40001/base/observer_list_unittest.cc File base/observer_list_unittest.cc (right): https://codereview.chromium.org/2419673003/diff/40001/base/observer_list_unittest.cc#newcode911 base/observer_list_unittest.cc:911: ++it; Leave a comment explaining why youre doing ...
4 years, 2 months ago (2016-10-14 21:52:10 UTC) #10
dcheng
TBRing //ios and //ui OWNERS (danakj@ reviewed)
4 years, 2 months ago (2016-10-15 05:38:20 UTC) #23
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2419673003/100001
4 years, 2 months ago (2016-10-15 05:38:38 UTC) #26
commit-bot: I haz the power
Committed patchset #6 (id:100001)
4 years, 2 months ago (2016-10-15 05:43:42 UTC) #28
commit-bot: I haz the power
Patchset 6 (id:??) landed as https://crrev.com/c9dd01442c877d2f76cf750e7b52a59caba4b22b Cr-Commit-Position: refs/heads/master@{#425549}
4 years, 2 months ago (2016-10-15 05:46:14 UTC) #30
loyso (OOO)
https://codereview.chromium.org/2419673003/diff/100001/base/observer_list_unittest.cc File base/observer_list_unittest.cc (right): https://codereview.chromium.org/2419673003/diff/100001/base/observer_list_unittest.cc#newcode909 base/observer_list_unittest.cc:909: while (it != observer_list.end()) { nit: you recreate the ...
4 years, 2 months ago (2016-10-16 23:20:17 UTC) #31
loyso (OOO)
4 years, 2 months ago (2016-10-16 23:32:47 UTC) #32
Message was sent while issue was closed.
On 2016/10/14 21:32:22, dcheng wrote:
> On 2016/10/13 23:45:06, loyso wrote:
> > On 2016/10/13 23:40:14, loyso wrote:
> > > auto it = observers.begin();
> > > auto end = observers.end();
> > > while(it != end) {
> > >   Observer& observer = *it;
> > >   it++;
> > >   observer.Observe();
> > > }
> 
> Personally, I wouldn't see it as a terrible thing that code written like this
> doesn't work 
> 
> > It looks like operator* and operator-> needs EnsureValidIndex if we support
> such
> > loops.
> > If we don't, how can we forbid them?
> 
> Easy: by making it not work =P
Such a crash would be a generic runtime DCHECK failure. We could mention in the
observer_list.h comment, which loop forms we don't support. (Plus a couple of
unit tests, which check that GetCurrent would return nullptr in a specific
situation)

Powered by Google App Engine
This is Rietveld 408576698