shill: use ResultAggregator for device suspend actions
Use ResultAggregator to have manager asynchronously execute each device's
suspend actions before a system suspend takes place. The previous
implementation executed these suspend actions synchronously and used
a HookTable for other termination/suspend actions. This implementation does
not change the use of the HookTable for termination action, but
uses only a ResultAggregator to wait for asynchronous suspend actions.
Manager now creates a ResultAggregator in OnSuspendImminent() and passes
a callback to every device as an argument to OnBeforeSuspend(). Each
device then performs synchronous actions and/or posts asychronous tasks
in OnBeforeSuspend(), and is responsible for running the received
callback after completing these actions.
Also:
- rename RetrySetWakeOnPacketConnection to RetryApplyWakeOnWiFiSettings
for consistency.
- add detailed documentation to result_aggregator.h explaining and
stating the conventions to be followed when using ResultAggregator.
- remove TerminationActionReason from metrics and add separate
Termination action and Suspend action metrics in preparation for
complete splitting of termination and suspend action codepaths.
BUG=chromium:390668
CQ-DEPEND=CL:223098
TEST='P2_TEST_FILTER="shill::*" FEATURES="test" USE="clang asan"
emerge-samus shill' succeeds.
Change-Id: I5a9d9039669a822e0cb82bf6784522f1ce86a966
Reviewed-on: https://chromium-review.googlesource.com/218551
Reviewed-by: Samuel Tan <samueltan@chromium.org>
Tested-by: Samuel Tan <samueltan@chromium.org>
Commit-Queue: Samuel Tan <samueltan@chromium.org>
diff --git a/shill_daemon.cc b/shill_daemon.cc
index 9a55556..49f056f 100644
--- a/shill_daemon.cc
+++ b/shill_daemon.cc
@@ -65,8 +65,7 @@
void Daemon::Quit() {
SLOG(Daemon, 1) << "Starting termination actions.";
if (!manager_->RunTerminationActionsAndNotifyMetrics(
- Bind(&Daemon::TerminationActionsCompleted, Unretained(this)),
- Metrics::kTerminationActionReasonTerminate)) {
+ Bind(&Daemon::TerminationActionsCompleted, Unretained(this)))) {
SLOG(Daemon, 1) << "No termination actions were run";
StopAndReturnToMain();
}
@@ -74,8 +73,7 @@
void Daemon::TerminationActionsCompleted(const Error &error) {
SLOG(Daemon, 1) << "Finished termination actions. Result: " << error;
- metrics_->NotifyTerminationActionsCompleted(
- Metrics::kTerminationActionReasonTerminate, error.IsSuccess());
+ metrics_->NotifyTerminationActionsCompleted(error.IsSuccess());
// Daemon::TerminationActionsCompleted() should not directly call
// Daemon::Stop(). Otherwise, it could lead to the call sequence below. That