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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 case common::mojom::ValueDataView::Tag::STRING_VALUE: { | 76 case common::mojom::ValueDataView::Tag::STRING_VALUE: { |
77 base::StringPiece string_value; | 77 base::StringPiece string_value; |
78 if (!data.ReadStringValue(&string_value)) | 78 if (!data.ReadStringValue(&string_value)) |
79 return false; | 79 return false; |
80 *value_out = base::MakeUnique<base::Value>(string_value); | 80 *value_out = base::MakeUnique<base::Value>(string_value); |
81 return true; | 81 return true; |
82 } | 82 } |
83 case common::mojom::ValueDataView::Tag::BINARY_VALUE: { | 83 case common::mojom::ValueDataView::Tag::BINARY_VALUE: { |
84 mojo::ArrayDataView<uint8_t> binary_data; | 84 mojo::ArrayDataView<uint8_t> binary_data; |
85 data.GetBinaryValueDataView(&binary_data); | 85 data.GetBinaryValueDataView(&binary_data); |
86 *value_out = base::BinaryValue::CreateWithCopiedBuffer( | 86 *value_out = base::Value::CreateWithCopiedBuffer( |
87 reinterpret_cast<const char*>(binary_data.data()), | 87 reinterpret_cast<const char*>(binary_data.data()), |
88 binary_data.size()); | 88 binary_data.size()); |
89 return true; | 89 return true; |
90 } | 90 } |
91 case common::mojom::ValueDataView::Tag::DICTIONARY_VALUE: { | 91 case common::mojom::ValueDataView::Tag::DICTIONARY_VALUE: { |
92 std::unique_ptr<base::DictionaryValue> dictionary_value; | 92 std::unique_ptr<base::DictionaryValue> dictionary_value; |
93 if (!data.ReadDictionaryValue(&dictionary_value)) | 93 if (!data.ReadDictionaryValue(&dictionary_value)) |
94 return false; | 94 return false; |
95 *value_out = std::move(dictionary_value); | 95 *value_out = std::move(dictionary_value); |
96 return true; | 96 return true; |
97 } | 97 } |
98 case common::mojom::ValueDataView::Tag::LIST_VALUE: { | 98 case common::mojom::ValueDataView::Tag::LIST_VALUE: { |
99 std::unique_ptr<base::ListValue> list_value; | 99 std::unique_ptr<base::ListValue> list_value; |
100 if (!data.ReadListValue(&list_value)) | 100 if (!data.ReadListValue(&list_value)) |
101 return false; | 101 return false; |
102 *value_out = std::move(list_value); | 102 *value_out = std::move(list_value); |
103 return true; | 103 return true; |
104 } | 104 } |
105 } | 105 } |
106 return false; | 106 return false; |
107 } | 107 } |
108 | 108 |
109 } // namespace mojo | 109 } // namespace mojo |
OLD | NEW |