Change base::JSONReader::ReadToValue() to return Optional.

https://chromium-review.googlesource.com/c/chromium/src/+/1476186
This commit is contained in:
deepak1556 2019-02-27 17:35:27 +05:30 committed by Samuel Attard
parent fb9d1bd83c
commit 0243b0ffc1

View file

@ -186,16 +186,15 @@ bool Archive::Init() {
return false;
}
std::string error;
base::JSONReader reader;
std::unique_ptr<base::Value> value(reader.ReadToValue(header));
base::Optional<base::Value> value = base::JSONReader::Read(header);
if (!value || !value->is_dict()) {
LOG(ERROR) << "Failed to parse header: " << error;
LOG(ERROR) << "Failed to parse header";
return false;
}
header_size_ = 8 + size;
header_.reset(static_cast<base::DictionaryValue*>(value.release()));
header_ = base::DictionaryValue::From(
std::make_unique<base::Value>(value->Clone()));
return true;
}