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

Unified Diff: base/json/json_reader.cc

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 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_reader.h ('k') | base/json/json_reader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/json/json_reader.cc
diff --git a/base/json/json_reader.cc b/base/json/json_reader.cc
index e17d450ebfae57cf065dc0ac205494de87e5f3b3..ad3ea98b31422b2ec98494d497487da36744f214 100644
--- a/base/json/json_reader.cc
+++ b/base/json/json_reader.cc
@@ -6,6 +6,7 @@
#include "base/json/json_parser.h"
#include "base/logging.h"
+#include "base/values.h"
namespace base {
@@ -42,34 +43,51 @@ JSONReader::~JSONReader() {
}
// static
-Value* JSONReader::Read(const StringPiece& json) {
+Value* JSONReader::DeprecatedRead(const StringPiece& json) {
+ return Read(json).release();
+}
+
+// static
+scoped_ptr<Value> JSONReader::Read(const StringPiece& json) {
internal::JSONParser parser(JSON_PARSE_RFC);
- return parser.Parse(json);
+ return make_scoped_ptr(parser.Parse(json));
}
// static
-Value* JSONReader::Read(const StringPiece& json,
- int options) {
- internal::JSONParser parser(options);
- return parser.Parse(json);
+Value* JSONReader::DeprecatedRead(const StringPiece& json, int options) {
+ return Read(json, options).release();
}
// static
-Value* JSONReader::ReadAndReturnError(const StringPiece& json,
- int options,
- int* error_code_out,
- std::string* error_msg_out) {
+scoped_ptr<Value> JSONReader::Read(const StringPiece& json, int options) {
internal::JSONParser parser(options);
- Value* root = parser.Parse(json);
- if (root)
- return root;
+ return make_scoped_ptr(parser.Parse(json));
+}
- if (error_code_out)
- *error_code_out = parser.error_code();
- if (error_msg_out)
- *error_msg_out = parser.GetErrorMessage();
+// static
+Value* JSONReader::DeprecatedReadAndReturnError(const StringPiece& json,
+ int options,
+ int* error_code_out,
+ std::string* error_msg_out) {
+ return ReadAndReturnError(json, options, error_code_out, error_msg_out)
+ .release();
+}
+
+// static
+scoped_ptr<Value> JSONReader::ReadAndReturnError(const StringPiece& json,
+ int options,
+ int* error_code_out,
+ std::string* error_msg_out) {
+ internal::JSONParser parser(options);
+ scoped_ptr<Value> root(parser.Parse(json));
+ if (!root) {
+ if (error_code_out)
+ *error_code_out = parser.error_code();
+ if (error_msg_out)
+ *error_msg_out = parser.GetErrorMessage();
+ }
- return NULL;
+ return root;
}
// static
@@ -99,8 +117,8 @@ std::string JSONReader::ErrorCodeToString(JsonParseError error_code) {
}
}
-Value* JSONReader::ReadToValue(const std::string& json) {
- return parser_->Parse(json);
+scoped_ptr<Value> JSONReader::ReadToValue(const std::string& json) {
+ return make_scoped_ptr(parser_->Parse(json));
}
JSONReader::JsonParseError JSONReader::error_code() const {
« no previous file with comments | « base/json/json_reader.h ('k') | base/json/json_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698