libchromeos: Add support for async D-Bus method handlers

Changed DBusObject implementation infrastructure in libchromeos
to add support for registering asynchronous D-Bus method handlers.

Also changed the simple synchronous method handler signature to
eliminate the confusion when a handler returning a value throws
an error.

Currently, there are four kinds of D-Bus method handlers:
- SimpleMethodHandler - has one of the following signatures:

    RetVal Handler(Args... args)
    void Handler(Args... args)

  The first one takes only input parameters (by value or const
  reference) and returns a single value as a function return.
  The second handler can mix both input (value/const reference)
  and output (pointer) values.

  This handler is synchronous (response is sent as soon as the
  handler returns) and does not provide any error returns
  (it always succeeds).

- SimpleMethodHanderWithError
  This is similar to SimpleMethodHandler but provides a way
  to return an error. The handler signature is as follows:

    bool Handler(ErrorPtr* error, Args... args)

  The parameters can include both IN and OUT arguments.

  If the handler succeeds, it must return true. On failures,
  it returns false and provides error details in |error|.

- MethodHandler - a generic (possibly asynchronous) handler
  that has the following signature:

    void Handler(scoped_ptr<DBusMethodResponse> response,
                 Args... args)

  The parameters include only IN arguments and the method
  sends back any return values using the |response| object.

  The handler owns the |response| so it can start an
  asynchronous operation (that holds on to the response) and
  exit immediately. The D-Bus method response is sent only
  when the handler provides the reply using the response
  object.

- RawMethodHandler
  This is the low-level method handler that does not go through
  any of the parameter/return value parsing. It is provided
  with the raw method call D-Bus message and is expected to
  provide the response manually. The handler signtaure is:

    void Handler(dbus::MethodCall* method_call,
                 ResponseSender sender)

  This type of handler is useful to implement D-Bus methods
  with variable number of parameters or those which
  can accept a number of different types of arguments.

BUG=chromium:428390
TEST=FEATURES=test emerge-link libchromeos peerd buffet attestation
CQ-DEPEND=CL:227281

Change-Id: I1dde6b279ada9d350a4d0e6743c56d3b12cc38cf
Reviewed-on: https://chromium-review.googlesource.com/226666
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/commands/dbus_command_proxy_unittest.cc b/buffet/commands/dbus_command_proxy_unittest.cc
index f8fba8d..ae91b13 100644
--- a/buffet/commands/dbus_command_proxy_unittest.cc
+++ b/buffet/commands/dbus_command_proxy_unittest.cc
@@ -9,6 +9,7 @@
 #include <dbus/mock_exported_object.h>
 #include <dbus/property.h>
 #include <chromeos/dbus/dbus_object.h>
+#include <chromeos/dbus/dbus_object_test_helpers.h>
 #include <gtest/gtest.h>
 
 #include "buffet/commands/command_dictionary.h"
@@ -131,8 +132,8 @@
     dbus::MessageWriter writer(&method_call);
     if (param_callback)
       param_callback(&writer);
-    return chromeos::dbus_utils::CallMethod(*GetProxyDBusObject(),
-                                            &method_call);
+    return chromeos::dbus_utils::testing::CallMethod(*GetProxyDBusObject(),
+                                                     &method_call);
   }
 
   static bool IsResponseError(const std::unique_ptr<dbus::Response>& response) {
@@ -157,8 +158,8 @@
     dbus::MessageWriter writer(&method_call);
     writer.AppendString(dbus_constants::kCommandInterface);
     writer.AppendString(property_name);
-    auto response = chromeos::dbus_utils::CallMethod(*GetProxyDBusObject(),
-                                                     &method_call);
+    auto response = chromeos::dbus_utils::testing::CallMethod(
+        *GetProxyDBusObject(), &method_call);
     T value{};
     VerifyResponse(response, [&value](dbus::MessageReader* reader) {
       EXPECT_TRUE(chromeos::dbus_utils::PopValueFromReader(reader, &value));