chromeos-dbus-bindings: Redesign due to underlying DBusObject change.

DBusObject method handlers have been changed to allow for async
method handlers. D-Bus proxy generator is changing accordingly
to reflect the underlying implementation change.

Now it is possible to generate asyc-ready method handlers by
adding annotations to the method elements in the source XML file.
With the "org.chromium.DBus.Method.Kind" attribute on a method
description element, you can now control which of the four
supported method handers are to be used:

- "normal" (default): the handler signature is as follows:

  bool Handler(ErrorPtr* error, const Type1& in1, const Type2& in2, ...
               Type3* out1, Type4* out2, ...);

- "simple": the handler does not fail and hence does not return
  any error information. One of the following two signatures:

  RetType Handler(const Type1& in1, const Type2& in2, ...);
  void Handler(const Type1& in1, const Type2& in2, ...,
               Type3* out1, Type4* out2, ...);

- "async": is a possibly asynchronous method handler:

  void Handler(scoped_ptr<DBusMethodResponse> response,
               const Type1& in1, const Type2& in2, ...);

- "raw": the fully custom specialty handler that allows
  raw implementation of D-Bus method with no additional framework:

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

As part of this change, it was also possible to provide implementations
for methods returning more than one value.

A method element can also specify that the method handler can be
marked as 'const' in the C++ adapter by adding the following attribute
with the value of "true": "org.chromium.DBus.Method.Const"

Another significant change to the D-Bus binding generator is the
support of multiple interfaces per D-Bus object. Now the XML file
can list multiple <interface> tags for a class node. This makes the
generator to create the abstract C++ interface adaptors that contain
protorypes for all the methods, signals and properties for that interface.

The final interface implementation class derives from one or more adaptor(s)
and implements the actual interface methods.

Finally, updated lorgnette to use the new generated adaptor for its
D-Bus interfaces.

BUG=chromium:419271, chromium:420925, chromium:428390
TEST=FEATURES=test emerge-link chromeos-dbus-bindings

Change-Id: I02d1fc2e21a230e0f4c959c54ed7c71490945b12
Reviewed-on: https://chromium-review.googlesource.com/227281
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
diff --git a/chromeos-dbus-bindings/proxy_generator_unittest.cc b/chromeos-dbus-bindings/proxy_generator_unittest.cc
index 1149de9..7bb1ab9 100644
--- a/chromeos-dbus-bindings/proxy_generator_unittest.cc
+++ b/chromeos-dbus-bindings/proxy_generator_unittest.cc
@@ -23,6 +23,7 @@
 namespace {
 
 const char kInterfaceName[] = "org.chromium.TestInterface";
+const char kInterfaceName2[] = "org.chromium.TestInterface2";
 const char kMethod1Name[] = "Elements";
 const char kMethod1Return[] = "s";
 const char kMethod1Argument1[] = "s";
@@ -34,6 +35,11 @@
 const char kMethod3Name[] = "NiceWeatherForDucks";
 const char kMethod3Argument1[] = "b";
 const char kMethod4Name[] = "ExperimentNumberSix";
+const char kMethod5Name[] = "GetPersonInfo";
+const char kMethod5Argument1[] = "s";
+const char kMethod5ArgumentName1[] = "name";
+const char kMethod5Argument2[] = "i";
+const char kMethod5ArgumentName2[] = "age";
 const char kSignal1Name[] = "Closer";
 const char kSignal2Name[] = "TheCurseOfKaZar";
 const char kSignal2Argument1[] = "as";
@@ -114,68 +120,66 @@
           << object_path_.value();
     }
   }
