buffet: Add State property to Manager BUG=chromium:356368 TEST=Modified buffet_BasicDBusAPI verifies that Get and GetAll work. Change-Id: I3af7cbbdee6d47405786420b0d00a71b0f883ec7 Reviewed-on: https://chromium-review.googlesource.com/192002 Tested-by: Christopher Wiley <wiley@chromium.org> Reviewed-by: Chris Sosa <sosa@chromium.org> Commit-Queue: Christopher Wiley <wiley@chromium.org>
diff --git a/buffet/manager.cc b/buffet/manager.cc index 4daa9fc..e0a9b7a 100644 --- a/buffet/manager.cc +++ b/buffet/manager.cc
@@ -28,9 +28,16 @@ dbus_constants::kManagerUpdateStateMethod, base::Bind(&Manager::HandleUpdateState, base::Unretained(this))); + properties_.reset(new Properties(exported_object)); + // TODO(wiley): Initialize all properties appropriately before claiming + // the properties interface. + properties_->state_.SetValue("{}"); + properties_->ClaimPropertiesInterface(); } Manager::~Manager() { + // Prevent the properties object from making calls to the exported object. + properties_.reset(nullptr); // Unregister ourselves from the Bus. This prevents the bus from calling // our callbacks in between the Manager's death and the bus unregistering // our exported object on shutdown. Unretained makes no promises of memory @@ -89,7 +96,8 @@ } LOG(INFO) << "Received call to Manager.UpdateState()"; - // TODO(wiley): Do something with these parameters to update state. + // TODO(wiley): Merge json state blobs intelligently. + properties_->state_.SetValue(json_state_fragment); // Send back our response. return dbus::Response::FromMethodCall(method_call);