OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef MOJO_COMMON_VALUES_STRUCT_TRAITS_H_ | 5 #ifndef MOJO_COMMON_VALUES_STRUCT_TRAITS_H_ |
6 #define MOJO_COMMON_VALUES_STRUCT_TRAITS_H_ | 6 #define MOJO_COMMON_VALUES_STRUCT_TRAITS_H_ |
7 | 7 |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "mojo/common/values.mojom.h" | 9 #include "mojo/common/values.mojom.h" |
10 #include "mojo/public/cpp/bindings/array_traits.h" | 10 #include "mojo/public/cpp/bindings/array_traits.h" |
| 11 #include "mojo/public/cpp/bindings/clone_traits.h" |
11 #include "mojo/public/cpp/bindings/map_traits.h" | 12 #include "mojo/public/cpp/bindings/map_traits.h" |
12 #include "mojo/public/cpp/bindings/struct_traits.h" | 13 #include "mojo/public/cpp/bindings/struct_traits.h" |
13 #include "mojo/public/cpp/bindings/union_traits.h" | 14 #include "mojo/public/cpp/bindings/union_traits.h" |
14 | 15 |
15 namespace mojo { | 16 namespace mojo { |
16 | 17 |
17 template <> | 18 template <> |
18 struct ArrayTraits<base::ListValue> { | 19 struct ArrayTraits<base::ListValue> { |
19 using Element = std::unique_ptr<base::Value>; | 20 using Element = std::unique_ptr<base::Value>; |
20 using ConstIterator = base::ListValue::const_iterator; | 21 using ConstIterator = base::ListValue::const_iterator; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 103 |
103 static const base::DictionaryValue& values( | 104 static const base::DictionaryValue& values( |
104 const std::unique_ptr<base::DictionaryValue>& value) { | 105 const std::unique_ptr<base::DictionaryValue>& value) { |
105 return *value; | 106 return *value; |
106 } | 107 } |
107 static bool Read(common::mojom::DictionaryValueDataView data, | 108 static bool Read(common::mojom::DictionaryValueDataView data, |
108 std::unique_ptr<base::DictionaryValue>* value); | 109 std::unique_ptr<base::DictionaryValue>* value); |
109 }; | 110 }; |
110 | 111 |
111 template <> | 112 template <> |
| 113 struct CloneTraits<std::unique_ptr<base::DictionaryValue>, false> { |
| 114 static std::unique_ptr<base::DictionaryValue> Clone( |
| 115 const std::unique_ptr<base::DictionaryValue>& input); |
| 116 }; |
| 117 |
| 118 template <> |
112 struct UnionTraits<common::mojom::ValueDataView, base::Value> { | 119 struct UnionTraits<common::mojom::ValueDataView, base::Value> { |
113 static common::mojom::ValueDataView::Tag GetTag(const base::Value& data) { | 120 static common::mojom::ValueDataView::Tag GetTag(const base::Value& data) { |
114 switch (data.GetType()) { | 121 switch (data.GetType()) { |
115 case base::Value::Type::NONE: | 122 case base::Value::Type::NONE: |
116 return common::mojom::ValueDataView::Tag::NULL_VALUE; | 123 return common::mojom::ValueDataView::Tag::NULL_VALUE; |
117 case base::Value::Type::BOOLEAN: | 124 case base::Value::Type::BOOLEAN: |
118 return common::mojom::ValueDataView::Tag::BOOL_VALUE; | 125 return common::mojom::ValueDataView::Tag::BOOL_VALUE; |
119 case base::Value::Type::INTEGER: | 126 case base::Value::Type::INTEGER: |
120 return common::mojom::ValueDataView::Tag::INT_VALUE; | 127 return common::mojom::ValueDataView::Tag::INT_VALUE; |
121 case base::Value::Type::DOUBLE: | 128 case base::Value::Type::DOUBLE: |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 base::Value>::dictionary_value(*value); | 248 base::Value>::dictionary_value(*value); |
242 } | 249 } |
243 | 250 |
244 static bool Read(common::mojom::ValueDataView data, | 251 static bool Read(common::mojom::ValueDataView data, |
245 std::unique_ptr<base::Value>* value); | 252 std::unique_ptr<base::Value>* value); |
246 }; | 253 }; |
247 | 254 |
248 } // namespace mojo | 255 } // namespace mojo |
249 | 256 |
250 #endif // MOJO_COMMON_VALUES_STRUCT_TRAITS_H_ | 257 #endif // MOJO_COMMON_VALUES_STRUCT_TRAITS_H_ |
OLD | NEW |