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}


CrOS-Libchrome-Original-Commit: 6aad314383abc65e773b58a5aa697a84bf42e176
2 files changed
tree: b6a09a05f1364ce69832df93d80729b3257b55d2
  1. base/
  2. build/
  3. components/
  4. dbus/
  5. device/
  6. ipc/
  7. mojo/
  8. testing/
  9. third_party/
  10. ui/