Refactor AlarmTimer to report error to the caller.
This is to address the comment
Instead of just upstreaming it, which exposes a method unused in Chromium,
this CL introduces Create() factory method and drops the code to
fallback in case of timerfd_create failure.
Now, a caller should check whether Create() returns null or not.
In case of null, to keep the previous behavior, the caller can
create an instance of the parent class.
Along with the change, in order to run unittest for the class
without capability CAP_WAKE_ALARM, this CL also introduces CreateForTesting().
We used to test just fall-back code paths.
In addition, this CL fixes the FD leak on destruction.
TEST=Build and run components_unittests --gtest_filter=AlarmTimerTest*. Run try.
Reviewed-by: Ryo Hashimoto <firstname.lastname@example.org>
Reviewed-by: Dmitry Titov <email@example.com>
Reviewed-by: Dan Erat <firstname.lastname@example.org>
Commit-Queue: Hidehiko Abe <email@example.com>
3 files changed