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 bool StructTraits<common::mojom::ListValueDataView, | 10 bool StructTraits<common::mojom::ListValueDataView, |
(...skipping 27 matching lines...) Expand all Loading... |
38 std::unique_ptr<base::Value> value; | 38 std::unique_ptr<base::Value> value; |
39 if (!view.keys().Read(i, &key) || !view.values().Read(i, &value)) | 39 if (!view.keys().Read(i, &key) || !view.values().Read(i, &value)) |
40 return false; | 40 return false; |
41 | 41 |
42 dictionary_value->SetWithoutPathExpansion(key, std::move(value)); | 42 dictionary_value->SetWithoutPathExpansion(key, std::move(value)); |
43 } | 43 } |
44 *value_out = std::move(dictionary_value); | 44 *value_out = std::move(dictionary_value); |
45 return true; | 45 return true; |
46 } | 46 } |
47 | 47 |
| 48 std::unique_ptr<base::DictionaryValue> |
| 49 CloneTraits<std::unique_ptr<base::DictionaryValue>, false>::Clone( |
| 50 const std::unique_ptr<base::DictionaryValue>& input) { |
| 51 auto result = base::MakeUnique<base::DictionaryValue>(); |
| 52 result->MergeDictionary(input.get()); |
| 53 return result; |
| 54 } |
| 55 |
48 bool UnionTraits<common::mojom::ValueDataView, std::unique_ptr<base::Value>>:: | 56 bool UnionTraits<common::mojom::ValueDataView, std::unique_ptr<base::Value>>:: |
49 Read(common::mojom::ValueDataView data, | 57 Read(common::mojom::ValueDataView data, |
50 std::unique_ptr<base::Value>* value_out) { | 58 std::unique_ptr<base::Value>* value_out) { |
51 switch (data.tag()) { | 59 switch (data.tag()) { |
52 case common::mojom::ValueDataView::Tag::NULL_VALUE: { | 60 case common::mojom::ValueDataView::Tag::NULL_VALUE: { |
53 *value_out = base::Value::CreateNullValue(); | 61 *value_out = base::Value::CreateNullValue(); |
54 return true; | 62 return true; |
55 } | 63 } |
56 case common::mojom::ValueDataView::Tag::BOOL_VALUE: { | 64 case common::mojom::ValueDataView::Tag::BOOL_VALUE: { |
57 *value_out = base::MakeUnique<base::FundamentalValue>(data.bool_value()); | 65 *value_out = base::MakeUnique<base::FundamentalValue>(data.bool_value()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 if (!data.ReadListValue(&list_value)) | 101 if (!data.ReadListValue(&list_value)) |
94 return false; | 102 return false; |
95 *value_out = std::move(list_value); | 103 *value_out = std::move(list_value); |
96 return true; | 104 return true; |
97 } | 105 } |
98 } | 106 } |
99 return false; | 107 return false; |
100 } | 108 } |
101 | 109 |
102 } // namespace mojo | 110 } // namespace mojo |
OLD | NEW |