libchromeos: MessageLoop implementation using base::MessageLoopForIO.

The new chromeos::BaseMessageLoop implementation uses the existing
base::MessageLoopForIO implementation, that in the Linux and ChromeOS
context uses base::MessagePumpLibevent, a libevent based implementation.

This chromeos::MessageLoop allows to mix calls to base::MessageLoopForIO
and chromeos::MessageLoop with few limitations. This is useful when using
other code in libchrome that already interacts with libchrome's
MessageLoopForIO.

Among the limitations, the support for canceling a task will not free
the memory associated with the delayed event until it actually fires.
Also, base::MessagePumpLibevent uses epoll(7) which doesn't support
watching for file descriptors that would not naturally block (such as
regular files). Attempting to watch for those file descriptors will
return kTaskIdNull in this implementation, but would work on
chromeos::GlibMessageLoop.

This patch moves most of chromeos::GlibMessageLoop existing tests to a
common chromeos::MessageLoop test that runs for both implementations.

BUG=chromium:506052
TEST=Added unittests.

Change-Id: I4553d149511806ed599fa2847af4372985456106
Reviewed-on: https://chromium-review.googlesource.com/285217
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Trybot-Ready: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
9 files changed