OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/float_util.h" |
7 #include "base/logging.h" | 8 #include "base/logging.h" |
8 #include "base/string_util.h" | 9 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
10 | 11 |
11 namespace { | 12 namespace { |
12 | 13 |
13 // Make a deep copy of |node|, but don't include empty lists or dictionaries | 14 // Make a deep copy of |node|, but don't include empty lists or dictionaries |
14 // in the copy. It's possible for this function to return NULL and it | 15 // in the copy. It's possible for this function to return NULL and it |
15 // expects |node| to always be non-NULL. | 16 // expects |node| to always be non-NULL. |
16 Value* CopyWithoutEmptyChildren(Value* node) { | 17 Value* CopyWithoutEmptyChildren(Value* node) { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 FundamentalValue::FundamentalValue(bool in_value) | 154 FundamentalValue::FundamentalValue(bool in_value) |
154 : Value(TYPE_BOOLEAN), boolean_value_(in_value) { | 155 : Value(TYPE_BOOLEAN), boolean_value_(in_value) { |
155 } | 156 } |
156 | 157 |
157 FundamentalValue::FundamentalValue(int in_value) | 158 FundamentalValue::FundamentalValue(int in_value) |
158 : Value(TYPE_INTEGER), integer_value_(in_value) { | 159 : Value(TYPE_INTEGER), integer_value_(in_value) { |
159 } | 160 } |
160 | 161 |
161 FundamentalValue::FundamentalValue(double in_value) | 162 FundamentalValue::FundamentalValue(double in_value) |
162 : Value(TYPE_DOUBLE), double_value_(in_value) { | 163 : Value(TYPE_DOUBLE), double_value_(in_value) { |
| 164 // JSON doesn't support NaN or positive or negative infinity. |
| 165 DCHECK(IsFinite(in_value)); |
163 } | 166 } |
164 | 167 |
165 FundamentalValue::~FundamentalValue() { | 168 FundamentalValue::~FundamentalValue() { |
166 } | 169 } |
167 | 170 |
168 bool FundamentalValue::GetAsBoolean(bool* out_value) const { | 171 bool FundamentalValue::GetAsBoolean(bool* out_value) const { |
169 if (out_value && IsType(TYPE_BOOLEAN)) | 172 if (out_value && IsType(TYPE_BOOLEAN)) |
170 *out_value = boolean_value_; | 173 *out_value = boolean_value_; |
171 return (IsType(TYPE_BOOLEAN)); | 174 return (IsType(TYPE_BOOLEAN)); |
172 } | 175 } |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 if (lhs_it != end() || rhs_it != other_list->end()) | 899 if (lhs_it != end() || rhs_it != other_list->end()) |
897 return false; | 900 return false; |
898 | 901 |
899 return true; | 902 return true; |
900 } | 903 } |
901 | 904 |
902 ValueSerializer::~ValueSerializer() { | 905 ValueSerializer::~ValueSerializer() { |
903 } | 906 } |
904 | 907 |
905 } // namespace base | 908 } // namespace base |
OLD | NEW |