Refactor AlarmTimer to report error to the caller.
This is to address the comment https://chromium-review.googlesource.com/c/aosp/platform/external/libchrome/+/1387893/2/components/timers/alarm_timer_chromeos.h#45 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. BUG=None TEST=Build and run components_unittests --gtest_filter=AlarmTimerTest*. Run try. Change-Id: Ieb9660335120565ccff7f192d7a8192ca1e59ebc Reviewed-on: https://chromium-review.googlesource.com/c/1411356Reviewed-by:Ryo Hashimoto <hashimoto@chromium.org> Reviewed-by:
Dmitry Titov <dimich@chromium.org> Reviewed-by:
Dan Erat <derat@chromium.org> Commit-Queue: Hidehiko Abe <hidehiko@chromium.org> Cr-Commit-Position: refs/heads/master@{#626151}
Showing
Please register or sign in to comment