buffet: Separate command IDs from DBus paths.
As we're starting to support cloud and local cases, we need proper
support for cloud command IDs. Therefore now we require each
command instance to have some command id, but generate dbus path
independently.
BUG=None
TEST=cros_workon_make buffet --test&&manual
Change-Id: I83ae92872d920c8e0d6e15324ad11feebfd1f540
Reviewed-on: https://chromium-review.googlesource.com/226532
Tested-by: Anton Muhin <antonm@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Anton Muhin <antonm@chromium.org>
diff --git a/buffet/manager.cc b/buffet/manager.cc
index 7deb36f..9c1cd94 100644
--- a/buffet/manager.cc
+++ b/buffet/manager.cc
@@ -167,6 +167,7 @@
void Manager::HandleAddCommand(scoped_ptr<DBusMethodResponse> response,
const std::string& json_command) {
+ static int next_id = 0;
std::string error_message;
std::unique_ptr<base::Value> value(base::JSONReader::ReadAndReturnError(
json_command, base::JSON_PARSE_RFC, nullptr, &error_message));
@@ -183,6 +184,7 @@
response->ReplyWithError(error.get());
return;
}
+ command_instance->SetID(std::to_string(++next_id));
command_manager_->AddCommand(std::move(command_instance));
response->Return();
}