platform2: Move Error class from Buffet to libchromeos

Moved buffet::Error class and related facilities to
libchromeos and changed the namespace to 'chromeos::'.
Updated a bunch of code to include the header files
from the new location and referring to the new
namespace.

BUG=chromium:403604
TEST=USE=buffet ./build_packages
     FEATURES=test emerge-link libchromeos
     USE=buffet FEATURES=test emerge-link platform2

Change-Id: I0b5b37ccd7ee3b7be9467ebfae5d172d9b057cf6
Reviewed-on: https://chromium-review.googlesource.com/212525
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_instance.cc b/buffet/commands/command_instance.cc
index 1e667fe..04b08ab 100644
--- a/buffet/commands/command_instance.cc
+++ b/buffet/commands/command_instance.cc
@@ -5,12 +5,13 @@
 #include "buffet/commands/command_instance.h"
 
 #include <base/values.h>
+#include <chromeos/error.h>
+#include <chromeos/error_codes.h>
 
 #include "buffet/commands/command_definition.h"
 #include "buffet/commands/command_dictionary.h"
 #include "buffet/commands/schema_constants.h"
 #include "buffet/commands/schema_utils.h"
-#include "buffet/error_codes.h"
 
 namespace buffet {
 
@@ -40,7 +41,7 @@
 bool GetCommandParameters(const base::DictionaryValue* json,
                           const CommandDefinition* command_def,
                           native_types::Object* parameters,
-                          ErrorPtr* error) {
+                          chromeos::ErrorPtr* error) {
   // Get the command parameters from 'parameters' property.
   base::DictionaryValue no_params;  // Placeholder when no params are specified.
   const base::DictionaryValue* params = nullptr;
@@ -49,10 +50,10 @@
                                     &params_value)) {
     // Make sure the "parameters" property is actually an object.
     if (!params_value->GetAsDictionary(&params)) {
-      Error::AddToPrintf(error, errors::json::kDomain,
-                         errors::json::kObjectExpected,
-                         "Property '%s' must be a JSON object",
-                         commands::attributes::kCommand_Parameters);
+      chromeos::Error::AddToPrintf(error, chromeos::errors::json::kDomain,
+                                   chromeos::errors::json::kObjectExpected,
+                                   "Property '%s' must be a JSON object",
+                                   commands::attributes::kCommand_Parameters);
       return false;
     }
   } else {
@@ -74,13 +75,14 @@
 std::unique_ptr<const CommandInstance> CommandInstance::FromJson(
     const base::Value* value,
     const CommandDictionary& dictionary,
-    ErrorPtr* error) {
+    chromeos::ErrorPtr* error) {
   std::unique_ptr<const CommandInstance> instance;
   // Get the command JSON object from the value.
   const base::DictionaryValue* json = nullptr;
   if (!value->GetAsDictionary(&json)) {
-    Error::AddTo(error, errors::json::kDomain, errors::json::kObjectExpected,
-                 "Command instance is not a JSON object");
+    chromeos::Error::AddTo(error, chromeos::errors::json::kDomain,
+                           chromeos::errors::json::kObjectExpected,
+                           "Command instance is not a JSON object");
     return instance;
   }
 
@@ -88,25 +90,27 @@
   std::string command_name;
   if (!json->GetStringWithoutPathExpansion(commands::attributes::kCommand_Name,
                                            &command_name)) {
-    Error::AddTo(error, errors::commands::kDomain,
-                 errors::commands::kPropertyMissing,
-                 "Command name is missing");
+    chromeos::Error::AddTo(error, errors::commands::kDomain,
+                           errors::commands::kPropertyMissing,
+                           "Command name is missing");
     return instance;
   }
   // Make sure we know how to handle the command with this name.
   const CommandDefinition* command_def = dictionary.FindCommand(command_name);
   if (!command_def) {
-    Error::AddToPrintf(error, errors::commands::kDomain,
-                       errors::commands::kInvalidCommandName,
-                       "Unknown command received: %s", command_name.c_str());
+    chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                 errors::commands::kInvalidCommandName,
+                                 "Unknown command received: %s",
+                                 command_name.c_str());
     return instance;
   }
 
   native_types::Object parameters;
   if (!GetCommandParameters(json, command_def, &parameters, error)) {
-    Error::AddToPrintf(error, errors::commands::kDomain,
-                       errors::commands::kCommandFailed,
-                       "Failed to validate command '%s'", command_name.c_str());
+    chromeos::Error::AddToPrintf(error, errors::commands::kDomain,
+                                 errors::commands::kCommandFailed,
+                                 "Failed to validate command '%s'",
+                                 command_name.c_str());
     return instance;
   }