buffet: Moved LoadJsonDict() function into buffet/utils.h

Moved LoadJsonDict from CommandManager class into a separate
header file as a stand-alone function so that it can be
used by itself.

This function will come in handy when implementing device
state management.

BUG=chromium:415364
TEST=FEATURES=test emerge-link buffet

Change-Id: Ie818a811989d82e4b092e399ca136e15276ab453
Reviewed-on: https://chromium-review.googlesource.com/219134
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/utils.h b/buffet/utils.h
new file mode 100644
index 0000000..e71560c
--- /dev/null
+++ b/buffet/utils.h
@@ -0,0 +1,27 @@
+// Copyright 2014 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BUFFET_UTILS_H_
+#define BUFFET_UTILS_H_
+
+#include <memory>
+
+#include <base/values.h>
+#include <base/files/file_path.h>
+#include <chromeos/errors/error.h>
+
+namespace buffet {
+
+extern const char kErrorDomainBuffet[];
+extern const char kFileReadError[];
+
+// Helper function to load a JSON file that is expected to be
+// an object/dictionary. In case of error, returns empty unique ptr and fills
+// in error details in |error|.
+std::unique_ptr<const base::DictionaryValue> LoadJsonDict(
+    const base::FilePath& json_file_path, chromeos::ErrorPtr* error);
+
+}  // namespace buffet
+
+#endif  // BUFFET_UTILS_H_