| 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 // This file specifies a recursive data storage class called Value intended for | 5 // This file specifies a recursive data storage class called Value intended for |
| 6 // storing settings and other persistable data. | 6 // storing settings and other persistable data. |
| 7 // | 7 // |
| 8 // A Value represents something that can be stored in JSON or passed to/from | 8 // A Value represents something that can be stored in JSON or passed to/from |
| 9 // JavaScript. As such, it is NOT a generalized variant type, since only the | 9 // JavaScript. As such, it is NOT a generalized variant type, since only the |
| 10 // types supported by JavaScript/JSON are supported. | 10 // types supported by JavaScript/JSON are supported. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 166 |
| 167 // Compares if two Value objects have equal contents. Can handle NULLs. | 167 // Compares if two Value objects have equal contents. Can handle NULLs. |
| 168 // NULLs are considered equal but different from Value::CreateNullValue(). | 168 // NULLs are considered equal but different from Value::CreateNullValue(). |
| 169 static bool Equals(const Value* a, const Value* b); | 169 static bool Equals(const Value* a, const Value* b); |
| 170 | 170 |
| 171 protected: | 171 protected: |
| 172 // TODO(crbug.com/646113): Make these private once DictionaryValue and | 172 // TODO(crbug.com/646113): Make these private once DictionaryValue and |
| 173 // ListValue are properly inlined. | 173 // ListValue are properly inlined. |
| 174 Type type_; | 174 Type type_; |
| 175 | 175 |
| 176 // TODO(crbug.com/697817): Remove after diagnosing the bug. |
| 177 bool alive_ = true; |
| 178 |
| 176 union { | 179 union { |
| 177 bool bool_value_; | 180 bool bool_value_; |
| 178 int int_value_; | 181 int int_value_; |
| 179 double double_value_; | 182 double double_value_; |
| 180 ManualConstructor<std::string> string_value_; | 183 ManualConstructor<std::string> string_value_; |
| 181 ManualConstructor<std::vector<char>> binary_value_; | 184 ManualConstructor<std::vector<char>> binary_value_; |
| 182 // For current gcc and clang sizeof(DictStorage) = 48, which would result | 185 // For current gcc and clang sizeof(DictStorage) = 48, which would result |
| 183 // in sizeof(Value) = 56 if DictStorage was stack allocated. Allocating it | 186 // in sizeof(Value) = 56 if DictStorage was stack allocated. Allocating it |
| 184 // on the heap results in sizeof(Value) = 40 for all of gcc, clang and MSVC. | 187 // on the heap results in sizeof(Value) = 40 for all of gcc, clang and MSVC. |
| 185 ManualConstructor<std::unique_ptr<DictStorage>> dict_ptr_; | 188 ManualConstructor<std::unique_ptr<DictStorage>> dict_ptr_; |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 return out << static_cast<const Value&>(value); | 517 return out << static_cast<const Value&>(value); |
| 515 } | 518 } |
| 516 | 519 |
| 517 // Stream operator so that enum class Types can be used in log statements. | 520 // Stream operator so that enum class Types can be used in log statements. |
| 518 BASE_EXPORT std::ostream& operator<<(std::ostream& out, | 521 BASE_EXPORT std::ostream& operator<<(std::ostream& out, |
| 519 const Value::Type& type); | 522 const Value::Type& type); |
| 520 | 523 |
| 521 } // namespace base | 524 } // namespace base |
| 522 | 525 |
| 523 #endif // BASE_VALUES_H_ | 526 #endif // BASE_VALUES_H_ |
| OLD | NEW |