Migrate to base::FileDescriptionWatcher in dbus/bus.cc.

Before this CL, dbus::Bus::OnAddWatch called
MessageLoopForIO::current()->WatchFileDescriptor(), which is invalid from a
non-MessageLoopForIO thread. This caused a crash when dbus::Bus::OnAddWatch
was called from a TaskScheduler thread.

With this CL, dbus::Bus::OnAddWatch uses
base::FileDescriptorWatcher::WatchReadable/Writable instead of
MessageLoopForIO::current()->WatchFileDescriptor(). This works from
base::Threads that run a MessageLoopForIO and TaskScheduler threads.

This CL also instantiates a base::FileDescriptorWatcher in tests that use
dbus::Bus::OnAddWatch. This is required to allow usage of
base::FileDescriptorWatcher::WatchReadable/Writable on the main thread
of a test.

BUG=708142

Review-Url: https://codereview.chromium.org/2808983002
Cr-Original-Commit-Position: refs/heads/master@{#465215}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: ebc379c0d84a4c0447bcc95317c85ffee5c9025e
3 files changed