Chromium Code Reviews| 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> |
|
dcheng
2016/06/09 16:20:40
We should avoid adding new type converters. Can yo
ortuno
2016/06/09 16:29:23
OOO: Why should we avoid new type converters?
Thi
dcheng
2016/06/09 18:08:48
Several reasons:
- Type converters are redundant n
ortuno
2016/06/09 19:54:50
Maybe I'm missing something but that doesn't apply
|
| +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 |