| Index: components/arc/bluetooth/bluetooth_struct_traits.h
|
| diff --git a/components/arc/bluetooth/bluetooth_struct_traits.h b/components/arc/bluetooth/bluetooth_struct_traits.h
|
| index 2178fc1365103a6822c674453ac619a97ee65449..d9be9f5dab35a1fa1f25595cdacc31e51cdd6695 100644
|
| --- a/components/arc/bluetooth/bluetooth_struct_traits.h
|
| +++ b/components/arc/bluetooth/bluetooth_struct_traits.h
|
| @@ -6,6 +6,7 @@
|
| #define COMPONENTS_ARC_BLUETOOTH_BLUETOOTH_STRUCT_TRAITS_H_
|
|
|
| #include "components/arc/common/bluetooth.mojom.h"
|
| +#include "device/bluetooth/bluetooth_advertisement.h"
|
| #include "device/bluetooth/bluetooth_common.h"
|
|
|
| namespace mojo {
|
| @@ -49,6 +50,41 @@ struct EnumTraits<arc::mojom::BluetoothDeviceType,
|
| }
|
| };
|
|
|
| +template <>
|
| +struct EnumTraits<arc::mojom::BluetoothAdvertisementType,
|
| + device::BluetoothAdvertisement::AdvertisementType> {
|
| + static arc::mojom::BluetoothAdvertisementType ToMojom(
|
| + device::BluetoothAdvertisement::AdvertisementType type) {
|
| + switch (type) {
|
| + case device::BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST:
|
| + return arc::mojom::BluetoothAdvertisementType::ADV_TYPE_NON_CONNECTABLE;
|
| + case device::BluetoothAdvertisement::ADVERTISEMENT_TYPE_PERIPHERAL:
|
| + return arc::mojom::BluetoothAdvertisementType::ADV_TYPE_CONNECTABLE;
|
| + default:
|
| + NOTREACHED() << "Invalid type: " << static_cast<uint32_t>(type);
|
| + return arc::mojom::BluetoothAdvertisementType::ADV_TYPE_CONNECTABLE;
|
| + }
|
| + }
|
| +
|
| + static bool FromMojom(
|
| + arc::mojom::BluetoothAdvertisementType mojom_type,
|
| + device::BluetoothAdvertisement::AdvertisementType* type) {
|
| + switch (mojom_type) {
|
| + case arc::mojom::BluetoothAdvertisementType::ADV_TYPE_CONNECTABLE:
|
| + case arc::mojom::BluetoothAdvertisementType::ADV_TYPE_SCANNABLE:
|
| + *type = device::BluetoothAdvertisement::ADVERTISEMENT_TYPE_PERIPHERAL;
|
| + break;
|
| + case arc::mojom::BluetoothAdvertisementType::ADV_TYPE_NON_CONNECTABLE:
|
| + *type = device::BluetoothAdvertisement::ADVERTISEMENT_TYPE_BROADCAST;
|
| + break;
|
| + default:
|
| + NOTREACHED() << "Invalid type: " << static_cast<uint32_t>(mojom_type);
|
| + return false;
|
| + }
|
| + return true;
|
| + }
|
| +};
|
| +
|
| } // namespace mojo
|
|
|
| #endif // COMPONENTS_ARC_BLUETOOTH_BLUETOOTH_STRUCT_TRAITS_H_
|
|
|