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 #include "base/memory/ptr_util.h" | 5 #include "base/memory/ptr_util.h" |
6 #include "mojo/common/values_struct_traits.h" | 6 #include "mojo/common/values_struct_traits.h" |
7 | 7 |
8 namespace mojo { | 8 namespace mojo { |
9 | 9 |
| 10 namespace internal { |
| 11 |
| 12 std::unique_ptr<base::DictionaryValue> |
| 13 CloneTraits<std::unique_ptr<base::DictionaryValue>, false>::Clone( |
| 14 const std::unique_ptr<base::DictionaryValue>& input) { |
| 15 auto result = base::MakeUnique<base::DictionaryValue>(); |
| 16 result->MergeDictionary(input.get()); |
| 17 return result; |
| 18 } |
| 19 |
| 20 } // namespace internal |
| 21 |
10 bool StructTraits<common::mojom::ListValueDataView, | 22 bool StructTraits<common::mojom::ListValueDataView, |
11 std::unique_ptr<base::ListValue>>:: | 23 std::unique_ptr<base::ListValue>>:: |
12 Read(common::mojom::ListValueDataView data, | 24 Read(common::mojom::ListValueDataView data, |
13 std::unique_ptr<base::ListValue>* value_out) { | 25 std::unique_ptr<base::ListValue>* value_out) { |
14 mojo::ArrayDataView<common::mojom::ValueDataView> view; | 26 mojo::ArrayDataView<common::mojom::ValueDataView> view; |
15 data.GetValuesDataView(&view); | 27 data.GetValuesDataView(&view); |
16 | 28 |
17 auto list_value = base::MakeUnique<base::ListValue>(); | 29 auto list_value = base::MakeUnique<base::ListValue>(); |
18 for (size_t i = 0; i < view.size(); ++i) { | 30 for (size_t i = 0; i < view.size(); ++i) { |
19 std::unique_ptr<base::Value> value; | 31 std::unique_ptr<base::Value> value; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 if (!data.ReadListValue(&list_value)) | 105 if (!data.ReadListValue(&list_value)) |
94 return false; | 106 return false; |
95 *value_out = std::move(list_value); | 107 *value_out = std::move(list_value); |
96 return true; | 108 return true; |
97 } | 109 } |
98 } | 110 } |
99 return false; | 111 return false; |
100 } | 112 } |
101 | 113 |
102 } // namespace mojo | 114 } // namespace mojo |
OLD | NEW |