blob: 32738d2285218fedc5cd683af9746f9351d05c94 [file] [log] [blame]
Alex Vakulenkob04936f2014-09-19 14:53:58 -07001// Copyright 2014 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef BUFFET_UTILS_H_
6#define BUFFET_UTILS_H_
7
8#include <memory>
Alex Vakulenko9e2f8cd2015-04-07 16:28:09 -07009#include <string>
Alex Vakulenkob04936f2014-09-19 14:53:58 -070010
11#include <base/values.h>
12#include <base/files/file_path.h>
13#include <chromeos/errors/error.h>
14
15namespace buffet {
16
Alex Vakulenko07216fe2014-09-19 15:31:09 -070017// Buffet-wide errors.
18// TODO(avakulenko): This should be consolidated into errors::<domain> namespace
19// See crbug.com/417274
Alex Vakulenkob04936f2014-09-19 14:53:58 -070020extern const char kErrorDomainBuffet[];
21extern const char kFileReadError[];
Alex Vakulenko07216fe2014-09-19 15:31:09 -070022extern const char kInvalidCategoryError[];
23extern const char kInvalidPackageError[];
24
25// kDefaultCategory represents a default state property category for standard
26// properties from "base" package which are provided by buffet and not any of
27// the daemons running on the device.
28const char kDefaultCategory[] = "";
Alex Vakulenkob04936f2014-09-19 14:53:58 -070029
30// Helper function to load a JSON file that is expected to be
31// an object/dictionary. In case of error, returns empty unique ptr and fills
32// in error details in |error|.
33std::unique_ptr<const base::DictionaryValue> LoadJsonDict(
34 const base::FilePath& json_file_path, chromeos::ErrorPtr* error);
35
Alex Vakulenko9e2f8cd2015-04-07 16:28:09 -070036// Helper function to load a JSON dictionary from a string.
37std::unique_ptr<const base::DictionaryValue> LoadJsonDict(
38 const std::string& json_string, chromeos::ErrorPtr* error);
39
Alex Vakulenkob04936f2014-09-19 14:53:58 -070040} // namespace buffet
41
42#endif // BUFFET_UTILS_H_