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

Unified Diff: components/arc/bluetooth/bluetooth_struct_traits.h

Issue 2256003002: components/arc: implement multi advertising (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@plumb-incoming-connections
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698