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

Remove JSONReader::ValueWithError error_code field

There are two categories of base::ValueDeserializer error codes: content
errors (e.g. invalid syntax) and context errors (e.g. file not found,
network is down).

Callers do care about distinguishing between those categories, but
within the content category, callers don't care about e.g.
distinguishing JSON_TRAILING_COMMA from JSON_UNQUOTED_DICTIONARY_KEY,
except to show a human-readable error string, which is already available
in the JSONReader::ValueWithError error_message field.

The error_code field adds nothing interesting, and as per the commit
message to https://crrev.com/c/2251561 "Move JSONParser-specific enums
out of JSONReader", it has made it harder to experiment with different
JSON implementations. This commit deletes it.

Bug: 1069271
Bug: 1070409
Change-Id: If7b8a7ffd18e48a23b5e8071b4a83850ca3692a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2405336Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806855}
parent 48e1890c
......@@ -46,7 +46,6 @@ JSONReader::ValueWithError JSONReader::ReadAndReturnValueWithError(
ret.value = parser.Parse(json);
if (!ret.value) {
ret.error_message = parser.GetErrorMessage();
ret.error_code = parser.error_code();
ret.error_line = parser.error_line();
ret.error_column = parser.error_column();
}
......
......@@ -76,7 +76,6 @@ class BASE_EXPORT JSONReader {
// Contains default values if |value| exists, or the error status if |value|
// is base::nullopt.
int error_code = ValueDeserializer::kErrorCodeNoError;
std::string error_message;
int error_line = 0;
int error_column = 0;
......
......@@ -24,9 +24,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
JSONReader::ValueWithError json_val =
JSONReader::ReadAndReturnValueWithError(input_string, options);
CHECK((json_val.error_code == base::ValueDeserializer::kErrorCodeNoError) ==
json_val.value.has_value());
if (json_val.value) {
// Check that the value can be serialized and deserialized back to an
// equivalent |Value|.
......
......@@ -189,8 +189,6 @@ TEST(JSONReaderTest, Doubles) {
auto value_with_error =
JSONReader::ReadAndReturnValueWithError("1e1000", JSON_PARSE_RFC);
ASSERT_FALSE(value_with_error.value);
ASSERT_NE(base::ValueDeserializer::kErrorCodeNoError,
value_with_error.error_code);
}
TEST(JSONReaderTest, FractionalNumbers) {
......
......@@ -55,7 +55,7 @@ std::unique_ptr<Value> JSONStringValueDeserializer::Deserialize(
return base::Value::ToUniquePtrValue(std::move(*ret.value));
if (error_code)
*error_code = ret.error_code;
*error_code = base::ValueDeserializer::kErrorCodeInvalidFormat;
if (error_str)
*error_str = std::move(ret.error_message);
return nullptr;
......
......@@ -197,8 +197,6 @@ TEST_F(WKNavigationUtilTest, CreateRestoreSessionUrlForLargeSession) {
// Extract session JSON from restoration URL.
base::JSONReader::ValueWithError value_with_error =
ExtractSessionDict(restore_session_url);
ASSERT_EQ(base::ValueDeserializer::kErrorCodeNoError,
value_with_error.error_code);
ASSERT_TRUE(value_with_error.value.has_value());
// Verify that all titles and URLs are present.
......@@ -233,8 +231,6 @@ TEST_F(WKNavigationUtilTest, CreateRestoreSessionUrlForExtraLargeForwardList) {
// Extract session JSON from restoration URL.
base::JSONReader::ValueWithError value_with_error =
ExtractSessionDict(restore_session_url);
ASSERT_EQ(base::ValueDeserializer::kErrorCodeNoError,
value_with_error.error_code);
ASSERT_TRUE(value_with_error.value.has_value());
// Verify that first kMaxSessionSize titles and URLs are present.
......@@ -279,8 +275,6 @@ TEST_F(WKNavigationUtilTest, CreateRestoreSessionUrlForExtraLargeBackList) {
// Extract session JSON from restoration URL.
base::JSONReader::ValueWithError value_with_error =
ExtractSessionDict(restore_session_url);
ASSERT_EQ(base::ValueDeserializer::kErrorCodeNoError,
value_with_error.error_code);
ASSERT_TRUE(value_with_error.value.has_value());
// Verify that last kMaxSessionSize titles and URLs are present.
......@@ -326,8 +320,6 @@ TEST_F(WKNavigationUtilTest,
// Extract session JSON from restoration URL.
base::JSONReader::ValueWithError value_with_error =
ExtractSessionDict(restore_session_url);
ASSERT_EQ(base::ValueDeserializer::kErrorCodeNoError,
value_with_error.error_code);
ASSERT_TRUE(value_with_error.value.has_value());
// Verify that last kMaxSessionSize titles and URLs are present.
......
......@@ -81,8 +81,6 @@ MojoFacade::MessageNameAndArguments MojoFacade::GetMessageNameAndArguments(
base::JSON_PARSE_RFC);
CHECK(value_with_error.value);
CHECK(value_with_error.value->is_dict());
CHECK_EQ(base::ValueDeserializer::kErrorCodeNoError,
value_with_error.error_code);
const std::string* name = value_with_error.value->FindStringKey("name");
CHECK(name);
......
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