Commit 709559a1 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: I2e67c7815fa8ce3e9ad784e85e236cf33558e8d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2147440Reviewed-by: default avatarAlex Gough <ajgo@chromium.org>
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759059}
parent 198130ea
......@@ -26,7 +26,7 @@ static void ConvertToValuesAndRespond(
for (auto&& item : *policies) {
auto snapshot = base::JSONReader::ReadAndReturnValueWithError(
item->JsonString(), base::JSON_PARSE_RFC);
CHECK(base::JSONReader::JSON_NO_ERROR == snapshot.error_code);
CHECK(snapshot.value);
policy_values.Append(std::move(snapshot.value.value()));
}
std::move(response).Run(std::move(policy_values));
......
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