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

Side by Side Diff: base/json/json_reader.cc

Issue 1124223012: Change JSONReader::ReadToValue to return a scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: chromedriver Created 5 years, 7 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 6
7 #include "base/json/json_parser.h" 7 #include "base/json/json_parser.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/values.h"
9 10
10 namespace base { 11 namespace base {
11 12
12 // Values 1000 and above are used by JSONFileValueSerializer::JsonFileError. 13 // Values 1000 and above are used by JSONFileValueSerializer::JsonFileError.
13 COMPILE_ASSERT(JSONReader::JSON_PARSE_ERROR_COUNT < 1000, 14 COMPILE_ASSERT(JSONReader::JSON_PARSE_ERROR_COUNT < 1000,
14 json_reader_error_out_of_bounds); 15 json_reader_error_out_of_bounds);
15 16
16 const char JSONReader::kInvalidEscape[] = 17 const char JSONReader::kInvalidEscape[] =
17 "Invalid escape sequence."; 18 "Invalid escape sequence.";
18 const char JSONReader::kSyntaxError[] = 19 const char JSONReader::kSyntaxError[] =
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 case JSON_UNSUPPORTED_ENCODING: 93 case JSON_UNSUPPORTED_ENCODING:
93 return kUnsupportedEncoding; 94 return kUnsupportedEncoding;
94 case JSON_UNQUOTED_DICTIONARY_KEY: 95 case JSON_UNQUOTED_DICTIONARY_KEY:
95 return kUnquotedDictionaryKey; 96 return kUnquotedDictionaryKey;
96 default: 97 default:
97 NOTREACHED(); 98 NOTREACHED();
98 return std::string(); 99 return std::string();
99 } 100 }
100 } 101 }
101 102
102 Value* JSONReader::ReadToValue(const std::string& json) { 103 scoped_ptr<Value> JSONReader::ReadToValue(const std::string& json) {
103 return parser_->Parse(json); 104 return make_scoped_ptr(parser_->Parse(json));
104 } 105 }
105 106
106 JSONReader::JsonParseError JSONReader::error_code() const { 107 JSONReader::JsonParseError JSONReader::error_code() const {
107 return parser_->error_code(); 108 return parser_->error_code();
108 } 109 }
109 110
110 std::string JSONReader::GetErrorMessage() const { 111 std::string JSONReader::GetErrorMessage() const {
111 return parser_->GetErrorMessage(); 112 return parser_->GetErrorMessage();
112 } 113 }
113 114
114 } // namespace base 115 } // namespace base
OLDNEW
« 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