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

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: Rebase on ToT. 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 "components/arc/common/bluetooth.mojom.h" 8 #include "components/arc/common/bluetooth.mojom.h"
9 #include "device/bluetooth/bluetooth_common.h" 9 #include "device/bluetooth/bluetooth_common.h"
10 #include "device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h"
10 11
11 namespace mojo { 12 namespace mojo {
12 13
13 template <> 14 template <>
14 struct EnumTraits<arc::mojom::BluetoothDeviceType, 15 struct EnumTraits<arc::mojom::BluetoothDeviceType,
15 device::BluetoothTransport> { 16 device::BluetoothTransport> {
16 static arc::mojom::BluetoothDeviceType ToMojom( 17 static arc::mojom::BluetoothDeviceType ToMojom(
17 device::BluetoothTransport type) { 18 device::BluetoothTransport type) {
18 switch (type) { 19 switch (type) {
19 case device::BLUETOOTH_TRANSPORT_CLASSIC: 20 case device::BLUETOOTH_TRANSPORT_CLASSIC:
(...skipping 22 matching lines...) Expand all
42 *type = device::BLUETOOTH_TRANSPORT_DUAL; 43 *type = device::BLUETOOTH_TRANSPORT_DUAL;
43 break; 44 break;
44 default: 45 default:
45 NOTREACHED() << "Invalid type: " << static_cast<uint32_t>(mojom_type); 46 NOTREACHED() << "Invalid type: " << static_cast<uint32_t>(mojom_type);
46 return false; 47 return false;
47 } 48 }
48 return true; 49 return true;
49 } 50 }
50 }; 51 };
51 52
53 template <>
54 struct EnumTraits<arc::mojom::BluetoothSdpAttributeType,
55 bluez::BluetoothServiceAttributeValueBlueZ::Type> {
56 static arc::mojom::BluetoothSdpAttributeType ToMojom(
57 bluez::BluetoothServiceAttributeValueBlueZ::Type input) {
58 switch (input) {
59 case bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE:
60 case bluez::BluetoothServiceAttributeValueBlueZ::UINT:
61 case bluez::BluetoothServiceAttributeValueBlueZ::INT:
62 case bluez::BluetoothServiceAttributeValueBlueZ::UUID:
63 case bluez::BluetoothServiceAttributeValueBlueZ::STRING:
64 case bluez::BluetoothServiceAttributeValueBlueZ::BOOL:
65 case bluez::BluetoothServiceAttributeValueBlueZ::SEQUENCE:
66 case bluez::BluetoothServiceAttributeValueBlueZ::URL:
67 return static_cast<arc::mojom::BluetoothSdpAttributeType>(input);
68 default:
69 NOTREACHED() << "Invalid type: " << static_cast<uint32_t>(input);
70 return arc::mojom::BluetoothSdpAttributeType::NULLTYPE;
71 }
72 }
73
74 static bool FromMojom(
75 arc::mojom::BluetoothSdpAttributeType input,
76 bluez::BluetoothServiceAttributeValueBlueZ::Type* output) {
77 switch (input) {
78 case arc::mojom::BluetoothSdpAttributeType::NULLTYPE:
79 case arc::mojom::BluetoothSdpAttributeType::UINT:
80 case arc::mojom::BluetoothSdpAttributeType::INT:
81 case arc::mojom::BluetoothSdpAttributeType::UUID:
82 case arc::mojom::BluetoothSdpAttributeType::STRING:
83 case arc::mojom::BluetoothSdpAttributeType::BOOL:
84 case arc::mojom::BluetoothSdpAttributeType::SEQUENCE:
85 case arc::mojom::BluetoothSdpAttributeType::URL:
86 *output = static_cast<bluez::BluetoothServiceAttributeValueBlueZ::Type>(
87 input);
88 return true;
89 default:
90 NOTREACHED() << "Invalid type: " << static_cast<uint32_t>(input);
91 return false;
92 }
93 }
94 };
95
52 } // namespace mojo 96 } // namespace mojo
53 97
54 #endif // COMPONENTS_ARC_BLUETOOTH_BLUETOOTH_STRUCT_TRAITS_H_ 98 #endif // COMPONENTS_ARC_BLUETOOTH_BLUETOOTH_STRUCT_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698