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 #ifndef COMPONENTS_ARC_BLUETOOTH_BLUETOOTH_STRUCT_TRAITS_H_ | 5 #ifndef COMPONENTS_ARC_BLUETOOTH_BLUETOOTH_STRUCT_TRAITS_H_ |
6 #define COMPONENTS_ARC_BLUETOOTH_BLUETOOTH_STRUCT_TRAITS_H_ | 6 #define COMPONENTS_ARC_BLUETOOTH_BLUETOOTH_STRUCT_TRAITS_H_ |
7 | 7 |
8 #include <map> | |
9 #include <utility> | |
10 #include <vector> | |
11 | |
8 #include "components/arc/common/bluetooth.mojom.h" | 12 #include "components/arc/common/bluetooth.mojom.h" |
9 #include "device/bluetooth/bluetooth_common.h" | 13 #include "device/bluetooth/bluetooth_common.h" |
14 #include "device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h" | |
15 #include "device/bluetooth/bluez/bluetooth_service_record_bluez.h" | |
16 #include "ipc/ipc_message_utils.h" | |
10 | 17 |
11 namespace mojo { | 18 namespace mojo { |
12 | 19 |
13 template <> | 20 template <> |
14 struct EnumTraits<arc::mojom::BluetoothDeviceType, | 21 struct EnumTraits<arc::mojom::BluetoothDeviceType, |
15 device::BluetoothTransport> { | 22 device::BluetoothTransport> { |
16 static arc::mojom::BluetoothDeviceType ToMojom( | 23 static arc::mojom::BluetoothDeviceType ToMojom( |
17 device::BluetoothTransport type) { | 24 device::BluetoothTransport type) { |
18 switch (type) { | 25 switch (type) { |
19 case device::BLUETOOTH_TRANSPORT_CLASSIC: | 26 case device::BLUETOOTH_TRANSPORT_CLASSIC: |
(...skipping 22 matching lines...) Expand all Loading... | |
42 *type = device::BLUETOOTH_TRANSPORT_DUAL; | 49 *type = device::BLUETOOTH_TRANSPORT_DUAL; |
43 break; | 50 break; |
44 default: | 51 default: |
45 NOTREACHED() << "Invalid type: " << static_cast<uint32_t>(mojom_type); | 52 NOTREACHED() << "Invalid type: " << static_cast<uint32_t>(mojom_type); |
46 return false; | 53 return false; |
47 } | 54 } |
48 return true; | 55 return true; |
49 } | 56 } |
50 }; | 57 }; |
51 | 58 |
59 template <> | |
60 struct EnumTraits<arc::mojom::BluetoothSdpAttrType, | |
61 bluez::BluetoothServiceAttributeValueBlueZ::Type> { | |
62 static arc::mojom::BluetoothSdpAttrType ToMojom( | |
63 bluez::BluetoothServiceAttributeValueBlueZ::Type input); | |
64 static bool FromMojom( | |
65 arc::mojom::BluetoothSdpAttrType input, | |
66 bluez::BluetoothServiceAttributeValueBlueZ::Type* output); | |
67 }; | |
68 | |
69 template <> | |
70 struct StructTraits<arc::mojom::BluetoothSdpServiceAttr, | |
71 bluez::BluetoothServiceAttributeValueBlueZ> { | |
72 static bluez::BluetoothServiceAttributeValueBlueZ::Type type( | |
73 const bluez::BluetoothServiceAttributeValueBlueZ& value) { | |
74 return value.type(); | |
75 } | |
76 | |
77 static size_t type_size( | |
78 const bluez::BluetoothServiceAttributeValueBlueZ& value) { | |
79 return value.size(); | |
80 } | |
81 | |
82 static const base::ListValue& value( | |
83 const bluez::BluetoothServiceAttributeValueBlueZ& value) { | |
84 base::ListValue list_value; | |
85 list_value.Append(value.value().CreateDeepCopy()); | |
86 return std::move(list_value); | |
dcheng
2016/08/20 02:39:19
Nit: std::move() has no effect here.
More problem
yzshen1
2016/08/22 23:42:14
Ah, I think that is because we don't have any IPC:
Miao
2016/08/25 16:51:36
Added the SetUpContext / TearDownContext feature f
| |
87 } | |
88 | |
89 static const std::vector<bluez::BluetoothServiceAttributeValueBlueZ>& | |
90 sequence(const bluez::BluetoothServiceAttributeValueBlueZ& value) { | |
91 return value.sequence(); | |
92 } | |
93 | |
94 static bool Read(arc::mojom::BluetoothSdpServiceAttrDataView data, | |
95 bluez::BluetoothServiceAttributeValueBlueZ* output); | |
96 }; | |
97 | |
98 template <> | |
99 struct StructTraits<arc::mojom::BluetoothSdpRecord, | |
100 bluez::BluetoothServiceRecordBlueZ> { | |
101 static const std::map<uint16_t, bluez::BluetoothServiceAttributeValueBlueZ> | |
102 attrs(const bluez::BluetoothServiceRecordBlueZ& value) { | |
103 std::map<uint16_t, bluez::BluetoothServiceAttributeValueBlueZ> attributes; | |
dcheng
2016/08/20 02:39:19
Similar comment here: if we really need to create
Miao
2016/08/25 16:51:36
Done.
| |
104 std::vector<uint16_t> attribute_ids = value.GetAttributeIds(); | |
105 | |
106 for (auto it : attribute_ids) { | |
107 attributes[it] = std::move(bluez::BluetoothServiceAttributeValueBlueZ( | |
dcheng
2016/08/20 02:39:19
Note that std::move() here doesn't have an effect,
Miao
2016/08/25 16:51:36
Done.
| |
108 value.GetAttributeValue(it))); | |
109 } | |
110 | |
111 return attributes; | |
112 } | |
113 | |
114 static bool Read(arc::mojom::BluetoothSdpRecordDataView data, | |
115 bluez::BluetoothServiceRecordBlueZ* output); | |
116 }; | |
117 | |
52 } // namespace mojo | 118 } // namespace mojo |
53 | 119 |
54 #endif // COMPONENTS_ARC_BLUETOOTH_BLUETOOTH_STRUCT_TRAITS_H_ | 120 #endif // COMPONENTS_ARC_BLUETOOTH_BLUETOOTH_STRUCT_TRAITS_H_ |
OLD | NEW |