0

Use base::JSONReader::ReadDeprecated() in various [h-z]* directories.

This is part of the process to help migrate base::JSONReader::Read() to
return base::Optional<base::Value>.

Do the same for ReadAndReturnError() and ReadToValue().

BUG=925165
TBR=eroman@chromium.org,pfeldman@chromium.org,sandersd@chromium.org,sergeyu@chromium.org,thakis@chromium.org

Change-Id: I0550baa36f24e6b27a4479543e55c8734c3c6956
Reviewed-on: https://chromium-review.googlesource.com/c/1476099
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632889}
This commit is contained in:
Lei Zhang
2019-02-16 03:02:03 +00:00
committed by Commit Bot
parent 4b8e54432d
commit a8b4c5fbfa
35 changed files with 76 additions and 59 deletions

@@ -131,7 +131,8 @@ int HeadlessDevToolsClientImpl::GetNextRawDevToolsMessageId() {
void HeadlessDevToolsClientImpl::SendRawDevToolsMessage( void HeadlessDevToolsClientImpl::SendRawDevToolsMessage(
const std::string& json_message) { const std::string& json_message) {
std::unique_ptr<base::Value> message = base::JSONReader::Read(json_message); std::unique_ptr<base::Value> message =
base::JSONReader::ReadDeprecated(json_message);
if (!message->is_dict()) { if (!message->is_dict()) {
LOG(ERROR) << "Malformed raw message"; LOG(ERROR) << "Malformed raw message";
return; return;
@@ -153,7 +154,7 @@ void HeadlessDevToolsClientImpl::ReceiveProtocolMessage(
const std::string& json_message) { const std::string& json_message) {
// LOG(ERROR) << "[RECV] " << json_message; // LOG(ERROR) << "[RECV] " << json_message;
std::unique_ptr<base::Value> message = std::unique_ptr<base::Value> message =
base::JSONReader::Read(json_message, base::JSON_PARSE_RFC); base::JSONReader::ReadDeprecated(json_message, base::JSON_PARSE_RFC);
if (!message || !message->is_dict()) { if (!message || !message->is_dict()) {
NOTREACHED() << "Badly formed reply " << json_message; NOTREACHED() << "Badly formed reply " << json_message;
return; return;

@@ -26,7 +26,7 @@ TEST(TypesTest, IntegerProperty) {
TEST(TypesTest, IntegerPropertyParseError) { TEST(TypesTest, IntegerPropertyParseError) {
const char json[] = "{\"entryId\": \"foo\"}"; const char json[] = "{\"entryId\": \"foo\"}";
std::unique_ptr<base::Value> object = base::JSONReader::Read(json); std::unique_ptr<base::Value> object = base::JSONReader::ReadDeprecated(json);
ASSERT_TRUE(object); ASSERT_TRUE(object);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
@@ -52,7 +52,7 @@ TEST(TypesTest, BooleanProperty) {
TEST(TypesTest, BooleanPropertyParseError) { TEST(TypesTest, BooleanPropertyParseError) {
const char json[] = "{\"suppressed\": \"foo\"}"; const char json[] = "{\"suppressed\": \"foo\"}";
std::unique_ptr<base::Value> object = base::JSONReader::Read(json); std::unique_ptr<base::Value> object = base::JSONReader::ReadDeprecated(json);
ASSERT_TRUE(object); ASSERT_TRUE(object);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
@@ -76,7 +76,7 @@ TEST(TypesTest, DoubleProperty) {
TEST(TypesTest, DoublePropertyParseError) { TEST(TypesTest, DoublePropertyParseError) {
const char json[] = "{\"latitude\": \"foo\"}"; const char json[] = "{\"latitude\": \"foo\"}";
std::unique_ptr<base::Value> object = base::JSONReader::Read(json); std::unique_ptr<base::Value> object = base::JSONReader::ReadDeprecated(json);
ASSERT_TRUE(object); ASSERT_TRUE(object);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
@@ -99,7 +99,7 @@ TEST(TypesTest, StringProperty) {
TEST(TypesTest, StringPropertyParseError) { TEST(TypesTest, StringPropertyParseError) {
const char json[] = "{\"url\": false}"; const char json[] = "{\"url\": false}";
std::unique_ptr<base::Value> object = base::JSONReader::Read(json); std::unique_ptr<base::Value> object = base::JSONReader::ReadDeprecated(json);
ASSERT_TRUE(object); ASSERT_TRUE(object);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
@@ -124,7 +124,7 @@ TEST(TypesTest, EnumProperty) {
TEST(TypesTest, EnumPropertyParseError) { TEST(TypesTest, EnumPropertyParseError) {
const char json[] = "{\"type\": false}"; const char json[] = "{\"type\": false}";
std::unique_ptr<base::Value> object = base::JSONReader::Read(json); std::unique_ptr<base::Value> object = base::JSONReader::ReadDeprecated(json);
ASSERT_TRUE(object); ASSERT_TRUE(object);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
@@ -162,7 +162,7 @@ TEST(TypesTest, ArrayProperty) {
TEST(TypesTest, ArrayPropertyParseError) { TEST(TypesTest, ArrayPropertyParseError) {
const char json[] = "{\"nodeIds\": true}"; const char json[] = "{\"nodeIds\": true}";
std::unique_ptr<base::Value> object = base::JSONReader::Read(json); std::unique_ptr<base::Value> object = base::JSONReader::ReadDeprecated(json);
ASSERT_TRUE(object); ASSERT_TRUE(object);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
@@ -191,7 +191,7 @@ TEST(TypesTest, ObjectProperty) {
TEST(TypesTest, ObjectPropertyParseError) { TEST(TypesTest, ObjectPropertyParseError) {
const char json[] = "{\"result\": 42}"; const char json[] = "{\"result\": 42}";
std::unique_ptr<base::Value> object = base::JSONReader::Read(json); std::unique_ptr<base::Value> object = base::JSONReader::ReadDeprecated(json);
ASSERT_TRUE(object); ASSERT_TRUE(object);
#if DCHECK_IS_ON() #if DCHECK_IS_ON()

@@ -145,7 +145,7 @@ class HeadlessJsBindingsTest
void OnMessageFromJS(const std::string& json_message) { void OnMessageFromJS(const std::string& json_message) {
std::unique_ptr<base::Value> message = std::unique_ptr<base::Value> message =
base::JSONReader::Read(json_message, base::JSON_PARSE_RFC); base::JSONReader::ReadDeprecated(json_message, base::JSON_PARSE_RFC);
const base::Value* method_value = message->FindKey("method"); const base::Value* method_value = message->FindKey("method");
if (!method_value) { if (!method_value) {
FinishAsynchronousTest(); FinishAsynchronousTest();

@@ -104,7 +104,8 @@ class HeadlessProtocolBrowserTest
// runtime::Observer implementation. // runtime::Observer implementation.
void OnBindingCalled(const runtime::BindingCalledParams& params) override { void OnBindingCalled(const runtime::BindingCalledParams& params) override {
std::string json_message = params.GetPayload(); std::string json_message = params.GetPayload();
std::unique_ptr<base::Value> message = base::JSONReader::Read(json_message); std::unique_ptr<base::Value> message =
base::JSONReader::ReadDeprecated(json_message);
const base::DictionaryValue* message_dict; const base::DictionaryValue* message_dict;
const base::DictionaryValue* params_dict; const base::DictionaryValue* params_dict;
std::string method; std::string method;

@@ -77,8 +77,8 @@ std::string SerializeP2PCandidate(const cricket::Candidate& candidate) {
bool DeserializeP2PCandidate(const std::string& candidate_str, bool DeserializeP2PCandidate(const std::string& candidate_str,
cricket::Candidate* candidate) { cricket::Candidate* candidate) {
std::unique_ptr<base::Value> value( std::unique_ptr<base::Value> value(base::JSONReader::ReadDeprecated(
base::JSONReader::Read(candidate_str, base::JSON_ALLOW_TRAILING_COMMAS)); candidate_str, base::JSON_ALLOW_TRAILING_COMMAS));
if (!value.get() || !value->is_dict()) { if (!value.get() || !value->is_dict()) {
return false; return false;
} }

@@ -199,7 +199,7 @@ class VideoDecoder::FakeImpl : public VideoDecoder::ImplBase {
// Make sure this is a JSON string. // Make sure this is a JSON string.
if (!len || data[0] != '{') if (!len || data[0] != '{')
return NULL; return NULL;
std::unique_ptr<base::Value> values(base::JSONReader::Read( std::unique_ptr<base::Value> values(base::JSONReader::ReadDeprecated(
base::StringPiece(reinterpret_cast<char*>(data), len))); base::StringPiece(reinterpret_cast<char*>(data), len)));
if (!values) if (!values)
return NULL; return NULL;

@@ -59,7 +59,8 @@ MATCHER(NotEmpty, "") {
} }
MATCHER(IsJSONDictionary, "") { MATCHER(IsJSONDictionary, "") {
std::string result(arg.begin(), arg.end()); std::string result(arg.begin(), arg.end());
std::unique_ptr<base::Value> root(base::JSONReader().ReadToValue(result)); std::unique_ptr<base::Value> root(
base::JSONReader().ReadToValueDeprecated(result));
return (root.get() && root->type() == base::Value::Type::DICTIONARY); return (root.get() && root->type() == base::Value::Type::DICTIONARY);
} }
MATCHER(IsNullTime, "") { MATCHER(IsNullTime, "") {

@@ -172,7 +172,8 @@ bool ExtractKeysFromJWKSet(const std::string& jwk_set,
return false; return false;
} }
std::unique_ptr<base::Value> root(base::JSONReader().ReadToValue(jwk_set)); std::unique_ptr<base::Value> root(
base::JSONReader().ReadToValueDeprecated(jwk_set));
if (!root.get() || root->type() != base::Value::Type::DICTIONARY) { if (!root.get() || root->type() != base::Value::Type::DICTIONARY) {
DVLOG(1) << "Not valid JSON: " << jwk_set << ", root: " << root.get(); DVLOG(1) << "Not valid JSON: " << jwk_set << ", root: " << root.get();
return false; return false;
@@ -241,7 +242,8 @@ bool ExtractKeyIdsFromKeyIdsInitData(const std::string& input,
return false; return false;
} }
std::unique_ptr<base::Value> root(base::JSONReader().ReadToValue(input)); std::unique_ptr<base::Value> root(
base::JSONReader().ReadToValueDeprecated(input));
if (!root.get() || root->type() != base::Value::Type::DICTIONARY) { if (!root.get() || root->type() != base::Value::Type::DICTIONARY) {
error_message->assign("Not valid JSON: "); error_message->assign("Not valid JSON: ");
error_message->append(ShortenTo64Characters(input)); error_message->append(ShortenTo64Characters(input));
@@ -375,7 +377,7 @@ bool ExtractFirstKeyIdFromLicenseRequest(const std::vector<uint8_t>& license,
} }
std::unique_ptr<base::Value> root( std::unique_ptr<base::Value> root(
base::JSONReader().ReadToValue(license_as_str)); base::JSONReader().ReadToValueDeprecated(license_as_str));
if (!root.get() || root->type() != base::Value::Type::DICTIONARY) { if (!root.get() || root->type() != base::Value::Type::DICTIONARY) {
DVLOG(1) << "Not valid JSON: " << license_as_str; DVLOG(1) << "Not valid JSON: " << license_as_str;
return false; return false;

@@ -103,7 +103,8 @@ bool Image::LoadMetadata() {
} }
base::JSONReader reader; base::JSONReader reader;
std::unique_ptr<base::Value> metadata(reader.ReadToValue(json_data)); std::unique_ptr<base::Value> metadata(
reader.ReadToValueDeprecated(json_data));
if (!metadata) { if (!metadata) {
VLOGF(1) << "Failed to parse image metadata: " << json_path << ": " VLOGF(1) << "Failed to parse image metadata: " << json_path << ": "
<< reader.GetErrorMessage(); << reader.GetErrorMessage();

@@ -124,7 +124,8 @@ bool Video::LoadMetadata() {
} }
base::JSONReader reader; base::JSONReader reader;
std::unique_ptr<base::Value> metadata(reader.ReadToValue(json_data)); std::unique_ptr<base::Value> metadata(
reader.ReadToValueDeprecated(json_data));
if (!metadata) { if (!metadata) {
VLOGF(1) << "Failed to parse video metadata: " << json_path << ": " VLOGF(1) << "Failed to parse video metadata: " << json_path << ": "
<< reader.GetErrorMessage(); << reader.GetErrorMessage();

@@ -54,8 +54,8 @@ base::DictionaryValue* ReadHeader(base::StringPiece* data) {
const base::StringPiece header_bytes(data->data(), header_len); const base::StringPiece header_bytes(data->data(), header_len);
data->remove_prefix(header_len); data->remove_prefix(header_len);
std::unique_ptr<base::Value> header = std::unique_ptr<base::Value> header = base::JSONReader::ReadDeprecated(
base::JSONReader::Read(header_bytes, base::JSON_ALLOW_TRAILING_COMMAS); header_bytes, base::JSON_ALLOW_TRAILING_COMMAS);
if (header.get() == nullptr) if (header.get() == nullptr)
return nullptr; return nullptr;

@@ -1242,7 +1242,7 @@ TEST_P(HttpServerPropertiesManagerTest,
} }
TEST_P(HttpServerPropertiesManagerTest, AddToAlternativeServiceMap) { TEST_P(HttpServerPropertiesManagerTest, AddToAlternativeServiceMap) {
std::unique_ptr<base::Value> server_value = base::JSONReader::Read( std::unique_ptr<base::Value> server_value = base::JSONReader::ReadDeprecated(
"{\"alternative_service\":[{\"port\":443,\"protocol_str\":\"h2\"}," "{\"alternative_service\":[{\"port\":443,\"protocol_str\":\"h2\"},"
"{\"port\":123,\"protocol_str\":\"quic\"," "{\"port\":123,\"protocol_str\":\"quic\","
"\"expiration\":\"9223372036854775807\"},{\"host\":\"example.org\"," "\"expiration\":\"9223372036854775807\"},{\"host\":\"example.org\","
@@ -1294,7 +1294,7 @@ TEST_P(HttpServerPropertiesManagerTest, AddToAlternativeServiceMap) {
// Regression test for https://crbug.com/615497. // Regression test for https://crbug.com/615497.
TEST_P(HttpServerPropertiesManagerTest, DoNotLoadAltSvcForInsecureOrigins) { TEST_P(HttpServerPropertiesManagerTest, DoNotLoadAltSvcForInsecureOrigins) {
std::unique_ptr<base::Value> server_value = base::JSONReader::Read( std::unique_ptr<base::Value> server_value = base::JSONReader::ReadDeprecated(
"{\"alternative_service\":[{\"port\":443,\"protocol_str\":\"h2\"," "{\"alternative_service\":[{\"port\":443,\"protocol_str\":\"h2\","
"\"expiration\":\"9223372036854775807\"}]}"); "\"expiration\":\"9223372036854775807\"}]}");
ASSERT_TRUE(server_value); ASSERT_TRUE(server_value);
@@ -1515,7 +1515,7 @@ TEST_P(HttpServerPropertiesManagerTest, PersistAdvertisedVersionsToPref) {
} }
TEST_P(HttpServerPropertiesManagerTest, ReadAdvertisedVersionsFromPref) { TEST_P(HttpServerPropertiesManagerTest, ReadAdvertisedVersionsFromPref) {
std::unique_ptr<base::Value> server_value = base::JSONReader::Read( std::unique_ptr<base::Value> server_value = base::JSONReader::ReadDeprecated(
"{\"alternative_service\":[" "{\"alternative_service\":["
"{\"port\":443,\"protocol_str\":\"quic\"}," "{\"port\":443,\"protocol_str\":\"quic\"},"
"{\"port\":123,\"protocol_str\":\"quic\"," "{\"port\":123,\"protocol_str\":\"quic\","
@@ -1686,7 +1686,7 @@ TEST_P(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
std::string expiration_str = std::string expiration_str =
base::NumberToString(static_cast<int64_t>(one_day_from_now_.ToTimeT())); base::NumberToString(static_cast<int64_t>(one_day_from_now_.ToTimeT()));
std::unique_ptr<base::Value> server_value = base::JSONReader::Read( std::unique_ptr<base::Value> server_value = base::JSONReader::ReadDeprecated(
"{" "{"
"\"broken_alternative_services\":[" "\"broken_alternative_services\":["
"{\"broken_until\":\"" + "{\"broken_until\":\"" +

@@ -292,7 +292,8 @@ bool TransportSecurityPersister::LoadEntries(const std::string& serialized,
bool TransportSecurityPersister::Deserialize(const std::string& serialized, bool TransportSecurityPersister::Deserialize(const std::string& serialized,
bool* dirty, bool* dirty,
TransportSecurityState* state) { TransportSecurityState* state) {
std::unique_ptr<base::Value> value = base::JSONReader::Read(serialized); std::unique_ptr<base::Value> value =
base::JSONReader::ReadDeprecated(serialized);
base::DictionaryValue* dict_value = NULL; base::DictionaryValue* dict_value = NULL;
if (!value.get() || !value->GetAsDictionary(&dict_value)) if (!value.get() || !value->GetAsDictionary(&dict_value))
return false; return false;

@@ -239,7 +239,7 @@ void CheckHPKPReport(
const scoped_refptr<X509Certificate>& served_certificate_chain, const scoped_refptr<X509Certificate>& served_certificate_chain,
const scoped_refptr<X509Certificate>& validated_certificate_chain, const scoped_refptr<X509Certificate>& validated_certificate_chain,
const HashValueVector& known_pins) { const HashValueVector& known_pins) {
std::unique_ptr<base::Value> value(base::JSONReader::Read(report)); std::unique_ptr<base::Value> value(base::JSONReader::ReadDeprecated(report));
ASSERT_TRUE(value); ASSERT_TRUE(value);
ASSERT_TRUE(value->is_dict()); ASSERT_TRUE(value->is_dict());

@@ -127,7 +127,7 @@ struct ParsedNetLog {
} }
base::JSONReader reader; base::JSONReader reader;
container = reader.ReadToValue(input); container = reader.ReadToValueDeprecated(input);
if (!container) { if (!container) {
return ::testing::AssertionFailure() << reader.GetErrorMessage(); return ::testing::AssertionFailure() << reader.GetErrorMessage();
} }

@@ -108,8 +108,8 @@ class TraceNetLogObserverTest : public TestWithScopedTaskEnvironment {
trace_buffer_.Finish(); trace_buffer_.Finish();
std::unique_ptr<base::Value> trace_value; std::unique_ptr<base::Value> trace_value;
trace_value = trace_value = base::JSONReader::ReadDeprecated(json_output_.json_output,
base::JSONReader::Read(json_output_.json_output, base::JSON_PARSE_RFC); base::JSON_PARSE_RFC);
ASSERT_TRUE(trace_value) << json_output_.json_output; ASSERT_TRUE(trace_value) << json_output_.json_output;
base::ListValue* trace_events = nullptr; base::ListValue* trace_events = nullptr;

@@ -403,8 +403,8 @@ class NetworkErrorLoggingServiceImpl : public NetworkErrorLoggingService {
if (json_value.size() > kMaxJsonSize) if (json_value.size() > kMaxJsonSize)
return HeaderOutcome::DISCARDED_JSON_TOO_BIG; return HeaderOutcome::DISCARDED_JSON_TOO_BIG;
std::unique_ptr<base::Value> value = std::unique_ptr<base::Value> value = base::JSONReader::ReadDeprecated(
base::JSONReader::Read(json_value, base::JSON_PARSE_RFC, kMaxJsonDepth); json_value, base::JSON_PARSE_RFC, kMaxJsonDepth);
if (!value) if (!value)
return HeaderOutcome::DISCARDED_JSON_INVALID; return HeaderOutcome::DISCARDED_JSON_INVALID;

@@ -37,7 +37,7 @@ void FuzzReportingHeaderParser(const std::string& data_json,
// Emulate what ReportingService::OnHeader does before calling // Emulate what ReportingService::OnHeader does before calling
// ReportingHeaderParser::ParseHeader. // ReportingHeaderParser::ParseHeader.
std::unique_ptr<base::Value> data_value = std::unique_ptr<base::Value> data_value =
base::JSONReader::Read("[" + data_json + "]"); base::JSONReader::ReadDeprecated("[" + data_json + "]");
if (!data_value) if (!data_value)
return; return;

@@ -26,7 +26,7 @@ class ReportingHeaderParserTest : public ReportingTestBase {
protected: protected:
void ParseHeader(const GURL& url, const std::string& json) { void ParseHeader(const GURL& url, const std::string& json) {
std::unique_ptr<base::Value> value = std::unique_ptr<base::Value> value =
base::JSONReader::Read("[" + json + "]"); base::JSONReader::ReadDeprecated("[" + json + "]");
if (value) if (value)
ReportingHeaderParser::ParseHeader(context(), url, std::move(value)); ReportingHeaderParser::ParseHeader(context(), url, std::move(value));
} }

@@ -66,8 +66,9 @@ class ReportingServiceImpl : public ReportingService {
return; return;
} }
std::unique_ptr<base::Value> header_value = base::JSONReader::Read( std::unique_ptr<base::Value> header_value =
"[" + header_string + "]", base::JSON_PARSE_RFC, kMaxJsonDepth); base::JSONReader::ReadDeprecated("[" + header_string + "]",
base::JSON_PARSE_RFC, kMaxJsonDepth);
if (!header_value) { if (!header_value) {
ReportingHeaderParser::RecordHeaderDiscardedForJsonInvalid(); ReportingHeaderParser::RecordHeaderDiscardedForJsonInvalid();
return; return;

@@ -53,7 +53,7 @@ class PendingUploadImpl : public TestReportingUploader::PendingUpload {
const GURL& url() const override { return url_; } const GURL& url() const override { return url_; }
const std::string& json() const override { return json_; } const std::string& json() const override { return json_; }
std::unique_ptr<base::Value> GetValue() const override { std::unique_ptr<base::Value> GetValue() const override {
return base::JSONReader::Read(json_); return base::JSONReader::ReadDeprecated(json_);
} }
void Complete(ReportingUploader::Outcome outcome) override { void Complete(ReportingUploader::Outcome outcome) override {

@@ -502,7 +502,8 @@ bool BaseTestServer::SetAndParseServerData(const std::string& server_data,
int* port) { int* port) {
VLOG(1) << "Server data: " << server_data; VLOG(1) << "Server data: " << server_data;
base::JSONReader json_reader; base::JSONReader json_reader;
std::unique_ptr<base::Value> value(json_reader.ReadToValue(server_data)); std::unique_ptr<base::Value> value(
json_reader.ReadToValueDeprecated(server_data));
if (!value.get() || !value->is_dict()) { if (!value.get() || !value->is_dict()) {
LOG(ERROR) << "Could not parse server data: " LOG(ERROR) << "Could not parse server data: "
<< json_reader.GetErrorMessage(); << json_reader.GetErrorMessage();

@@ -59,8 +59,8 @@ RemoteTestServerConfig RemoteTestServerConfig::Load() {
if (!ReadFileToString(config_path, &config_json)) if (!ReadFileToString(config_path, &config_json))
LOG(FATAL) << "Failed to read " << config_path.value(); LOG(FATAL) << "Failed to read " << config_path.value();
std::unique_ptr<base::DictionaryValue> config = std::unique_ptr<base::DictionaryValue> config = base::DictionaryValue::From(
base::DictionaryValue::From(base::JSONReader::Read(config_json)); base::JSONReader::ReadDeprecated(config_json));
if (!config) if (!config)
LOG(FATAL) << "Failed to parse " << config_path.value(); LOG(FATAL) << "Failed to parse " << config_path.value();

@@ -62,7 +62,7 @@ bool ReadTestCase(const char* filename,
return false; return false;
} }
std::unique_ptr<base::Value> value = base::JSONReader::Read(json); std::unique_ptr<base::Value> value = base::JSONReader::ReadDeprecated(json);
if (!value.get()) { if (!value.get()) {
LOG(ERROR) << filename << ": couldn't parse JSON."; LOG(ERROR) << filename << ": couldn't parse JSON.";
return false; return false;

@@ -310,7 +310,7 @@ bool ParseJSON(base::StringPiece json,
"test", "public-suffix", "google", "custom", "test", "public-suffix", "google", "custom",
"bulk-legacy", "bulk-18-weeks", "bulk-1-year", "public-suffix-requested"}; "bulk-legacy", "bulk-18-weeks", "bulk-1-year", "public-suffix-requested"};
std::unique_ptr<base::Value> value = base::JSONReader::Read(json); std::unique_ptr<base::Value> value = base::JSONReader::ReadDeprecated(json);
base::DictionaryValue* dict_value = nullptr; base::DictionaryValue* dict_value = nullptr;
if (!value.get() || !value->GetAsDictionary(&dict_value)) { if (!value.get() || !value->GetAsDictionary(&dict_value)) {
LOG(ERROR) << "Could not parse the input JSON file"; LOG(ERROR) << "Could not parse the input JSON file";

@@ -6664,7 +6664,7 @@ TEST_F(URLRequestTestHTTP, ProcessPKPAndSendReport) {
EXPECT_EQ("application/json; charset=utf-8", EXPECT_EQ("application/json; charset=utf-8",
mock_report_sender.latest_content_type()); mock_report_sender.latest_content_type());
std::unique_ptr<base::Value> value( std::unique_ptr<base::Value> value(
base::JSONReader::Read(mock_report_sender.latest_report())); base::JSONReader::ReadDeprecated(mock_report_sender.latest_report()));
ASSERT_TRUE(value); ASSERT_TRUE(value);
ASSERT_TRUE(value->is_dict()); ASSERT_TRUE(value->is_dict());
base::DictionaryValue* report_dict; base::DictionaryValue* report_dict;

@@ -47,7 +47,8 @@ const char kPrinterSettings[] = R"({
} }
TEST(PrintSettingsConversionTest, ConversionTest) { TEST(PrintSettingsConversionTest, ConversionTest) {
std::unique_ptr<base::Value> value = base::JSONReader::Read(kPrinterSettings); std::unique_ptr<base::Value> value =
base::JSONReader::ReadDeprecated(kPrinterSettings);
ASSERT_TRUE(value); ASSERT_TRUE(value);
PrintSettings settings; PrintSettings settings;
bool success = PrintSettingsFromJobSettings( bool success = PrintSettingsFromJobSettings(
@@ -61,7 +62,8 @@ TEST(PrintSettingsConversionTest, ConversionTest) {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
TEST(PrintSettingsConversionTest, ConversionTest_DontSendUsername) { TEST(PrintSettingsConversionTest, ConversionTest_DontSendUsername) {
std::unique_ptr<base::Value> value = base::JSONReader::Read(kPrinterSettings); std::unique_ptr<base::Value> value =
base::JSONReader::ReadDeprecated(kPrinterSettings);
ASSERT_TRUE(value); ASSERT_TRUE(value);
value->SetKey(kSettingSendUserInfo, base::Value(false)); value->SetKey(kSettingSendUserInfo, base::Value(false));
PrintSettings settings; PrintSettings settings;

@@ -28,7 +28,8 @@ bool OriginPolicyParser::DoParse(base::StringPiece policy_text) {
if (policy_text.empty()) if (policy_text.empty())
return false; return false;
std::unique_ptr<base::Value> json = base::JSONReader::Read(policy_text); std::unique_ptr<base::Value> json =
base::JSONReader::ReadDeprecated(policy_text);
if (!json || !json->is_dict()) if (!json || !json->is_dict())
return false; return false;

@@ -168,8 +168,8 @@ std::unique_ptr<TrialToken> TrialToken::Parse(
return nullptr; return nullptr;
} }
std::unique_ptr<base::DictionaryValue> datadict = std::unique_ptr<base::DictionaryValue> datadict = base::DictionaryValue::From(
base::DictionaryValue::From(base::JSONReader::Read(token_payload)); base::JSONReader::ReadDeprecated(token_payload));
if (!datadict) { if (!datadict) {
return nullptr; return nullptr;
} }

@@ -136,7 +136,7 @@ std::unique_ptr<Value> StringUtil::parseMessage(
reinterpret_cast<const uint8_t*>(message.data()), reinterpret_cast<const uint8_t*>(message.data()),
message.length()); message.length());
} }
std::unique_ptr<base::Value> value = base::JSONReader::Read(message); std::unique_ptr<base::Value> value = base::JSONReader::ReadDeprecated(message);
return toProtocolValue(value.get(), 1000); return toProtocolValue(value.get(), 1000);
} }

@@ -28,7 +28,7 @@ namespace {
// |json| is converted to a |c_str()| here because rapidjson and other parts // |json| is converted to a |c_str()| here because rapidjson and other parts
// of the standalone library use char* rather than std::string. // of the standalone library use char* rather than std::string.
::std::unique_ptr<const base::Value> parsed( ::std::unique_ptr<const base::Value> parsed(
base::JSONReader::Read(json.c_str())); base::JSONReader::ReadDeprecated(json.c_str()));
*parser_error = !parsed || !parsed->is_dict(); *parser_error = !parsed || !parsed->is_dict();
if (*parser_error) if (*parser_error)

@@ -16,8 +16,9 @@ namespace test_util {
std::unique_ptr<base::Value> ReadJson(const base::StringPiece& json) { std::unique_ptr<base::Value> ReadJson(const base::StringPiece& json) {
int error_code; int error_code;
std::string error_msg; std::string error_msg;
std::unique_ptr<base::Value> result(base::JSONReader::ReadAndReturnError( std::unique_ptr<base::Value> result(
json, base::JSON_ALLOW_TRAILING_COMMAS, &error_code, &error_msg)); base::JSONReader::ReadAndReturnErrorDeprecated(
json, base::JSON_ALLOW_TRAILING_COMMAS, &error_code, &error_msg));
// CHECK not ASSERT since passing invalid |json| is a test error. // CHECK not ASSERT since passing invalid |json| is a test error.
CHECK(result) << error_msg; CHECK(result) << error_msg;
return result; return result;

@@ -983,7 +983,8 @@ TEST_F(LayerWithNullDelegateTest, EscapedDebugNames) {
std::string json; std::string json;
debug_info->AppendAsTraceFormat(&json); debug_info->AppendAsTraceFormat(&json);
base::JSONReader json_reader; base::JSONReader json_reader;
std::unique_ptr<base::Value> debug_info_value(json_reader.ReadToValue(json)); std::unique_ptr<base::Value> debug_info_value(
json_reader.ReadToValueDeprecated(json));
EXPECT_TRUE(debug_info_value); EXPECT_TRUE(debug_info_value);
EXPECT_TRUE(debug_info_value->is_dict()); EXPECT_TRUE(debug_info_value->is_dict());
base::DictionaryValue* dictionary = 0; base::DictionaryValue* dictionary = 0;

@@ -49,8 +49,9 @@ TEST(JsonConverterTest, JsonFromToDisplayLayout) {
"}"; "}";
int error_code = 0, error_line, error_column; int error_code = 0, error_line, error_column;
std::string error_msg; std::string error_msg;
std::unique_ptr<base::Value> read_value(base::JSONReader::ReadAndReturnError( std::unique_ptr<base::Value> read_value(
data, 0, &error_code, &error_msg, &error_line, &error_column)); base::JSONReader::ReadAndReturnErrorDeprecated(
data, 0, &error_code, &error_msg, &error_line, &error_column));
ASSERT_EQ(0, error_code) << error_msg << " at " << error_line << ":" ASSERT_EQ(0, error_code) << error_msg << " at " << error_line << ":"
<< error_column; << error_column;
EXPECT_TRUE(value.Equals(read_value.get())); EXPECT_TRUE(value.Equals(read_value.get()));
@@ -72,8 +73,9 @@ TEST(JsonConverterTest, OldJsonToDisplayLayout) {
"}"; "}";
int error_code = 0, error_line, error_column; int error_code = 0, error_line, error_column;
std::string error_msg; std::string error_msg;
std::unique_ptr<base::Value> read_value(base::JSONReader::ReadAndReturnError( std::unique_ptr<base::Value> read_value(
data, 0, &error_code, &error_msg, &error_line, &error_column)); base::JSONReader::ReadAndReturnErrorDeprecated(
data, 0, &error_code, &error_msg, &error_line, &error_column));
ASSERT_EQ(0, error_code) << error_msg << " at " << error_line << ":" ASSERT_EQ(0, error_code) << error_msg << " at " << error_line << ":"
<< error_column; << error_column;

@@ -16,7 +16,7 @@ CaptionStyle::~CaptionStyle() = default;
// static // static
CaptionStyle CaptionStyle::FromSpec(const std::string& spec) { CaptionStyle CaptionStyle::FromSpec(const std::string& spec) {
CaptionStyle style; CaptionStyle style;
std::unique_ptr<base::Value> dict = base::JSONReader::Read(spec); std::unique_ptr<base::Value> dict = base::JSONReader::ReadDeprecated(spec);
if (!dict || !dict->is_dict()) if (!dict || !dict->is_dict())
return style; return style;