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 30 matching lines...) Expand all Loading... |
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> | 48 std::unique_ptr<base::DictionaryValue> |
49 CloneTraits<std::unique_ptr<base::DictionaryValue>, false>::Clone( | 49 CloneTraits<std::unique_ptr<base::DictionaryValue>, false>::Clone( |
50 const std::unique_ptr<base::DictionaryValue>& input) { | 50 const std::unique_ptr<base::DictionaryValue>& input) { |
51 auto result = base::MakeUnique<base::DictionaryValue>(); | 51 return input ? input->CreateDeepCopy() : nullptr; |
52 result->MergeDictionary(input.get()); | |
53 return result; | |
54 } | 52 } |
55 | 53 |
56 bool UnionTraits<common::mojom::ValueDataView, std::unique_ptr<base::Value>>:: | 54 bool UnionTraits<common::mojom::ValueDataView, std::unique_ptr<base::Value>>:: |
57 Read(common::mojom::ValueDataView data, | 55 Read(common::mojom::ValueDataView data, |
58 std::unique_ptr<base::Value>* value_out) { | 56 std::unique_ptr<base::Value>* value_out) { |
59 switch (data.tag()) { | 57 switch (data.tag()) { |
60 case common::mojom::ValueDataView::Tag::NULL_VALUE: { | 58 case common::mojom::ValueDataView::Tag::NULL_VALUE: { |
61 *value_out = base::MakeUnique<base::Value>(); | 59 *value_out = base::MakeUnique<base::Value>(); |
62 return true; | 60 return true; |
63 } | 61 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 std::unique_ptr<base::ListValue> list_value; | 97 std::unique_ptr<base::ListValue> list_value; |
100 if (!data.ReadListValue(&list_value)) | 98 if (!data.ReadListValue(&list_value)) |
101 return false; | 99 return false; |
102 *value_out = std::move(list_value); | 100 *value_out = std::move(list_value); |
103 return true; | 101 return true; |
104 } | 102 } |
105 } | 103 } |
106 return false; | 104 return false; |
107 } | 105 } |
108 | 106 |
| 107 std::unique_ptr<base::Value> |
| 108 CloneTraits<std::unique_ptr<base::Value>, false>::Clone( |
| 109 const std::unique_ptr<base::Value>& input) { |
| 110 return input ? input->CreateDeepCopy() : nullptr; |
| 111 } |
| 112 |
109 } // namespace mojo | 113 } // namespace mojo |
OLD | NEW |