| 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 // 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 setting and other persistable data. It includes the ability to | 6 // storing setting and other persistable data. It includes the ability to |
| 7 // specify (recursive) lists and dictionaries, so it's fairly expressive. | 7 // specify (recursive) lists and dictionaries, so it's fairly expressive. |
| 8 // However, the API is optimized for the common case, namely storing a | 8 // However, the API is optimized for the common case, namely storing a |
| 9 // hierarchical tree of simple values. Given a DictionaryValue root, you can | 9 // hierarchical tree of simple values. Given a DictionaryValue root, you can |
| 10 // easily do things like: | 10 // easily do things like: |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // this works because C++ supports covariant return types. | 106 // this works because C++ supports covariant return types. |
| 107 virtual Value* DeepCopy() const; | 107 virtual Value* DeepCopy() const; |
| 108 | 108 |
| 109 // Compares if two Value objects have equal contents. | 109 // Compares if two Value objects have equal contents. |
| 110 virtual bool Equals(const Value* other) const; | 110 virtual bool Equals(const Value* other) const; |
| 111 | 111 |
| 112 // Compares if two Value objects have equal contents. Can handle NULLs. | 112 // Compares if two Value objects have equal contents. Can handle NULLs. |
| 113 // NULLs are considered equal but different from Value::CreateNullValue(). | 113 // NULLs are considered equal but different from Value::CreateNullValue(). |
| 114 static bool Equals(const Value* a, const Value* b); | 114 static bool Equals(const Value* a, const Value* b); |
| 115 | 115 |
| 116 #if !defined(OS_CHROMEOS) | |
| 117 // NOTE: We pass Value from libcros tp Chrome, so changing the size of Value | |
| 118 // breaks it. TODO(stevenjb): Eliminate that dependency (crosbug.com/19576). | |
| 119 // TODO(sky) bug 91396: remove this when we figure out 91396. | |
| 120 // If true crash when deleted. | |
| 121 void set_check_on_delete(bool value) { check_on_delete_ = value; } | |
| 122 #else | |
| 123 void set_check_on_delete(bool value) {} | |
| 124 #endif | |
| 125 | |
| 126 protected: | 116 protected: |
| 127 // This isn't safe for end-users (they should use the Create*Value() | 117 // This isn't safe for end-users (they should use the Create*Value() |
| 128 // static methods above), but it's useful for subclasses. | 118 // static methods above), but it's useful for subclasses. |
| 129 explicit Value(Type type); | 119 explicit Value(Type type); |
| 130 | 120 |
| 131 private: | 121 private: |
| 122 Value(); |
| 123 |
| 132 Type type_; | 124 Type type_; |
| 133 | 125 |
| 134 #if !defined(OS_CHROMEOS) | |
| 135 // See description above setter. | |
| 136 bool check_on_delete_; | |
| 137 #endif | |
| 138 | |
| 139 DISALLOW_COPY_AND_ASSIGN(Value); | 126 DISALLOW_COPY_AND_ASSIGN(Value); |
| 140 }; | 127 }; |
| 141 | 128 |
| 142 // FundamentalValue represents the simple fundamental types of values. | 129 // FundamentalValue represents the simple fundamental types of values. |
| 143 class BASE_EXPORT FundamentalValue : public Value { | 130 class BASE_EXPORT FundamentalValue : public Value { |
| 144 public: | 131 public: |
| 145 explicit FundamentalValue(bool in_value); | 132 explicit FundamentalValue(bool in_value); |
| 146 explicit FundamentalValue(int in_value); | 133 explicit FundamentalValue(int in_value); |
| 147 explicit FundamentalValue(double in_value); | 134 explicit FundamentalValue(double in_value); |
| 148 virtual ~FundamentalValue(); | 135 virtual ~FundamentalValue(); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 | 461 |
| 475 } // namespace base | 462 } // namespace base |
| 476 | 463 |
| 477 // http://crbug.com/88666 | 464 // http://crbug.com/88666 |
| 478 using base::DictionaryValue; | 465 using base::DictionaryValue; |
| 479 using base::ListValue; | 466 using base::ListValue; |
| 480 using base::StringValue; | 467 using base::StringValue; |
| 481 using base::Value; | 468 using base::Value; |
| 482 | 469 |
| 483 #endif // BASE_VALUES_H_ | 470 #endif // BASE_VALUES_H_ |
| OLD | NEW |