buffet: Expose RegistrationStatus over DBus
This new property lets applications monitor Buffet's connection to
cloud services.
BUG=brillo:16
TEST=Unittests, buffet_Registration has been expanded appropriately.
CQ-DEPEND=CL:*199337
Change-Id: I30253e8199cb65068a74dd8b780a8ab0954bf9fa
Reviewed-on: https://chromium-review.googlesource.com/250011
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Christopher Wiley <wiley@chromium.org>
Commit-Queue: Christopher Wiley <wiley@chromium.org>
diff --git a/buffet/manager.cc b/buffet/manager.cc
index a1457c4..2e96fbc 100644
--- a/buffet/manager.cc
+++ b/buffet/manager.cc
@@ -63,12 +63,16 @@
// TODO(avakulenko): Figure out security implications of storing
// device info state data unencrypted.
device_info_ = std::unique_ptr<DeviceRegistrationInfo>(
- new DeviceRegistrationInfo(command_manager_,
- state_manager_,
- std::move(config_store),
- chromeos::http::Transport::CreateDefault(),
- std::move(state_store)));
+ new DeviceRegistrationInfo(
+ command_manager_,
+ state_manager_,
+ std::move(config_store),
+ chromeos::http::Transport::CreateDefault(),
+ std::move(state_store),
+ base::Bind(&Manager::OnRegistrationStatusChange,
+ base::Unretained(this))));
device_info_->Load();
+ OnRegistrationStatusChange(device_info_->GetRegistrationStatus());
// Wait a significant amount of time for local daemons to publish their
// state to Buffet before publishing it to the cloud.
// TODO(wiley) We could do a lot of things here to either expose this
@@ -218,4 +222,8 @@
return message;
}
+void Manager::OnRegistrationStatusChange(RegistrationStatus status) {
+ dbus_adaptor_.SetStatus(StatusToString(status));
+}
+
} // namespace buffet