| 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 "components/arc/common/bluetooth.mojom.h" | 8 #include "components/arc/common/bluetooth.mojom.h" |
| 9 #include "device/bluetooth/bluetooth_advertisement.h" |
| 9 #include "device/bluetooth/bluetooth_common.h" | 10 #include "device/bluetooth/bluetooth_common.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) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 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::BluetoothAdvertisementType, |
| 55 device::BluetoothAdvertisement::AdvertisementType> { |
| 56 static arc::mojom::BluetoothAdvertisementType ToMojom( |
| 57 device::BluetoothAdvertisement::AdvertisementType type) { |
| 58 switch (type) { |
| 59 case device::BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST: |
| 60 return arc::mojom::BluetoothAdvertisementType::ADV_TYPE_NON_CONNECTABLE; |
| 61 case device::BluetoothAdvertisement::ADVERTISEMENT_TYPE_PERIPHERAL: |
| 62 return arc::mojom::BluetoothAdvertisementType::ADV_TYPE_CONNECTABLE; |
| 63 default: |
| 64 NOTREACHED() << "Invalid type: " << static_cast<uint32_t>(type); |
| 65 return arc::mojom::BluetoothAdvertisementType::ADV_TYPE_CONNECTABLE; |
| 66 } |
| 67 } |
| 68 |
| 69 static bool FromMojom( |
| 70 arc::mojom::BluetoothAdvertisementType mojom_type, |
| 71 device::BluetoothAdvertisement::AdvertisementType* type) { |
| 72 switch (mojom_type) { |
| 73 case arc::mojom::BluetoothAdvertisementType::ADV_TYPE_CONNECTABLE: |
| 74 case arc::mojom::BluetoothAdvertisementType::ADV_TYPE_SCANNABLE: |
| 75 *type = device::BluetoothAdvertisement::ADVERTISEMENT_TYPE_PERIPHERAL; |
| 76 break; |
| 77 case arc::mojom::BluetoothAdvertisementType::ADV_TYPE_NON_CONNECTABLE: |
| 78 *type = device::BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST; |
| 79 break; |
| 80 default: |
| 81 NOTREACHED() << "Invalid type: " << static_cast<uint32_t>(mojom_type); |
| 82 return false; |
| 83 } |
| 84 return true; |
| 85 } |
| 86 }; |
| 87 |
| 52 } // namespace mojo | 88 } // namespace mojo |
| 53 | 89 |
| 54 #endif // COMPONENTS_ARC_BLUETOOTH_BLUETOOTH_STRUCT_TRAITS_H_ | 90 #endif // COMPONENTS_ARC_BLUETOOTH_BLUETOOTH_STRUCT_TRAITS_H_ |
| OLD | NEW |