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

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

Issue 10003001: Update JSONReader to take base::StringPiece instead of std::string (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Sync with Parser changes Created 8 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 unified diff | Download patch
« no previous file with comments | « base/json/json_reader.h ('k') | chrome/browser/plugin_finder.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 9
10 namespace base { 10 namespace base {
(...skipping 20 matching lines...) Expand all
31 } 31 }
32 32
33 JSONReader::JSONReader(int options) 33 JSONReader::JSONReader(int options)
34 : parser_(new internal::JSONParser(options)) { 34 : parser_(new internal::JSONParser(options)) {
35 } 35 }
36 36
37 JSONReader::~JSONReader() { 37 JSONReader::~JSONReader() {
38 } 38 }
39 39
40 // static 40 // static
41 Value* JSONReader::Read(const std::string& json) { 41 Value* JSONReader::Read(const StringPiece& json) {
42 internal::JSONParser parser(JSON_PARSE_RFC); 42 internal::JSONParser parser(JSON_PARSE_RFC);
43 return parser.Parse(json); 43 return parser.Parse(json);
44 } 44 }
45 45
46 // static 46 // static
47 Value* JSONReader::Read(const std::string& json, 47 Value* JSONReader::Read(const StringPiece& json,
48 int options) { 48 int options) {
49 internal::JSONParser parser(options); 49 internal::JSONParser parser(options);
50 return parser.Parse(json); 50 return parser.Parse(json);
51 } 51 }
52 52
53 // static 53 // static
54 Value* JSONReader::ReadAndReturnError(const std::string& json, 54 Value* JSONReader::ReadAndReturnError(const StringPiece& json,
55 int options, 55 int options,
56 int* error_code_out, 56 int* error_code_out,
57 std::string* error_msg_out) { 57 std::string* error_msg_out) {
58 internal::JSONParser parser(options); 58 internal::JSONParser parser(options);
59 Value* root = parser.Parse(json); 59 Value* root = parser.Parse(json);
60 if (root) 60 if (root)
61 return root; 61 return root;
62 62
63 if (error_code_out) 63 if (error_code_out)
64 *error_code_out = parser.error_code(); 64 *error_code_out = parser.error_code();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 JSONReader::JsonParseError JSONReader::error_code() const { 102 JSONReader::JsonParseError JSONReader::error_code() const {
103 return parser_->error_code(); 103 return parser_->error_code();
104 } 104 }
105 105
106 std::string JSONReader::GetErrorMessage() const { 106 std::string JSONReader::GetErrorMessage() const {
107 return parser_->GetErrorMessage(); 107 return parser_->GetErrorMessage();
108 } 108 }
109 109
110 } // namespace base 110 } // namespace base
OLDNEW
« no previous file with comments | « base/json/json_reader.h ('k') | chrome/browser/plugin_finder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698