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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 bool UnionTraits<common::mojom::ValueDataView, std::unique_ptr<base::Value>>:: | 56 bool UnionTraits<common::mojom::ValueDataView, std::unique_ptr<base::Value>>:: |
57 Read(common::mojom::ValueDataView data, | 57 Read(common::mojom::ValueDataView data, |
58 std::unique_ptr<base::Value>* value_out) { | 58 std::unique_ptr<base::Value>* value_out) { |
59 switch (data.tag()) { | 59 switch (data.tag()) { |
60 case common::mojom::ValueDataView::Tag::NULL_VALUE: { | 60 case common::mojom::ValueDataView::Tag::NULL_VALUE: { |
61 *value_out = base::Value::CreateNullValue(); | 61 *value_out = base::Value::CreateNullValue(); |
62 return true; | 62 return true; |
63 } | 63 } |
64 case common::mojom::ValueDataView::Tag::BOOL_VALUE: { | 64 case common::mojom::ValueDataView::Tag::BOOL_VALUE: { |
65 *value_out = base::MakeUnique<base::FundamentalValue>(data.bool_value()); | 65 *value_out = base::MakeUnique<base::Value>(data.bool_value()); |
66 return true; | 66 return true; |
67 } | 67 } |
68 case common::mojom::ValueDataView::Tag::INT_VALUE: { | 68 case common::mojom::ValueDataView::Tag::INT_VALUE: { |
69 *value_out = base::MakeUnique<base::FundamentalValue>(data.int_value()); | 69 *value_out = base::MakeUnique<base::Value>(data.int_value()); |
70 return true; | 70 return true; |
71 } | 71 } |
72 case common::mojom::ValueDataView::Tag::DOUBLE_VALUE: { | 72 case common::mojom::ValueDataView::Tag::DOUBLE_VALUE: { |
73 *value_out = | 73 *value_out = base::MakeUnique<base::Value>(data.double_value()); |
74 base::MakeUnique<base::FundamentalValue>(data.double_value()); | |
75 return true; | 74 return true; |
76 } | 75 } |
77 case common::mojom::ValueDataView::Tag::STRING_VALUE: { | 76 case common::mojom::ValueDataView::Tag::STRING_VALUE: { |
78 base::StringPiece string_value; | 77 base::StringPiece string_value; |
79 if (!data.ReadStringValue(&string_value)) | 78 if (!data.ReadStringValue(&string_value)) |
80 return false; | 79 return false; |
81 *value_out = base::MakeUnique<base::StringValue>(string_value); | 80 *value_out = base::MakeUnique<base::StringValue>(string_value); |
82 return true; | 81 return true; |
83 } | 82 } |
84 case common::mojom::ValueDataView::Tag::BINARY_VALUE: { | 83 case common::mojom::ValueDataView::Tag::BINARY_VALUE: { |
(...skipping 16 matching lines...) Expand all Loading... |
101 if (!data.ReadListValue(&list_value)) | 100 if (!data.ReadListValue(&list_value)) |
102 return false; | 101 return false; |
103 *value_out = std::move(list_value); | 102 *value_out = std::move(list_value); |
104 return true; | 103 return true; |
105 } | 104 } |
106 } | 105 } |
107 return false; | 106 return false; |
108 } | 107 } |
109 | 108 |
110 } // namespace mojo | 109 } // namespace mojo |
OLD | NEW |