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

Unified Diff: content/renderer/bluetooth/bluetooth_type_converters.cc

Issue 2015463004: bluetooth: Use BluetoothUUID instead of string when sending uuids (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-mojo-request-device
Patch Set: Fix merge conflict Created 4 years, 6 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: content/renderer/bluetooth/bluetooth_type_converters.cc
diff --git a/content/renderer/bluetooth/bluetooth_type_converters.cc b/content/renderer/bluetooth/bluetooth_type_converters.cc
index 863e2ef859d6eb10ca430e5e8cc3580b40a83317..c7bf1a7948979c4a696ddd358ccc2879c247d3ac 100644
--- a/content/renderer/bluetooth/bluetooth_type_converters.cc
+++ b/content/renderer/bluetooth/bluetooth_type_converters.cc
@@ -16,8 +16,10 @@ blink::mojom::WebBluetoothScanFilterPtr TypeConverter<
web_filter) {
blink::mojom::WebBluetoothScanFilterPtr filter =
blink::mojom::WebBluetoothScanFilter::New();
+
if (!web_filter.services.isEmpty())
- filter->services = Array<String>::From(web_filter.services);
+ filter->services =
+ Array<base::Optional<device::BluetoothUUID>>::From(web_filter.services);
if (web_filter.hasName)
filter->name = String::From(web_filter.name);
@@ -27,6 +29,7 @@ blink::mojom::WebBluetoothScanFilterPtr TypeConverter<
return filter;
}
+// static
blink::mojom::WebBluetoothRequestDeviceOptionsPtr
TypeConverter<blink::mojom::WebBluetoothRequestDeviceOptionsPtr,
blink::WebRequestDeviceOptions>::
@@ -37,8 +40,21 @@ TypeConverter<blink::mojom::WebBluetoothRequestDeviceOptionsPtr,
options->filters = mojo::Array<blink::mojom::WebBluetoothScanFilterPtr>::From(
web_options.filters);
options->optional_services =
- mojo::Array<mojo::String>::From(web_options.optionalServices);
+ mojo::Array<base::Optional<device::BluetoothUUID>>::From(
+ web_options.optionalServices);
return options;
}
+// static
+base::Optional<device::BluetoothUUID>
+TypeConverter<base::Optional<device::BluetoothUUID>, blink::WebString>::Convert(
+ const blink::WebString& web_string) {
+ base::Optional<device::BluetoothUUID> uuid =
+ device::BluetoothUUID(web_string.utf8());
+
+ DCHECK(uuid->IsValid());
+
+ return uuid;
+}
+
} // namespace mojo
« no previous file with comments | « content/renderer/bluetooth/bluetooth_type_converters.h ('k') | content/renderer/bluetooth/web_bluetooth_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698