-  virtual std::string Elements(
-      const std::string& space_walk_in,
-      const std::vector<dbus::ObjectPath>& ramblin_man_in,
+  virtual bool Elements(
+      const std::string& in_space_walk,
+      const std::vector<dbus::ObjectPath>& in_ramblin_man,
+      std::string* out_3,
       chromeos::ErrorPtr* error) {
     auto response = chromeos::dbus_utils::CallMethodAndBlock(
         dbus_object_proxy_,
         "org.chromium.TestInterface",
         "Elements",
         error,
-        space_walk_in,
-        ramblin_man_in);
-    std::string result{};
-    if (!response) {
-      return result;
-    }
-    chromeos::dbus_utils::ExtractMethodCallResults(
-        response.get(), error, &result);
-    return result;
+        in_space_walk,
+        in_ramblin_man);
+    return response && chromeos::dbus_utils::ExtractMethodCallResults(
+        response.get(), error, out_3);
   }
-  virtual int64_t ReturnToPatagonia(
+  virtual bool ReturnToPatagonia(
+      int64_t* out_1,
       chromeos::ErrorPtr* error) {
     auto response = chromeos::dbus_utils::CallMethodAndBlock(
         dbus_object_proxy_,
         "org.chromium.TestInterface",
         "ReturnToPatagonia",
         error);
-    int64_t result{};
-    if (!response) {
-      return result;
-    }
-    chromeos::dbus_utils::ExtractMethodCallResults(
-        response.get(), error, &result);
-    return result;
+    return response && chromeos::dbus_utils::ExtractMethodCallResults(
+        response.get(), error, out_1);
   }
-  virtual void NiceWeatherForDucks(
-      bool argument1_in,
+  virtual bool NiceWeatherForDucks(
+      bool in_1,
       chromeos::ErrorPtr* error) {
     auto response = chromeos::dbus_utils::CallMethodAndBlock(
         dbus_object_proxy_,
         "org.chromium.TestInterface",
         "NiceWeatherForDucks",
         error,
-        argument1_in);
-    if (!response) {
-      return;
-    }
-    chromeos::dbus_utils::ExtractMethodCallResults(
+        in_1);
+    return response && chromeos::dbus_utils::ExtractMethodCallResults(
         response.get(), error);
   }
-  virtual void ExperimentNumberSix(
+  virtual bool ExperimentNumberSix(
       chromeos::ErrorPtr* error) {
     auto response = chromeos::dbus_utils::CallMethodAndBlock(
         dbus_object_proxy_,
         "org.chromium.TestInterface",
         "ExperimentNumberSix",
         error);
-    if (!response) {
-      return;
-    }
-    chromeos::dbus_utils::ExtractMethodCallResults(
+    return response && chromeos::dbus_utils::ExtractMethodCallResults(
         response.get(), error);
   }
+  virtual bool GetPersonInfo(
+      std::string* out_name,
+      int32_t* out_age,
+      chromeos::ErrorPtr* error) {
+    auto response = chromeos::dbus_utils::CallMethodAndBlock(
+        dbus_object_proxy_,
+        "org.chromium.TestInterface2",
+        "GetPersonInfo",
+        error);
+    return response && chromeos::dbus_utils::ExtractMethodCallResults(
+        response.get(), error, out_name, out_age);
+  }
 
  private:
   scoped_refptr<dbus::Bus> bus_;
@@ -234,8 +238,17 @@
       vector<Interface::Argument>{
           {"", kSignal2Argument1},
           {"", kSignal2Argument2}});
+  Interface interface2;
+  interface2.name = kInterfaceName2;
+  interface2.methods.emplace_back(
+      kMethod5Name,
+      vector<Interface::Argument>{},
+      vector<Interface::Argument>{
+          {kMethod5ArgumentName1, kMethod5Argument1},
+          {kMethod5ArgumentName2, kMethod5Argument2}});
+  vector<Interface> interfaces{interface, interface2};
   base::FilePath output_path = temp_dir_.path().Append("output.h");
-  EXPECT_TRUE(ProxyGenerator::GenerateProxy(interface, output_path));
+  EXPECT_TRUE(ProxyGenerator::GenerateProxy(interfaces, output_path));
   string contents;
   EXPECT_TRUE(base::ReadFileToString(output_path, &contents));
   // The header guards contain the (temporary) filename, so we search for