buffet: Added base.updateDeviceInfo handler
base.updateDeviceInfo changes 'name', 'description' and 'location'
properties of the device resource.
BUG=brillo:697
TEST='FEATURES=test emerge-storm buffet'
Change-Id: Id1b349c97d2132117cdf803dda8e39d25c64621a
Reviewed-on: https://chromium-review.googlesource.com/270787
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/base_api_handler.h b/buffet/base_api_handler.h
new file mode 100644
index 0000000..8743bcf
--- /dev/null
+++ b/buffet/base_api_handler.h
@@ -0,0 +1,41 @@
+// Copyright 2015 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_BASE_API_HANDLER_H_
+#define BUFFET_BASE_API_HANDLER_H_
+
+#include <memory>
+#include <string>
+
+#include <base/memory/weak_ptr.h>
+
+namespace buffet {
+
+class CommandInstance;
+class CommandManager;
+class DeviceRegistrationInfo;
+
+// Handles commands from 'base' package.
+// Objects of the class subscribe for notification from CommandManager and
+// execute incoming commands.
+// Handled commands:
+// base.updateDeviceInfo
+class BaseApiHandler final {
+ public:
+ BaseApiHandler(const base::WeakPtr<DeviceRegistrationInfo>& device_info,
+ const std::shared_ptr<CommandManager>& command_manager);
+
+ private:
+ void OnCommandAdded(CommandInstance* command);
+ void UpdateDeviceInfo(CommandInstance* command);
+
+ base::WeakPtr<DeviceRegistrationInfo> device_info_;
+
+ base::WeakPtrFactory<BaseApiHandler> weak_ptr_factory_{this};
+ DISALLOW_COPY_AND_ASSIGN(BaseApiHandler);
+};
+
+} // namespace buffet
+
+#endif // BUFFET_BASE_API_HANDLER_H_