buffet: Add command ID to CommandInstance class

Rather than passing command ID along with CommandInstance class,
make it to be part of CommandInstance itself. When a command
instance is added to CommandQueue, the command queue will generate
a new ID and set it to the command instance.

Because CommandInstance, when saved in CommandQueue, is now mutable,
remove 'const' in a bunch of places to allow the command instance
to be modifiable.

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

Change-Id: Ia30dd4c9bd86b51694d9345dd91f6ed2ae0cb138
Reviewed-on: https://chromium-review.googlesource.com/213266
Reviewed-by: Chris Sosa <sosa@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/commands/command_instance.h b/buffet/commands/command_instance.h
index a901380..ebc43ad 100644
--- a/buffet/commands/command_instance.h
+++ b/buffet/commands/command_instance.h
@@ -32,6 +32,8 @@
                   const std::string& category,
                   const native_types::Object& parameters);
 
+  // Returns the full command ID.
+  const std::string& GetID() const { return id_; }
   // Returns the full name of the command.
   const std::string& GetName() const { return name_; }
   // Returns the command category.
@@ -46,12 +48,18 @@
   // object, checking the JSON |value| against the command definition schema
   // found in command |dictionary|. On error, returns null unique_ptr and
   // fills in error details in |error|.
-  static std::unique_ptr<const CommandInstance> FromJson(
+  static std::unique_ptr<CommandInstance> FromJson(
       const base::Value* value,
       const CommandDictionary& dictionary,
       chromeos::ErrorPtr* error);
 
+  // Sets the command ID (normally done by CommandQueue when the command
+  // instance is added to it).
+  void SetID(const std::string& id) { id_ = id; }
+
  private:
+  // Unique command ID within a command queue.
+  std::string id_;
   // Full command name as "<package_name>.<command_name>".
   std::string name_;
   // Command category. See comments for CommandDefinitions::LoadCommands for the