blob: c224513ee6a727f2859ab0e41b26e32de56e66cf [file] [log] [blame]
Christopher Wiley6d4db222014-05-02 13:44:48 -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_STORAGE_INTERFACE_H_
6#define BUFFET_STORAGE_INTERFACE_H_
7
8#include <memory>
9
10#include <base/values.h>
11
12namespace buffet {
13
14// We need to persist data in a couple places, and it is convenient to hide
15// the details of this storage behind an interface for test purposes.
16class StorageInterface {
17 public:
Vitaly Buka0faceef2015-05-18 09:28:54 -070018 virtual ~StorageInterface() = default;
19
Vitaly Bukad0ec5b02015-05-14 17:06:18 -070020 // Load the dictionary from storage. If it fails (e.g. the storage container
21 // [file?] doesn't exist), then it returns empty unique_ptr (aka nullptr).
22 virtual std::unique_ptr<base::DictionaryValue> Load() = 0;
Christopher Wiley6d4db222014-05-02 13:44:48 -070023
Vitaly Bukad0ec5b02015-05-14 17:06:18 -070024 // Save the dictionary to storage. If saved successfully, returns true. Could
25 // fail when writing to physical storage like file system for various reasons
26 // (out of disk space,access permissions, etc).
27 virtual bool Save(const base::DictionaryValue& config) = 0;
Christopher Wiley6d4db222014-05-02 13:44:48 -070028};
29
30} // namespace buffet
31
32#endif // BUFFET_STORAGE_INTERFACE_H_