power: Rewrite Suspender to use a state machine.

Simplify the Suspender class, making it perform a single
"prepare" step after receiving a suspend request and an
"undo prepare" step when the request is complete.
Previously, it did the prepare/unprepare dance for each
suspend _attempt_ (of which there can be multiple for a
given request in the event of dark resume or a failed
attempt).

Also run the event loop before resuspending from dark resume
in anticipation of later features where the system will
perform additional work while resumed. Suspender previously
had no dark-resume-related tests, so add a bunch of those.

BUG=chromium:384488
TEST=added more tests; also manually tested that dark resume
     works as before on link

Change-Id: I21ff21d18bbcd59a8effeca0e403c227d8045cb6
Reviewed-on: https://chromium-review.googlesource.com/205357
Reviewed-by: Daniel Erat <derat@chromium.org>
Tested-by: Daniel Erat <derat@chromium.org>
Commit-Queue: Daniel Erat <derat@chromium.org>
9 files changed