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

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

Issue 2506813003: Use new wrapper types for web_bluetooth.mojom (Closed)
Patch Set: merge master and resolve conflicts Created 4 years, 1 month 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 c7bf1a7948979c4a696ddd358ccc2879c247d3ac..3e5f8ceb30dbfd839878436502d20583347d080d 100644
--- a/content/renderer/bluetooth/bluetooth_type_converters.cc
+++ b/content/renderer/bluetooth/bluetooth_type_converters.cc
@@ -17,15 +17,18 @@ blink::mojom::WebBluetoothScanFilterPtr TypeConverter<
blink::mojom::WebBluetoothScanFilterPtr filter =
blink::mojom::WebBluetoothScanFilter::New();
- if (!web_filter.services.isEmpty())
- filter->services =
- Array<base::Optional<device::BluetoothUUID>>::From(web_filter.services);
+ if (!web_filter.services.isEmpty()) {
+ filter->services = std::vector<device::BluetoothUUID>();
dcheng 2016/11/24 04:56:49 Nit: consider writing this as filter->services.emp
juncai 2016/11/28 22:25:21 Done.
+ for (const auto& service : web_filter.services) {
+ filter->services->push_back(device::BluetoothUUID(service.utf8()));
+ }
+ }
if (web_filter.hasName)
- filter->name = String::From(web_filter.name);
+ filter->name = web_filter.name.utf8();
if (!web_filter.namePrefix.isEmpty())
- filter->name_prefix = String::From(web_filter.namePrefix);
+ filter->name_prefix = web_filter.namePrefix.utf8();
return filter;
}
@@ -37,22 +40,24 @@ TypeConverter<blink::mojom::WebBluetoothRequestDeviceOptionsPtr,
blink::mojom::WebBluetoothRequestDeviceOptionsPtr options =
blink::mojom::WebBluetoothRequestDeviceOptions::New();
- options->filters = mojo::Array<blink::mojom::WebBluetoothScanFilterPtr>::From(
- web_options.filters);
- options->optional_services =
- mojo::Array<base::Optional<device::BluetoothUUID>>::From(
- web_options.optionalServices);
+ for (const auto& filter : web_options.filters) {
+ options->filters.push_back(blink::mojom::WebBluetoothScanFilter::From<
+ blink::WebBluetoothScanFilter>(filter));
+ }
+ for (const auto& optional_service : web_options.optionalServices) {
+ options->optional_services.push_back(
+ device::BluetoothUUID(optional_service.utf8()));
+ }
return options;
}
// static
-base::Optional<device::BluetoothUUID>
-TypeConverter<base::Optional<device::BluetoothUUID>, blink::WebString>::Convert(
+device::BluetoothUUID
+TypeConverter<device::BluetoothUUID, blink::WebString>::Convert(
const blink::WebString& web_string) {
- base::Optional<device::BluetoothUUID> uuid =
- device::BluetoothUUID(web_string.utf8());
+ device::BluetoothUUID uuid = device::BluetoothUUID(web_string.utf8());
- DCHECK(uuid->IsValid());
+ DCHECK(uuid.IsValid());
return uuid;
}

Powered by Google App Engine
This is Rietveld 408576698