New issue
Advanced search Search tips

Issue 634916 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Oct 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Feature

Blocked on:
issue 100121



Sign in to add a comment

base::ObserverList should have a callback for each item in the list

Project Member Reported by ymalik@chromium.org, Aug 5 2016

Issue description

Probably something like this:
template<typename Callback> ObserverList::forEach(Callback)

This is useful for the following reasons:
- FOR_EACH_OBSERVER(ObserverType, observer_list, func) doesn't allow you to do things before calling func on each ObserverType.
- macros make it difficult to trace the control flow.
 
loyso suggested making the ObserverList::Iterator follow the C++ iterator pattern so you could use "for (auto& observer : observer_list)" which would be nicer than a lambda.

Comment 2 by loyso@chromium.org, Sep 14 2016

Cc: -loyso@chromium.org
Owner: loyso@chromium.org
Status: Started (was: Untriaged)

Comment 3 by loyso@chromium.org, Sep 14 2016

Components: Internals>Core
Labels: -Type-Bug Hotlist-CodeHealth OS-All Type-Feature

Comment 4 by loyso@chromium.org, Sep 14 2016

Blocking: 592873

Comment 5 by loyso@chromium.org, Sep 30 2016

Blockedon: 100121

Comment 6 by loyso@chromium.org, Oct 4 2016

Blocking: -592873
Project Member

Comment 8 by bugdroid1@chromium.org, Oct 11 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/29025b60361ec76cf02bab720703c66ae8047be9

commit 29025b60361ec76cf02bab720703c66ae8047be9
Author: loyso <loyso@chromium.org>
Date: Tue Oct 11 06:51:33 2016

Base ObserverList: Add basic support for standard C++ iterators.

Also add a support for const_iterator.

The range-based for loop support follows for free.

See the use case in the dependent CL.

BUG= 634916 

Review-Url: https://codereview.chromium.org/2340583005
Cr-Commit-Position: refs/heads/master@{#424381}

[modify] https://crrev.com/29025b60361ec76cf02bab720703c66ae8047be9/base/observer_list.h
[modify] https://crrev.com/29025b60361ec76cf02bab720703c66ae8047be9/base/observer_list_unittest.cc

Comment 10 by loyso@chromium.org, Oct 12 2016

Status: Fixed (was: Started)

Comment 11 by loyso@chromium.org, Oct 18 2016

Related: ObserverList expands to much machine code with gcc
https://bugs.chromium.org/p/chromium/issues/detail?id=394311

Sign in to add a comment