buffet: Added base.updateDeviceInfo handler
base.updateDeviceInfo changes 'name', 'description' and 'location'
properties of the device resource.
BUG=brillo:697
TEST='FEATURES=test emerge-storm buffet'
Change-Id: Id1b349c97d2132117cdf803dda8e39d25c64621a
Reviewed-on: https://chromium-review.googlesource.com/270787
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/commands/command_manager.cc b/buffet/commands/command_manager.cc
index cbaaeca..d0743de 100644
--- a/buffet/commands/command_manager.cc
+++ b/buffet/commands/command_manager.cc
@@ -134,4 +134,14 @@
return true;
}
+void CommandManager::AddOnCommandAddedCallback(
+ const CommandQueue::Callback& callback) {
+ command_queue_.AddOnCommandAddedCallback(callback);
+}
+
+void CommandManager::AddOnCommandRemovedCallback(
+ const CommandQueue::Callback& callback) {
+ command_queue_.AddOnCommandRemovedCallback(callback);
+}
+
} // namespace buffet
diff --git a/buffet/commands/command_manager.h b/buffet/commands/command_manager.h
index 88ebca7..9a891ba 100644
--- a/buffet/commands/command_manager.h
+++ b/buffet/commands/command_manager.h
@@ -98,6 +98,12 @@
CommandDefinition::Visibility visibility,
chromeos::ErrorPtr* error);
+ // Adds notifications callback for a new command being added to the queue.
+ void AddOnCommandAddedCallback(const CommandQueue::Callback& callback);
+
+ // Adds notifications callback for a command being removed from the queue.
+ void AddOnCommandRemovedCallback(const CommandQueue::Callback& callback);
+
private:
CommandDictionary base_dictionary_; // Base/std command definitions/schemas.
CommandDictionary dictionary_; // Command definitions/schemas.
diff --git a/buffet/commands/command_queue.cc b/buffet/commands/command_queue.cc
index 614261e..f4cda60 100644
--- a/buffet/commands/command_queue.cc
+++ b/buffet/commands/command_queue.cc
@@ -15,6 +15,9 @@
void CommandQueue::AddOnCommandAddedCallback(const Callback& callback) {
on_command_added_.push_back(callback);
+ // Send all pre-existed commands.
+ for (const auto& command : map_)
+ callback.Run(command.second.get());
}
void CommandQueue::AddOnCommandRemovedCallback(const Callback& callback) {