Commit 7e16321b authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

Check JSON value instead of error_code

Checking (result.error_code != JSON_NO_ERROR) is equivalent to checking
result.value (which has a base::Optional type, convertible to bool).

The error_code enum is really a private implementation detail. Callers
don't care about it (other than it being an error or no error). Removing
references (outside of //base/json) to that enum will let us more easily
modify the //base/json implementation.

Bug: 1070409
Change-Id: I95a739ee4dea283263106a64bed873c01f0ea60f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2147167Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759858}
parent f5d8192d
......@@ -54,7 +54,7 @@ std::unique_ptr<PrinterCache> ParsePrinters(std::unique_ptr<std::string> data) {
base::JSONReader::ReadAndReturnValueWithError(
*data, base::JSONParserOptions::JSON_ALLOW_TRAILING_COMMAS);
if (value_with_error.error_code != base::JSONReader::JSON_NO_ERROR) {
if (!value_with_error.value) {
LOG(WARNING) << "Failed to parse printers policy ("
<< value_with_error.error_message << ") on line "
<< value_with_error.error_line << " at position "
......
......@@ -54,7 +54,7 @@ TaskResults ParseData(int task_id, std::unique_ptr<std::string> data) {
base::JSONReader::ValueWithError value_with_error =
base::JSONReader::ReadAndReturnValueWithError(
*data, base::JSONParserOptions::JSON_ALLOW_TRAILING_COMMAS);
if (value_with_error.error_code != base::JSONReader::JSON_NO_ERROR) {
if (!value_with_error.value) {
LOG(WARNING) << "Failed to parse print servers policy ("
<< value_with_error.error_message << ") on line "
<< value_with_error.error_line << " at position "
......
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