From fb0777a30c7ea5962628f4f1b61feead00f5292f Mon Sep 17 00:00:00 2001 From: "gab@chromium.org" Date: Thu, 21 Nov 2013 07:44:09 +0000 Subject: Clarify the interface of JSONStringValueSerializer::Deserialize which can only return JSONParseError codes as an error_code. Also make sure JsonParseError codes do not go beyond JsonFileError codes which are used in conjunction for JSONFileValueSerializer. Review URL: https://codereview.chromium.org/71653002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@236445 0039d316-1c4b-4281-b951-d872f2087c98 --- base/json/json_reader.cc | 4 ++++ base/json/json_reader.h | 1 + base/json/json_string_value_serializer.h | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'base/json') diff --git a/base/json/json_reader.cc b/base/json/json_reader.cc index 593273e..cbf6c99 100644 --- a/base/json/json_reader.cc +++ b/base/json/json_reader.cc @@ -9,6 +9,10 @@ namespace base { +// Values 1000 and above are used by JSONFileValueSerializer::JsonFileError. +COMPILE_ASSERT(JSONReader::JSON_PARSE_ERROR_COUNT < 1000, + json_reader_error_out_of_bounds); + const char* JSONReader::kInvalidEscape = "Invalid escape sequence."; const char* JSONReader::kSyntaxError = diff --git a/base/json/json_reader.h b/base/json/json_reader.h index e602846..9b30687 100644 --- a/base/json/json_reader.h +++ b/base/json/json_reader.h @@ -73,6 +73,7 @@ class BASE_EXPORT JSONReader { JSON_UNEXPECTED_DATA_AFTER_ROOT, JSON_UNSUPPORTED_ENCODING, JSON_UNQUOTED_DICTIONARY_KEY, + JSON_PARSE_ERROR_COUNT }; // String versions of parse error codes. diff --git a/base/json/json_string_value_serializer.h b/base/json/json_string_value_serializer.h index 8aa3f95..014ef9f 100644 --- a/base/json/json_string_value_serializer.h +++ b/base/json/json_string_value_serializer.h @@ -47,7 +47,7 @@ class BASE_EXPORT JSONStringValueSerializer : public base::ValueSerializer { // Attempt to deserialize the data structure encoded in the string passed // in to the constructor into a structure of Value objects. If the return // value is NULL, and if |error_code| is non-null, |error_code| will - // contain an integer error code (either JsonFileError or JsonParseError). + // contain an integer error code (a JsonParseError in this case). // If |error_message| is non-null, it will be filled in with a formatted // error message including the location of the error if appropriate. // The caller takes ownership of the returned value. -- cgit v1.1