buffet: Add 'origin' property to Command

Now it is possible to distinguish commands that came from local
clients from those that were sent from the cloud.

The vendor applications could make a decision on how to process
the command depending on where it came from. Also, the command
status update code could do different things depending on whether
status updates need to go to the cloud or the local client.

BUG=None
TEST=`FEATURES=test emerge-link buffet`

Change-Id: I80156c5b43dace0b79b87b86618bfec017b30de9
Reviewed-on: https://chromium-review.googlesource.com/266563
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Trybot-Ready: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/commands/command_instance.h b/buffet/commands/command_instance.h
index e5e0f9f..db9c519 100644
--- a/buffet/commands/command_instance.h
+++ b/buffet/commands/command_instance.h
@@ -33,6 +33,7 @@
   // be in format "<package_name>.<command_name>", a command |category| and
   // a list of parameters and their values specified in |parameters|.
   CommandInstance(const std::string& name,
+                  const std::string& origin,
                   const CommandDefinition* command_definition,
                   const native_types::Object& parameters);
   ~CommandInstance();
@@ -50,6 +51,8 @@
   // Finds a command parameter value by parameter |name|. If the parameter
   // with given name does not exist, returns nullptr.
   const PropValue* FindParameter(const std::string& name) const;
+  // Returns the full name of the command.
+  const std::string& GetOrigin() const { return origin_; }
 
   // Returns command definition.
   const CommandDefinition* GetCommandDefinition() const {
@@ -62,6 +65,7 @@
   // fills in error details in |error|.
   static std::unique_ptr<CommandInstance> FromJson(
       const base::Value* value,
+      const std::string& origin,
       const CommandDictionary& dictionary,
       chromeos::ErrorPtr* error);
 
@@ -121,6 +125,8 @@
   std::string id_;
   // Full command name as "<package_name>.<command_name>".
   std::string name_;
+  // The origin of the command, either "local" or "cloud".
+  std::string origin_;
   // Command definition.
   const CommandDefinition* command_definition_;
   // Command parameters and their values.