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[] = ...@@ -30,19 +30,16 @@ constexpr const base::FilePath::CharType kArcFeaturesJsonFile[] =
base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) { base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
ArcFeatures arc_features; ArcFeatures arc_features;
int error_code; base::JSONReader::ValueWithError parsed_json =
std::string error_msg; base::JSONReader::ReadAndReturnValueWithError(input_json);
std::unique_ptr<base::Value> json_value = if (!parsed_json.value || !parsed_json.value->is_dict()) {
base::JSONReader::ReadAndReturnErrorDeprecated( LOG(ERROR) << "Error parsing feature JSON: " << parsed_json.error_message;
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;
return base::nullopt; return base::nullopt;
} }
// Parse each item under features. // Parse each item under features.
const base::Value* feature_list = 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) { if (!feature_list) {
LOG(ERROR) << "No feature list in JSON."; LOG(ERROR) << "No feature list in JSON.";
return base::nullopt; return base::nullopt;
...@@ -65,8 +62,9 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) { ...@@ -65,8 +62,9 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
} }
// Parse each item under unavailable_features. // Parse each item under unavailable_features.
const base::Value* unavailable_feature_list = json_value->FindKeyOfType( const base::Value* unavailable_feature_list =
"unavailable_features", base::Value::Type::LIST); parsed_json.value->FindKeyOfType("unavailable_features",
base::Value::Type::LIST);
if (!unavailable_feature_list) { if (!unavailable_feature_list) {
LOG(ERROR) << "No unavailable feature list in JSON."; LOG(ERROR) << "No unavailable feature list in JSON.";
return base::nullopt; return base::nullopt;
...@@ -85,8 +83,8 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) { ...@@ -85,8 +83,8 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
} }
// Parse each item under properties. // Parse each item under properties.
const base::Value* properties = const base::Value* properties = parsed_json.value->FindKeyOfType(
json_value->FindKeyOfType("properties", base::Value::Type::DICTIONARY); "properties", base::Value::Type::DICTIONARY);
if (!properties) { if (!properties) {
LOG(ERROR) << "No properties in JSON."; LOG(ERROR) << "No properties in JSON.";
return base::nullopt; return base::nullopt;
...@@ -101,7 +99,7 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) { ...@@ -101,7 +99,7 @@ base::Optional<ArcFeatures> ParseFeaturesJson(base::StringPiece input_json) {
} }
// Parse the Play Store version // 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); "play_store_version", base::Value::Type::STRING);
if (!play_version) { if (!play_version) {
LOG(ERROR) << "No Play Store version in JSON."; 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