Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: components/arc/bluetooth/bluetooth_struct_traits.h

Issue 2149713002: arc: bluetooth: Add SDP host side support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rewind to the previous approach using generic attribute and type converter Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
puthik_chromium 2016/08/28 00:05:39 We didn't need all these #include except one in li
Miao 2016/09/01 18:37:24 Done.
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
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::BluetoothSdpAttributeType,
61 bluez::BluetoothServiceAttributeValueBlueZ::Type> {
62 static arc::mojom::BluetoothSdpAttributeType ToMojom(
63 bluez::BluetoothServiceAttributeValueBlueZ::Type input) {
64 switch (input) {
65 case bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE:
66 case bluez::BluetoothServiceAttributeValueBlueZ::UINT:
67 case bluez::BluetoothServiceAttributeValueBlueZ::INT:
68 case bluez::BluetoothServiceAttributeValueBlueZ::UUID:
69 case bluez::BluetoothServiceAttributeValueBlueZ::STRING:
70 case bluez::BluetoothServiceAttributeValueBlueZ::BOOL:
71 case bluez::BluetoothServiceAttributeValueBlueZ::SEQUENCE:
72 case bluez::BluetoothServiceAttributeValueBlueZ::URL:
73 return static_cast<arc::mojom::BluetoothSdpAttributeType>(input);
74 default:
75 NOTREACHED() << "Invalid type: " << static_cast<uint32_t>(input);
76 return arc::mojom::BluetoothSdpAttributeType::NULLTYPE;
77 }
78 }
79
80 static bool FromMojom(
81 arc::mojom::BluetoothSdpAttributeType input,
82 bluez::BluetoothServiceAttributeValueBlueZ::Type* output) {
83 switch (input) {
84 case arc::mojom::BluetoothSdpAttributeType::NULLTYPE:
85 case arc::mojom::BluetoothSdpAttributeType::UINT:
86 case arc::mojom::BluetoothSdpAttributeType::INT:
87 case arc::mojom::BluetoothSdpAttributeType::UUID:
88 case arc::mojom::BluetoothSdpAttributeType::STRING:
89 case arc::mojom::BluetoothSdpAttributeType::BOOL:
90 case arc::mojom::BluetoothSdpAttributeType::SEQUENCE:
91 case arc::mojom::BluetoothSdpAttributeType::URL:
92 *output = static_cast<bluez::BluetoothServiceAttributeValueBlueZ::Type>(
93 input);
94 return true;
95 default:
96 NOTREACHED() << "Invalid type: " << static_cast<uint32_t>(input);
97 return false;
98 }
99 }
100 };
101
52 } // namespace mojo 102 } // namespace mojo
53 103
54 #endif // COMPONENTS_ARC_BLUETOOTH_BLUETOOTH_STRUCT_TRAITS_H_ 104 #endif // COMPONENTS_ARC_BLUETOOTH_BLUETOOTH_STRUCT_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698