Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2153)

Unified Diff: base/json/json_string_value_serializer.cc

Issue 889303004: JSONStringValueSerializer: Constructor argument must not be null. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@calamity-doodle-static
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/json/json_string_value_serializer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/json_string_value_serializer.cc
diff --git a/base/json/json_string_value_serializer.cc b/base/json/json_string_value_serializer.cc
index 59f030dff2fd52418333218bcaeb3868295994be..b48f73c34269fa95a173c332ad1d71464a80303f 100644
--- a/base/json/json_string_value_serializer.cc
+++ b/base/json/json_string_value_serializer.cc
@@ -10,6 +10,22 @@
using base::Value;
+JSONStringValueSerializer::JSONStringValueSerializer(std::string* json_string)
+ : json_string_(json_string),
+ initialized_with_const_string_(false),
+ pretty_print_(false),
+ allow_trailing_comma_(false) {
+ DCHECK(json_string);
+}
+
+JSONStringValueSerializer::JSONStringValueSerializer(
+ const std::string& json_string)
+ : json_string_(&const_cast<std::string&>(json_string)),
+ initialized_with_const_string_(true),
+ pretty_print_(false),
+ allow_trailing_comma_(false) {
+}
+
JSONStringValueSerializer::~JSONStringValueSerializer() {}
bool JSONStringValueSerializer::Serialize(const Value& root) {
@@ -23,7 +39,7 @@ bool JSONStringValueSerializer::SerializeAndOmitBinaryValues(
bool JSONStringValueSerializer::SerializeInternal(const Value& root,
bool omit_binary_values) {
- if (!json_string_ || initialized_with_const_string_)
+ if (initialized_with_const_string_)
return false;
int options = 0;
@@ -37,9 +53,6 @@ bool JSONStringValueSerializer::SerializeInternal(const Value& root,
Value* JSONStringValueSerializer::Deserialize(int* error_code,
std::string* error_str) {
- if (!json_string_)
- return NULL;
-
return base::JSONReader::ReadAndReturnError(*json_string_,
allow_trailing_comma_ ? base::JSON_ALLOW_TRAILING_COMMAS :
base::JSON_PARSE_RFC,
« no previous file with comments | « base/json/json_string_value_serializer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698