buffet: Add an abstract command dispatch interface

Added simple framework for implementing command dispatch from
buffet to command-handling daemons which concrete delivery
layers, such as D-Bus, can use to actually implement the command
delivery.

Also changed some CommandQueue unit tests to remove the
implementation detail knowledge of how the command IDs are generated.

BUG=chromium:374864
TEST=USE=buffet P2_TEST_FILTER="buffet::*" FEATURES=test emerge-link platform2

Change-Id: Ic7a719a09e924fefedc72cc0bb675adf1acd3713
Reviewed-on: https://chromium-review.googlesource.com/211485
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/commands/command_queue.cc b/buffet/commands/command_queue.cc
index ca1e7f9..671db6d 100644
--- a/buffet/commands/command_queue.cc
+++ b/buffet/commands/command_queue.cc
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include "buffet/commands/command_dispatch_interface.h"
 #include "buffet/commands/command_queue.h"
 
 namespace buffet {
@@ -11,6 +12,9 @@
   auto pair = map_.insert(std::make_pair(id, std::move(instance)));
   LOG_IF(FATAL, !pair.second) << "Command with ID '" << id
                               << "' is already in the queue";
+  if (dispatch_interface_)
+    dispatch_interface_->OnCommandAdded(id, pair.first->second.get());
+
   return id;
 }
 
@@ -21,6 +25,8 @@
   if (p != map_.end()) {
     instance = std::move(p->second);
     map_.erase(p);
+    if (dispatch_interface_)
+      dispatch_interface_->OnCommandRemoved(id, instance.get());
   }
   return instance;
 }