buffet: Add DBus proxy class for command instance object

Added DBusCommandProxy class that implements
org.chromium.Buffet.Command DBus interface, including command
methods and properties.

BUG=chromium:374864
TEST=USE=buffet P2_TEST_FILTER="buffet::*" FEATURES=test emerge-link platform2

Change-Id: Iaf17f2b7c276edc1e9f3ca09a759a4a7d4dc3b10
Reviewed-on: https://chromium-review.googlesource.com/213267
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Reviewed-by: Christopher Wiley <wiley@chromium.org>
diff --git a/buffet/commands/dbus_command_proxy.h b/buffet/commands/dbus_command_proxy.h
new file mode 100644
index 0000000..a4b2a53
--- /dev/null
+++ b/buffet/commands/dbus_command_proxy.h
@@ -0,0 +1,63 @@
+// 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_COMMANDS_DBUS_COMMAND_PROXY_H_
+#define BUFFET_COMMANDS_DBUS_COMMAND_PROXY_H_
+
+#include <memory>
+#include <string>
+
+#include <base/basictypes.h>
+#include <chromeos/dbus/dbus_object.h>
+
+namespace chromeos {
+namespace dbus_utils {
+class ExportedObjectManager;
+}  // namespace dbus_utils
+}  // namespace chromeos
+
+namespace buffet {
+
+class CommandInstance;
+
+class DBusCommandProxy {
+ public:
+  DBusCommandProxy(chromeos::dbus_utils::ExportedObjectManager* object_manager,
+                   const scoped_refptr<dbus::Bus>& bus,
+                   CommandInstance* command_instance);
+  virtual ~DBusCommandProxy() = default;
+
+  void RegisterAsync(
+      const chromeos::dbus_utils::AsyncEventSequencer::CompletionAction&
+          completion_callback);
+
+ private:
+  // DBus properties for org.chromium.Buffet.Command interface.
+  chromeos::dbus_utils::ExportedProperty<std::string> name_;
+  chromeos::dbus_utils::ExportedProperty<std::string> category_;
+  chromeos::dbus_utils::ExportedProperty<std::string> id_;
+  chromeos::dbus_utils::ExportedProperty<std::string> status_;
+  chromeos::dbus_utils::ExportedProperty<int32_t> progress_;
+
+  // Handles calls to org.chromium.Buffet.Command.SetProgress(progress).
+  void HandleSetProgress(chromeos::ErrorPtr* error, int32_t progress);
+  // Handles calls to org.chromium.Buffet.Command.Abort().
+  void HandleAbort(chromeos::ErrorPtr* error);
+  // Handles calls to org.chromium.Buffet.Command.Cancel().
+  void HandleCancel(chromeos::ErrorPtr* error);
+  // Handles calls to org.chromium.Buffet.Command.Done().
+  void HandleDone(chromeos::ErrorPtr* error);
+
+  dbus::ObjectPath object_path_;
+  CommandInstance* command_instance_;
+
+  chromeos::dbus_utils::DBusObject dbus_object_;
+
+  friend class DBusCommandProxyTest;
+  DISALLOW_COPY_AND_ASSIGN(DBusCommandProxy);
+};
+
+}  // namespace buffet
+
+#endif  // BUFFET_COMMANDS_DBUS_COMMAND_PROXY_H_