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

Side by Side Diff: base/values.cc

Issue 2475583002: Adds option for JSON reader to allow invalid utf characters (Closed)
Patch Set: cleanup Created 4 years, 1 month 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
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/values.h" 5 #include "base/values.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 default: 246 default:
247 NOTREACHED(); 247 NOTREACHED();
248 return false; 248 return false;
249 } 249 }
250 } 250 }
251 251
252 ///////////////////// StringValue //////////////////// 252 ///////////////////// StringValue ////////////////////
253 253
254 StringValue::StringValue(StringPiece in_value) 254 StringValue::StringValue(StringPiece in_value)
255 : Value(TYPE_STRING), value_(in_value.as_string()) { 255 : Value(TYPE_STRING), value_(in_value.as_string()) {
256 DCHECK(IsStringUTF8(in_value)); 256 // NOTE: no DCHECK that |in_value| is valid utf-8. We explicitly allow invalid
sky 2016/11/03 19:14:14 My rationale here for removing the DCHECK is that
257 // utf-8.
257 } 258 }
258 259
259 StringValue::StringValue(const string16& in_value) 260 StringValue::StringValue(const string16& in_value)
260 : Value(TYPE_STRING), 261 : Value(TYPE_STRING),
261 value_(UTF16ToUTF8(in_value)) { 262 value_(UTF16ToUTF8(in_value)) {
262 } 263 }
263 264
264 StringValue::~StringValue() { 265 StringValue::~StringValue() {
265 } 266 }
266 267
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 ValueDeserializer::~ValueDeserializer() { 1168 ValueDeserializer::~ValueDeserializer() {
1168 } 1169 }
1169 1170
1170 std::ostream& operator<<(std::ostream& out, const Value& value) { 1171 std::ostream& operator<<(std::ostream& out, const Value& value) {
1171 std::string json; 1172 std::string json;
1172 JSONWriter::WriteWithOptions(value, JSONWriter::OPTIONS_PRETTY_PRINT, &json); 1173 JSONWriter::WriteWithOptions(value, JSONWriter::OPTIONS_PRETTY_PRINT, &json);
1173 return out << json; 1174 return out << json;
1174 } 1175 }
1175 1176
1176 } // namespace base 1177 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698