Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a85402a1 authored by Erwin Jansen's avatar Erwin Jansen
Browse files

Use generic type for JsonParser

The android emulator team uses a newer libchrome library. The json read
method now returns an Optional type, vs. a unique_ptr.

We now let the compiler infer the type and rely on the operators to do
the right thing.

Change-Id: I0a668115659d6508344190783b7dc55d84374f15
Test: System compiles.
Bug: 182487647
parent 25d92a90
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
/*
 * Copyright 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
@@ -84,12 +83,17 @@ DeviceProperties::DeviceProperties(const std::string& file_name)
    return;
  }

  std::unique_ptr<base::Value> properties_value_ptr = base::JSONReader::Read(properties_raw);
  if (properties_value_ptr.get() == nullptr) LOG_INFO("Error controller properties may consist of ill-formed JSON.");
  auto properties_value = base::JSONReader::Read(properties_raw);
  if (!properties_value) {
    LOG_ERROR(
        "Error controller properties may consist of ill-formed JSON, no "
        "properties read.");
      return;
  }

  // Get the underlying base::Value object, which is of type
  // base::Value::TYPE_DICTIONARY, and read it into member variables.
  base::Value& properties_dictionary = *(properties_value_ptr.get());
  base::Value& properties_dictionary = *properties_value;
  base::JSONValueConverter<DeviceProperties> converter;

  if (!converter.Convert(properties_dictionary, this))