huddly-updater: remove base::JSONReader::.*Deprecated methods

JSONReader::.*Deprecated methods would be removed in next libchrome
uprev.
This also changes relevant usages of base::{Dictioanry,List}Value to
base::Value.

BUG=chromium:1094927, chromium:1099111
TEST=cros_run_unit_tests --board=fizz --packages huddly-updater

Change-Id: I872f6ffec83e39508fdf14cb2bf0789a33cd9ec2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/huddly-updater/+/2409475
Tested-by: Grace Cham <hscham@chromium.org>
Commit-Queue: Qijiang Fan <fqj@google.com>
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Reviewed-by: Joe Tessler <jrt@chromium.org>
diff --git a/src/huddly_hpk/hpk_file.cc b/src/huddly_hpk/hpk_file.cc
index 312a405..12d2f7b 100644
--- a/src/huddly_hpk/hpk_file.cc
+++ b/src/huddly_hpk/hpk_file.cc
@@ -66,61 +66,62 @@
 }
 
 bool HpkFile::ParseJsonManifest(std::string* error_msg) {
-  int error_code;
-  std::string json_error_msg;
   // Older implementatons of ReadAndReturnError produces scoped_ptr that must be
   // observed, to build on both CrOS and older versions of Android, as such we
   // get the raw pointer and recast to unique_ptr regardless if it is shared_ptr
   // or unique_ptr
-  // TODO(crbug/1066447): update to new Read API after libchrome uprev.
-  auto root_value = base::JSONReader().ReadAndReturnErrorDeprecated(
-      manifest_data_, base::JSON_PARSE_RFC, &error_code, &json_error_msg);
-  manifest_root_.reset(std::move(root_value.release()));
+  auto root_value = base::JSONReader::ReadAndReturnValueWithError(
+      manifest_data_, base::JSON_PARSE_RFC);
 
-  if (!manifest_root_) {
-    *error_msg = "Failed to parse json data:\n" + json_error_msg;
+  if (!root_value.value) {
+    *error_msg = "Failed to parse json data:\n" + root_value.error_message;
     return false;
   }
 
   // The root of the manifest should always be a dictionary.
-  if (!(manifest_root_->GetAsDictionary(&manifest_root_dictionary_))) {
+  if (!root_value.value->is_dict()) {
     *error_msg = "Manifest root object is not a dictionary.";
     return false;
   }
 
+  manifest_root_dictionary_ = std::move(*root_value.value);
+
   return true;
 }
 
 bool HpkFile::GetFirmwareVersionNumeric(std::vector<uint32_t>* version,
                                         std::string* error_msg) const {
-  base::ListValue* fw_version;
-  if (!(manifest_root_dictionary_->GetList("version.numerical", &fw_version))) {
+  const base::Value* fw_version =
+      manifest_root_dictionary_.FindListPath("version.numerical");
+  if (!fw_version) {
     *error_msg = "Failed to get firmware version as list.";
     return false;
   }
 
-  if (fw_version->GetSize() != kExpectedFirmwareVersionLength) {
+  if (fw_version->GetList().size() != kExpectedFirmwareVersionLength) {
     *error_msg = "Unexpected firmware version length.";
     return false;
   }
 
-  for (int i = 0; i < kExpectedFirmwareVersionLength; i++) {
-    int component = -1;
-    if (!fw_version->GetInteger(i, &component)) {
+  for (const auto& component : fw_version->GetList()) {
+    if (!component.is_int()) {
       *error_msg = "Failed to get firmware version component as integer.";
       return false;
     }
-    version->push_back(component);
+    version->push_back(component.GetInt());
   }
   return true;
 }
 
 bool HpkFile::GetFirmwareVersionString(std::string* version,
                                        std::string* error_msg) const {
-  if (!(manifest_root_dictionary_->GetString("version.app_version", version))) {
+  const std::string* fw_version =
+      manifest_root_dictionary_.FindStringPath("version.app_version");
+  if (!fw_version) {
     *error_msg = "Failed to get firmware version as string.";
     return false;
   }
+  *version = *fw_version;
 
   return true;
 }
diff --git a/src/huddly_hpk/hpk_file.h b/src/huddly_hpk/hpk_file.h
index f2e7a79..e401a86 100644
--- a/src/huddly_hpk/hpk_file.h
+++ b/src/huddly_hpk/hpk_file.h
@@ -33,8 +33,7 @@
 
   std::string file_contents_;
   std::string manifest_data_;
-  std::unique_ptr<base::Value> manifest_root_;
-  base::DictionaryValue* manifest_root_dictionary_;
+  base::Value manifest_root_dictionary_;
   std::vector<uint32_t> firmware_version_;
 };
 
diff --git a/src/huddly_hpk/hpk_file_unittest.cc b/src/huddly_hpk/hpk_file_unittest.cc
index 7bfabf3..e942d63 100644
--- a/src/huddly_hpk/hpk_file_unittest.cc
+++ b/src/huddly_hpk/hpk_file_unittest.cc
@@ -115,7 +115,7 @@
               HasSubstr("Failed to get firmware version component as integer"));
 }
 
-TEST_F(HpkFileTest, GetversionNumericFromExampleFile) {
+TEST_F(HpkFileTest, GetVersionNumericFromExampleFile) {
   const auto instance =
       huddly::HpkFile::Create(base::FilePath(kHpkTestFilePath), &error_msg);
   ASSERT_NE(nullptr, instance);
@@ -128,7 +128,7 @@
   EXPECT_EQ(kExpectedFirmwareVersionNumeric_, firmware_version);
 }
 
-TEST_F(HpkFileTest, GetversionStringFromExampleFile) {
+TEST_F(HpkFileTest, GetVersionStringFromExampleFile) {
   const auto instance =
       huddly::HpkFile::Create(base::FilePath(kHpkTestFilePath), &error_msg);
   ASSERT_NE(nullptr, instance);