summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-05 18:37:51 +0000
committerericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-05 18:37:51 +0000
commitb930d13574dc5dd5a7f6a2ea706f58d9f00959cc (patch)
tree670156bb42dfcf3876182d07bb60e88418e73f08
parent3f09649ae0477cf182033a8d3d507716372c31ad (diff)
downloadchromium_src-b930d13574dc5dd5a7f6a2ea706f58d9f00959cc.zip
chromium_src-b930d13574dc5dd5a7f6a2ea706f58d9f00959cc.tar.gz
chromium_src-b930d13574dc5dd5a7f6a2ea706f58d9f00959cc.tar.bz2
Update some comments/nits following r7486.
Review URL: http://codereview.chromium.org/17047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7547 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/json_reader.cc5
-rw-r--r--base/json_reader.h23
-rw-r--r--base/values.h2
-rw-r--r--chrome/common/json_value_serializer.cc4
-rw-r--r--chrome/common/json_value_serializer.h5
5 files changed, 19 insertions, 20 deletions
diff --git a/base/json_reader.cc b/base/json_reader.cc
index bf233a6..f3dfc75 100644
--- a/base/json_reader.cc
+++ b/base/json_reader.cc
@@ -136,7 +136,7 @@ Value* JSONReader::JsonToValue(const std::string& json, bool check_root,
// When the input JSON string starts with a UTF-8 Byte-Order-Mark
// (0xEF, 0xBB, 0xBF), the UTF8ToWide() function converts it to a Unicode
// BOM (U+FEFF). To avoid the JSONReader::BuildValue() function from
- // mis-treating a Unicode BOM as an invalid character and returning false,
+ // mis-treating a Unicode BOM as an invalid character and returning NULL,
// skip a converted Unicode BOM if it exists.
if (!json_wide.empty() && start_pos_[0] == 0xFEFF) {
++start_pos_;
@@ -217,9 +217,8 @@ Value* JSONReader::BuildValue(bool is_root) {
node.reset(new ListValue());
while (token.type != Token::ARRAY_END) {
Value* array_node = BuildValue(false);
- if (!array_node) {
+ if (!array_node)
return NULL;
- }
static_cast<ListValue*>(node.get())->Append(array_node);
// After a list value, we expect a comma or the end of the list.
diff --git a/base/json_reader.h b/base/json_reader.h
index 6231581..ac4ca1a 100644
--- a/base/json_reader.h
+++ b/base/json_reader.h
@@ -87,17 +87,17 @@ class JSONReader {
// Reads and parses |json|, returning a Value. The caller owns the returned
// instance. If |json| is not a properly formed JSON string, returns NULL.
- // If allow_trailing_comma is true, we will ignore trailing commas in objects
- // and arrays even though this goes against the RFC.
- static Value* Read(const std::string& json,
- bool allow_trailing_comma);
+ // If |allow_trailing_comma| is true, we will ignore trailing commas in
+ // objects and arrays even though this goes against the RFC.
+ static Value* Read(const std::string& json, bool allow_trailing_comma);
// Reads and parses |json| like Read(). |error_message_out| is optional. If
- // specified and NULL is returned, error_message_out will be populated with
- // a string describing the error. Otherwise, error_message_out is unmodified.
+ // specified and NULL is returned, |error_message_out| will be populated with
+ // a string describing the error. Otherwise, |error_message_out| is
+ // unmodified.
static Value* ReadAndReturnError(const std::string& json,
bool allow_trailing_comma,
- std::string *error_message_out);
+ std::string* error_message_out);
private:
static std::string FormatErrorMessage(int line, int column,
@@ -140,22 +140,21 @@ class JSONReader {
Token ParseStringToken();
// Convert the substring into a value string. This should always succeed
- // (otherwise ParseStringToken would have failed), but returns a success bool
- // just in case.
+ // (otherwise ParseStringToken would have failed).
Value* DecodeString(const Token& token);
// Grabs the next token in the JSON stream. This does not increment the
// stream so it can be used to look ahead at the next token.
Token ParseToken();
- // Increments json_pos_ past leading whitespace and comments.
+ // Increments |json_pos_| past leading whitespace and comments.
void EatWhitespaceAndComments();
- // If json_pos_ is at the start of a comment, eat it, otherwise, returns
+ // If |json_pos_| is at the start of a comment, eat it, otherwise, returns
// false.
bool EatComment();
- // Checks if json_pos_ matches str.
+ // Checks if |json_pos_| matches str.
bool NextStringMatch(const std::wstring& str);
// Creates the error message that will be returned to the caller. The current
diff --git a/base/values.h b/base/values.h
index ebd2117..6f2f9df 100644
--- a/base/values.h
+++ b/base/values.h
@@ -321,7 +321,7 @@ class ListValue : public Value {
// Removes the Value with the specified index from this list.
// If |out_value| is non-NULL, the removed Value AND ITS OWNERSHIP will be
- // passed out via out_value. If |out_value| is NULL, the removed value will
+ // passed out via |out_value|. If |out_value| is NULL, the removed value will
// be deleted. This method returns true if |index| is valid; otherwise
// it will return false and the ListValue object will be unchanged.
bool Remove(size_t index, Value** out_value);
diff --git a/chrome/common/json_value_serializer.cc b/chrome/common/json_value_serializer.cc
index 54afe7a..367b346 100644
--- a/chrome/common/json_value_serializer.cc
+++ b/chrome/common/json_value_serializer.cc
@@ -23,7 +23,7 @@ bool JSONStringValueSerializer::Serialize(const Value& root) {
Value* JSONStringValueSerializer::Deserialize(std::string* error_message) {
if (!json_string_)
- return false;
+ return NULL;
return JSONReader::ReadAndReturnError(*json_string_, allow_trailing_comma_,
error_message);
@@ -51,7 +51,7 @@ bool JSONFileValueSerializer::Serialize(const Value& root) {
Value* JSONFileValueSerializer::Deserialize(std::string* error_message) {
std::string json_string;
if (!file_util::ReadFileToString(json_file_path_, &json_string)) {
- return false;
+ return NULL;
}
JSONStringValueSerializer serializer(json_string);
return serializer.Deserialize(error_message);
diff --git a/chrome/common/json_value_serializer.h b/chrome/common/json_value_serializer.h
index 7a51528..71038fe 100644
--- a/chrome/common/json_value_serializer.h
+++ b/chrome/common/json_value_serializer.h
@@ -39,7 +39,7 @@ 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
+ // value is NULL and |error_message| is non-null, |error_message| will contain
// a string describing the error.
Value* Deserialize(std::string* error_message);
@@ -84,7 +84,8 @@ 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.
+ // contain a string describing the error. The caller takes ownership of the
+ // returned value.
Value* Deserialize(std::string* error_message);
private: