| OLD | NEW |
| 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_parser.h" | 5 #include "base/json/json_parser.h" |
| 6 | 6 |
| 7 #include "base/float_util.h" | 7 #include "base/float_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 error_line_(0), | 201 error_line_(0), |
| 202 error_column_(0) { | 202 error_column_(0) { |
| 203 } | 203 } |
| 204 | 204 |
| 205 JSONParser::~JSONParser() { | 205 JSONParser::~JSONParser() { |
| 206 } | 206 } |
| 207 | 207 |
| 208 Value* JSONParser::Parse(const StringPiece& input) { | 208 Value* JSONParser::Parse(const StringPiece& input) { |
| 209 // TODO(rsesek): Windows has problems with StringPiece/hidden roots. Fix | 209 // TODO(rsesek): Windows has problems with StringPiece/hidden roots. Fix |
| 210 // <http://crbug.com/126107> when my Windows box arrives. | 210 // <http://crbug.com/126107> when my Windows box arrives. |
| 211 #if defined(OS_WIN) | 211 // For Android, swapping string doesn't mean swapping internal pointers |
| 212 // but swapping contents. Since it can't provide the performance gain, |
| 213 // set the below flag to disable the optimization and make it work. |
| 214 #if defined(OS_WIN) || defined(OS_ANDROID) |
| 212 options_ |= JSON_DETACHABLE_CHILDREN; | 215 options_ |= JSON_DETACHABLE_CHILDREN; |
| 213 #endif | 216 #endif |
| 214 | 217 |
| 215 std::string input_copy; | 218 std::string input_copy; |
| 216 // If the children of a JSON root can be detached, then hidden roots cannot | 219 // If the children of a JSON root can be detached, then hidden roots cannot |
| 217 // be used, so do not bother copying the input because StringPiece will not | 220 // be used, so do not bother copying the input because StringPiece will not |
| 218 // be used anywhere. | 221 // be used anywhere. |
| 219 if (!(options_ & JSON_DETACHABLE_CHILDREN)) { | 222 if (!(options_ & JSON_DETACHABLE_CHILDREN)) { |
| 220 input_copy = input.as_string(); | 223 input_copy = input.as_string(); |
| 221 start_pos_ = input_copy.data(); | 224 start_pos_ = input_copy.data(); |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 const std::string& description) { | 964 const std::string& description) { |
| 962 if (line || column) { | 965 if (line || column) { |
| 963 return StringPrintf("Line: %i, column: %i, %s", | 966 return StringPrintf("Line: %i, column: %i, %s", |
| 964 line, column, description.c_str()); | 967 line, column, description.c_str()); |
| 965 } | 968 } |
| 966 return description; | 969 return description; |
| 967 } | 970 } |
| 968 | 971 |
| 969 } // namespace internal | 972 } // namespace internal |
| 970 } // namespace base | 973 } // namespace base |
| OLD | NEW |