libchromeos: Fix DBus data serialization to work with custom types

The previous implementation suffered from C++ binding rules for
non-dependent names in templates. Template functions such as
AppendValueToWriter and PopValueFromReader for template types such
as std::vector<T> and std::map<K,V> are limited to the types defined
in libchromeos because the implementations calling the inner overloads
for types such as T would only select functions defined before the
overloads for vector and map are defined.

This forced the custom implementations of user-provided types to
be included before chromeos/dbus/data_serialization.h and having
the code depend on the order of includes is a very dangerous thing.

To make the problem worse, generic AppendValueToWriter<T> is always
a default fall-back for any unknown types and it simply fails at run-time
which makes it very difficult to detect unintended problems.

The reason why the generic AppendValueToWriter<T>() was provided is to
allow chromeos::Any to contain any C++ type but still be able to use
with D-Bus subset of types to implement the D-Bus's VARIANT type.

This change addresses the above problems as follows:

- The template functionality depending on custom overloads of
  AppendValueToWriter and PopValueFromReader now call them indirectly
  through DBusType<T>::Write and DBusType<T>::Read helpers that delay
  binding to the correct overload of Append... and Pop... until the
  template instantiation.
- Marked the generic AppendValueToWriter<T> and PopValueFromReader<T>
  as "deleted" functions so the compilation would break as soon as
  these functions are called with an unsupported types.
- Provided IsTypeSupported<T...> type trait to help specialize the
  implementation for only supported D-Bus types. This allows, for
  example, specialization of vector<T> to work for supported types
  T and fail immediately for T that are not supported by D-Bus.
- Used IsTypeSupported<T> in chromeos::Any to disable calls to
  AppendValueToWriter at compile time for unsupported types.
- Made AppendValueToWriter() a void function. Now it doesn't fail.
  The internal implementation inside chromeos::Any uses CHECK() to
  ensure the contained class which will abort as soon as Any,
  containing datat of an unsupported type, is being written to
  D-Bus message buffer.

BUG=chromium:431744
TEST=FEATURES=test emerge-link libchromeos attestation buffet peerd

Change-Id: I13431f74797b8b92082f172a067ea1515a7aa73e
Reviewed-on: https://chromium-review.googlesource.com/228731
Reviewed-by: Christopher Wiley <wiley@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
10 files changed