buffet: Extract StorageInterface and implementations into separate files

This will make it easy to reuse file storage and memory storage
implementations in the forthcoming state aggregator.

BUG=chromium:369322
TEST=Unittests

Change-Id: Ie0dc0dbbfcc13e038352ecf77e2ad28bd41907d9
Reviewed-on: https://chromium-review.googlesource.com/198045
Tested-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/buffet/storage_interface.h b/buffet/storage_interface.h
new file mode 100644
index 0000000..26d71c1
--- /dev/null
+++ b/buffet/storage_interface.h
@@ -0,0 +1,32 @@
+// 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_STORAGE_INTERFACE_H_
+#define BUFFET_STORAGE_INTERFACE_H_
+
+#include <memory>
+
+#include <base/values.h>
+
+namespace buffet {
+
+// We need to persist data in a couple places, and it is convenient to hide
+// the details of this storage behind an interface for test purposes.
+class StorageInterface {
+ public:
+  // Load the device registration configuration from storage.
+  // If it fails (e.g. the storage container [file?] doesn't exist), then
+  // it returns empty unique_ptr (aka nullptr).
+  virtual std::unique_ptr<base::Value> Load() = 0;
+
+  // Save the device registration configuration to storage.
+  // If saved successfully, returns true. Could fail when writing to
+  // physical storage like file system for various reasons (out of disk space,
+  // access permissions, etc).
+  virtual bool Save(const base::Value* config) = 0;
+};
+
+}  // namespace buffet
+
+#endif  // BUFFET_STORAGE_INTERFACE_H_