Mojo: Armed Watchers

Changes the Watcher C API as described in this post:
https://groups.google.com/a/chromium.org/forum/#!topic/chromium-mojo/UcA97R4IznI

Makes watchers a first-class non-transferable handle type in Mojo,
allows multiple distinct events to be watched by a single watcher,
and requires watchers to be explicitly armed before a notification
will fire. Also now allows for cancellation (and watcher closure)
from within notification callbacks, simplifying cancellation logic
and avoiding any possibility of EDK deadlocks caused by cancellations,
during watch notification.

Updates the Watcher class in mojo/public/cpp/system to reflect the
new model, adding an explicit ArmingPolicy to allow users to select
manual or automatic arming. Also renames it to SimpleWatcher to
adequately convey that this is only a simplified helper class that
does not utilize the full power of watchers.

Automatic arming provides imperfect edge-triggered behavior, which is
still an improvement over the old behavior in many cases.

Manual arming is used in the bindings Connector to ensure that all
messages are flushed from a pipe before control returns from a
handle-ready notification, and is also now used for Watchers which
watch a data pipe handle.

Other users of the Watcher C API (namely Blink's MojoWatcher and
content's MessagePort) have also been adapted to the new API.

BUG=693595,700171

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


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