buffet: Make CommandInstance own its proxies.
This allows proxies which are not managed by command dispatchers,
for example, cloud proxies.
BUG=None
TEST=cros_workon_make buffet --test
Change-Id: Ia7f0fe97c20328acf8e7942a6ad71aabaade81e4
Reviewed-on: https://chromium-review.googlesource.com/228821
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/commands/dbus_command_dispatcher.cc b/buffet/commands/dbus_command_dispatcher.cc
index d36a927..6751372 100644
--- a/buffet/commands/dbus_command_dispatcher.cc
+++ b/buffet/commands/dbus_command_dispatcher.cc
@@ -24,17 +24,10 @@
void DBusCommandDispacher::OnCommandAdded(CommandInstance* command_instance) {
auto proxy = CreateDBusCommandProxy(command_instance);
proxy->RegisterAsync(AsyncEventSequencer::GetDefaultCompletionAction());
- command_instance->AddProxy(proxy.get());
-
- auto pair = std::make_pair(command_instance, std::move(proxy));
- CHECK(command_map_.insert(std::move(pair)).second)
- << "The command instance is already in the dispatcher command map";
+ command_instance->AddProxy(std::move(proxy));
}
void DBusCommandDispacher::OnCommandRemoved(CommandInstance* command_instance) {
- command_instance->ClearProxies();
- CHECK_GT(command_map_.erase(command_instance), 0u)
- << "The command instance is not in the dispatcher command map";
}
std::unique_ptr<DBusCommandProxy> DBusCommandDispacher::CreateDBusCommandProxy(