| Index: chrome/common/json_value_serializer.h
|
| diff --git a/chrome/common/json_value_serializer.h b/chrome/common/json_value_serializer.h
|
| index 1f1e556e6f3114328da0f49ef8847a475d9e2502..7919cfea6b304d470d66290508ad933db23896d2 100644
|
| --- a/chrome/common/json_value_serializer.h
|
| +++ b/chrome/common/json_value_serializer.h
|
| @@ -41,9 +41,12 @@ class JSONStringValueSerializer : public 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 |error_message| is non-null, |error_message| will contain
|
| - // a string describing the error.
|
| - Value* Deserialize(std::string* error_message);
|
| + // value is NULL, and if |error_code| is non-null, |error_code| will
|
| + // contain an integer error code (either JsonFileError or JsonParseError).
|
| + // 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.
|
| + Value* Deserialize(int* error_code, std::string* error_message);
|
|
|
| void set_pretty_print(bool new_value) { pretty_print_ = new_value; }
|
| bool pretty_print() { return pretty_print_; }
|
| @@ -85,14 +88,39 @@ class JSONFileValueSerializer : public ValueSerializer {
|
|
|
| // Attempt to deserialize the data structure encoded in the file passed
|
| // in to the constructor into a structure of Value objects. If the return
|
| - // value is NULL, and if |error_message| is non-null, |error_message| will
|
| - // contain a string describing the error. The caller takes ownership of the
|
| - // returned value.
|
| - Value* Deserialize(std::string* error_message);
|
| + // value is NULL, and if |error_code| is non-null, |error_code| will
|
| + // contain an integer error code (either JsonFileError or JsonParseError).
|
| + // 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.
|
| + Value* Deserialize(int* error_code, std::string* error_message);
|
| +
|
| + // This enum is designed to safely overlap with JSONReader::JsonParseError.
|
| + enum JsonFileError {
|
| + JSON_NO_ERROR = 0,
|
| + JSON_ACCESS_DENIED = 1000,
|
| + JSON_CANNOT_READ_FILE,
|
| + JSON_FILE_LOCKED,
|
| + JSON_NO_SUCH_FILE
|
| + };
|
| +
|
| + // File-specific error messages that can be returned.
|
| + static const char* kAccessDenied;
|
| + static const char* kCannotReadFile;
|
| + static const char* kFileLocked;
|
| + static const char* kNoSuchFile;
|
| +
|
| + // Convert an error code into an error message. |error_code| is assumed to
|
| + // be a JsonFileError.
|
| + static const char* GetErrorMessageForCode(int error_code);
|
|
|
| private:
|
| FilePath json_file_path_;
|
|
|
| + // A wrapper for file_util::ReadFileToString which returns a non-zero
|
| + // JsonFileError if there were file errors.
|
| + int ReadFileToString(std::string* json_string);
|
| +
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(JSONFileValueSerializer);
|
| };
|
|
|
|
|