Skip to content
  • fdoray's avatar
    Migrate to base::FileDescriptionWatcher in dbus/bus.cc. · ebc379c0
    fdoray authored
    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-Commit-Position: refs/heads/master@{#465215}
    ebc379c0