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

Issue 2805933002: [reland] Allow ObserverListThreadSafe to be used from sequenced tasks. (Closed)

Created:
3 years, 8 months ago by fdoray
Modified:
3 years, 8 months ago
Reviewers:
gab
CC:
chromium-reviews, danakj+watch_chromium.org, vmpstr+watch_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Allow ObserverListThreadSafe to be used from sequenced tasks. This CL is identical to https://codereview.chromium.org/2592143003, except that RemoveObserver() works when called from any sequence (existing code rely on that). Previously, observers could only be added to an ObserverListThreadSafe from single-threaded tasks. Observers were notified on the registration thread. With this CL, observers can also be added to an ObserverListThreadSafe from sequenced tasks. They are notified on the registration sequence. ObserverListThreadSafe behaves almost the same way as before when used from single-threaded tasks. The following things changed: - The order in which observers registered from the same thread are notified is no longer deterministic. - One notification task is posted for each observer rather than one notification task per thread. - If an observer is added to a NOTIFY_ALL ObserverListThreadSafe from a stack of notification dispatches, only the notification on top of the stack is sent to the newly added observer. BUG=675631 Review-Url: https://codereview.chromium.org/2805933002 Cr-Commit-Position: refs/heads/master@{#463345} Committed: https://chromium.googlesource.com/chromium/src/+/6aad314383abc65e773b58a5aa697a84bf42e176

Patch Set 1 : same as https://codereview.chromium.org/2592143003 #

Patch Set 2 : rebase-and-remove-dcheck #

Patch Set 3 : fix-race #

Total comments: 4

Patch Set 4 : CR-gab #

Unified diffs Side-by-side diffs Delta from patch set Stats (+258 lines, -152 lines) Patch
M base/observer_list_threadsafe.h View 1 3 chunks +114 lines, -130 lines 0 comments Download
M base/observer_list_unittest.cc View 1 2 3 8 chunks +144 lines, -22 lines 0 comments Download

Messages

Total messages: 27 (19 generated)
fdoray
PTAL
3 years, 8 months ago (2017-04-10 12:36:27 UTC) #11
gab
lgtm w/ q https://codereview.chromium.org/2805933002/diff/40001/base/observer_list_unittest.cc File base/observer_list_unittest.cc (right): https://codereview.chromium.org/2805933002/diff/40001/base/observer_list_unittest.cc#newcode611 base/observer_list_unittest.cc:611: TaskScheduler::GetInstance()->FlushForTesting(); Why is it racy without ...
3 years, 8 months ago (2017-04-10 16:23:45 UTC) #12
fdoray
https://codereview.chromium.org/2805933002/diff/40001/base/observer_list_unittest.cc File base/observer_list_unittest.cc (right): https://codereview.chromium.org/2805933002/diff/40001/base/observer_list_unittest.cc#newcode611 base/observer_list_unittest.cc:611: TaskScheduler::GetInstance()->FlushForTesting(); On 2017/04/10 16:23:45, gab wrote: > Why is ...
3 years, 8 months ago (2017-04-10 16:34:09 UTC) #13
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/2805933002/40001
3 years, 8 months ago (2017-04-10 16:34:56 UTC) #15
gab
https://codereview.chromium.org/2805933002/diff/40001/base/observer_list_unittest.cc File base/observer_list_unittest.cc (right): https://codereview.chromium.org/2805933002/diff/40001/base/observer_list_unittest.cc#newcode611 base/observer_list_unittest.cc:611: TaskScheduler::GetInstance()->FlushForTesting(); On 2017/04/10 16:34:09, fdoray wrote: > On 2017/04/10 ...
3 years, 8 months ago (2017-04-10 16:36:14 UTC) #16
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/2805933002/60001
3 years, 8 months ago (2017-04-10 17:44:33 UTC) #23
commit-bot: I haz the power
Committed patchset #4 (id:60001) as https://chromium.googlesource.com/chromium/src/+/6aad314383abc65e773b58a5aa697a84bf42e176
3 years, 8 months ago (2017-04-10 18:59:20 UTC) #26
fdoray
3 years, 8 months ago (2017-04-10 19:07:16 UTC) #27
Message was sent while issue was closed.
https://codereview.chromium.org/2805933002/diff/40001/base/observer_list_unit...
File base/observer_list_unittest.cc (right):

https://codereview.chromium.org/2805933002/diff/40001/base/observer_list_unit...
base/observer_list_unittest.cc:611:
TaskScheduler::GetInstance()->FlushForTesting();
On 2017/04/10 16:36:14, gab wrote:
> On 2017/04/10 16:34:09, fdoray wrote:
> > On 2017/04/10 16:23:45, gab wrote:
> > > Why is it racy without this? Doesn't the ScopedTaskScheduler do this?
> > 
> > Yes. But without this, a task may still be waiting on |barrier| when
|barrier|
> > is destroyed (because |barrier| is destroyed before
> |scoped_task_environment|).
> 
> Hmmm ok, then flip the order of their definition on the stack at beginning of
> test w/ comment?

Done.

Powered by Google App Engine
This is Rietveld 408576698