Commit e5791077 authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

Upgrade arc from deprecated base::JSONReader API

Bug: 1070409
Change-Id: I488a2edafed79e209f4ab89d56a54d4dd031b2eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2224422Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774404}
parent fe43b5ac
......@@ -30,19 +30,16 @@ constexpr const base::FilePath::CharType kArcFeaturesJsonFile[] =
base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
ArcFeatures arc_features;
int error_code;
std::string error_msg;
std::unique_ptr<base::Value> json_value =
base::JSONReader::ReadAndReturnErrorDeprecated(
input_json, base::JSON_PARSE_RFC, &error_code, &error_msg);
if (!json_value || !json_value->is_dict()) {
LOG(ERROR) << "Error parsing feature JSON: " << error_msg;
base::JSONReader::ValueWithError parsed_json =
base::JSONReader::ReadAndReturnValueWithError(input_json);
if (!parsed_json.value || !parsed_json.value->is_dict()) {
LOG(ERROR) << "Error parsing feature JSON: " << parsed_json.error_message;
return base::nullopt;
}
// Parse each item under features.
const base::Value* feature_list =
json_value->FindKeyOfType("features", base::Value::Type::LIST);
parsed_json.value->FindKeyOfType("features", base::Value::Type::LIST);
if (!feature_list) {
LOG(ERROR) << "No feature list in JSON.";
return base::nullopt;
......@@ -65,8 +62,9 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
}
// Parse each item under unavailable_features.
const base::Value* unavailable_feature_list = json_value->FindKeyOfType(
"unavailable_features", base::Value::Type::LIST);
const base::Value* unavailable_feature_list =
parsed_json.value->FindKeyOfType("unavailable_features",
base::Value::Type::LIST);
if (!unavailable_feature_list) {
LOG(ERROR) << "No unavailable feature list in JSON.";
return base::nullopt;
......@@ -85,8 +83,8 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
}
// Parse each item under properties.
const base::Value* properties =
json_value->FindKeyOfType("properties", base::Value::Type::DICTIONARY);
const base::Value* properties = parsed_json.value->FindKeyOfType(
"properties", base::Value::Type::DICTIONARY);
if (!properties) {
LOG(ERROR) << "No properties in JSON.";
return base::nullopt;
......@@ -101,7 +99,7 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
}
// Parse the Play Store version
const base::Value* play_version = json_value->FindKeyOfType(
const base::Value* play_version = parsed_json.value->FindKeyOfType(
"play_store_version", base::Value::Type::STRING);
if (!play_version) {
LOG(ERROR) << "No Play Store version in JSON.";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment