buffet: Read config/state paths from commandline

This allows us to use custom paths and configurations in test without
altering normal system operation.

BUG=brillo:172
TEST=unittests

Change-Id: I1a969093683205d5f600ff88ebba8b22c05368b4
Reviewed-on: https://chromium-review.googlesource.com/247504
Tested-by: Christopher Wiley <wiley@chromium.org>
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Christopher Wiley <wiley@chromium.org>
diff --git a/buffet/manager.cc b/buffet/manager.cc
index 04fcc36..6605770 100644
--- a/buffet/manager.cc
+++ b/buffet/manager.cc
@@ -23,6 +23,7 @@
 #include "buffet/commands/command_manager.h"
 #include "buffet/states/state_change_queue.h"
 #include "buffet/states/state_manager.h"
+#include "buffet/storage_impls.h"
 
 using chromeos::dbus_utils::AsyncEventSequencer;
 using chromeos::dbus_utils::ExportedObjectManager;
@@ -41,7 +42,10 @@
 
 Manager::~Manager() {}
 
-void Manager::RegisterAsync(const AsyncEventSequencer::CompletionAction& cb) {
+void Manager::RegisterAsync(
+    const base::FilePath& config_path,
+    const base::FilePath& state_path,
+    const AsyncEventSequencer::CompletionAction& cb) {
   command_manager_ =
       std::make_shared<CommandManager>(dbus_object_.GetObjectManager());
   command_manager_->Startup();
@@ -50,13 +54,17 @@
   state_manager_ = std::make_shared<StateManager>(state_change_queue_.get());
   state_manager_->Startup();
   std::unique_ptr<chromeos::KeyValueStore> config_store{
-    new chromeos::KeyValueStore};
-  config_store->Load(base::FilePath(
-      FILE_PATH_LITERAL("/etc/buffet/buffet.conf")));
+      new chromeos::KeyValueStore};
+  std::unique_ptr<FileStorage> state_store{new FileStorage{state_path}};
+  config_store->Load(config_path);
+  // TODO(avakulenko): Figure out security implications of storing
+  // device info state data unencrypted.
   device_info_ = std::unique_ptr<DeviceRegistrationInfo>(
       new DeviceRegistrationInfo(command_manager_,
                                  state_manager_,
-                                 std::move(config_store)));
+                                 std::move(config_store),
+                                 chromeos::http::Transport::CreateDefault(),
+                                 std::move(state_store)));
   device_info_->Load();
   dbus_adaptor_.RegisterWithDBusObject(&dbus_object_);
   dbus_object_.RegisterAsync(cb);