• Nick Diego Yamane's avatar
    Implement file descriptor watching API in MessagePumpGlib · 58914197
    Nick Diego Yamane authored
    The main user of GLib MessagePump implementation is Aura/X11, while Ozone-based
    ports use mainly libevent version, which exposes WatchFileDescriptor API that
    is used by higher level components through MessageLoop[Current]For{UI,IO}
    interfaces. Currently, there's no such API in MessagePumpGlib.
    
    The motivation here is to make MessageLoopCurrent API usage transparent,
    regardless which message pump is used in UI thread. This benefits X11 migration
    to Ozone on Linux desktop, which (just like Aura/X11) must integrate with Gtk,
    so GLib-based loop in browser's main thread is a natural path.
    
    So, this CL implements the aforementioned API in GLib MessageLoop following the
    same design, assumptions and overall structure as its original libevent-based
    version.
    
    As a follow-up, https://crrev.com/c/1730972 refactors code using
    MessagePumpLibevent::{FdWatchController,FdWatcher} directly, replacing them by
    MessageLoopCurrent*ForUI counterparts as well as refactoring
    X11EventSourceLibevent (which Implementation has been used as reference for
    this CL) in the same direction, so in the end it has no libevent specific code
    and the build-time glib/libevent switch (use_glib gn var) is possible.
    
    Bug: 988094, 789065
    Test: base_unittests (MessagePumpGLibFdWatchTest.*)
    Change-Id: I843ab924d18c08b6384e0716bc36c4f5f8482fa3
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1731031
    Commit-Queue: Nick Yamane <nickdiego@igalia.com>
    Reviewed-by: default avatarkylechar <kylechar@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#685245}
    58914197
message_pump_glib.h 5.08 KB