| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 // Creates a BinaryValue, taking ownership of the bytes pointed to by | 176 // Creates a BinaryValue, taking ownership of the bytes pointed to by |
| 177 // |buffer|. | 177 // |buffer|. |
| 178 BinaryValue(std::unique_ptr<char[]> buffer, size_t size); | 178 BinaryValue(std::unique_ptr<char[]> buffer, size_t size); |
| 179 | 179 |
| 180 ~BinaryValue() override; | 180 ~BinaryValue() override; |
| 181 | 181 |
| 182 // For situations where you want to keep ownership of your buffer, this | 182 // For situations where you want to keep ownership of your buffer, this |
| 183 // factory method creates a new BinaryValue by copying the contents of the | 183 // factory method creates a new BinaryValue by copying the contents of the |
| 184 // buffer that's passed in. | 184 // buffer that's passed in. |
| 185 static BinaryValue* CreateWithCopiedBuffer(const char* buffer, size_t size); | 185 static std::unique_ptr<BinaryValue> CreateWithCopiedBuffer(const char* buffer, |
| 186 size_t size); |
| 186 | 187 |
| 187 size_t GetSize() const { return size_; } | 188 size_t GetSize() const { return size_; } |
| 188 | 189 |
| 189 // May return NULL. | 190 // May return NULL. |
| 190 char* GetBuffer() { return buffer_.get(); } | 191 char* GetBuffer() { return buffer_.get(); } |
| 191 const char* GetBuffer() const { return buffer_.get(); } | 192 const char* GetBuffer() const { return buffer_.get(); } |
| 192 | 193 |
| 193 // Overridden from Value: | 194 // Overridden from Value: |
| 194 bool GetAsBinary(const BinaryValue** out_value) const override; | 195 bool GetAsBinary(const BinaryValue** out_value) const override; |
| 195 BinaryValue* DeepCopy() const override; | 196 BinaryValue* DeepCopy() const override; |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 } | 560 } |
| 560 | 561 |
| 561 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, | 562 BASE_EXPORT inline std::ostream& operator<<(std::ostream& out, |
| 562 const ListValue& value) { | 563 const ListValue& value) { |
| 563 return out << static_cast<const Value&>(value); | 564 return out << static_cast<const Value&>(value); |
| 564 } | 565 } |
| 565 | 566 |
| 566 } // namespace base | 567 } // namespace base |
| 567 | 568 |
| 568 #endif // BASE_VALUES_H_ | 569 #endif // BASE_VALUES_H_ |
| OLD | NEW |