Chromium Code Reviews| Index: components/arc/bluetooth/arc_bluetooth_bridge.cc |
| diff --git a/components/arc/bluetooth/arc_bluetooth_bridge.cc b/components/arc/bluetooth/arc_bluetooth_bridge.cc |
| index d3f91bd5e1e654d25c9ad0441df62098acc3c5fa..ee49c1e320659997f1b1d8943bba8b3c1e56fa14 100644 |
| --- a/components/arc/bluetooth/arc_bluetooth_bridge.cc |
| +++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc |
| @@ -1406,12 +1406,13 @@ ArcBluetoothBridge::GetDeviceProperties(mojom::BluetoothPropertyType type, |
| if (type == mojom::BluetoothPropertyType::ALL || |
| type == mojom::BluetoothPropertyType::UUIDS) { |
| mojom::BluetoothPropertyPtr btp = mojom::BluetoothProperty::New(); |
| - std::vector<BluetoothUUID> uuids = device->GetUUIDs(); |
| + BluetoothDevice::UUIDSet uuids = device->GetUUIDs(); |
| mojo::Array<mojom::BluetoothUUIDPtr> uuid_results = |
| - mojo::Array<mojom::BluetoothUUIDPtr>::New(0); |
| + mojo::Array<mojom::BluetoothUUIDPtr>::New(uuids.size()); |
| - for (auto& uuid : uuids) { |
| - uuid_results.push_back(mojom::BluetoothUUID::From(uuid)); |
| + size_t i = 0; |
| + for (const auto& uuid : uuids) { |
| + uuid_results[i] = mojom::BluetoothUUID::From(uuid); |
|
Jeffrey Yasskin
2016/08/18 16:04:32
Too bad they don't have tests. You need to i++ in
ortuno
2016/08/19 20:50:32
Done.
|
| } |
| btp->set_uuids(std::move(uuid_results)); |
| @@ -1542,24 +1543,21 @@ ArcBluetoothBridge::GetAdvertisingData(BluetoothDevice* device) const { |
| advertising_data.push_back(std::move(local_name)); |
| // ServiceUuid |
| - BluetoothDevice::UUIDList uuid_list = device->GetUUIDs(); |
| - if (uuid_list.size() > 0) { |
| + BluetoothDevice::UUIDSet uuid_set = device->GetUUIDs(); |
|
Jeffrey Yasskin
2016/08/18 16:04:32
This indentation's wrong.
ortuno
2016/08/19 20:50:32
Done.
|
| + if (uuid_set.size() > 0) { |
| mojom::BluetoothAdvertisingDataPtr service_uuids = |
| mojom::BluetoothAdvertisingData::New(); |
| - service_uuids->set_service_uuids( |
| - mojo::Array<mojom::BluetoothUUIDPtr>::From(uuid_list)); |
| + mojo::Array<mojom::BluetoothUUIDPtr> advertised_uuids(uuid_set.size()); |
| + size_t i = 0; |
| + for (const auto& uuid : uuid_set) { |
| + advertised_uuids[i] = mojom::BluetoothUUID::From(uuid); |
|
Jeffrey Yasskin
2016/08/18 16:04:32
Another missing i++.
ortuno
2016/08/19 20:50:32
Done.
|
| + } |
| + service_uuids->set_service_uuids(std::move(advertised_uuids)); |
| advertising_data.push_back(std::move(service_uuids)); |
| } |
| // Service data |
| for (auto& uuid : device->GetServiceDataUUIDs()) { |
|
Jeffrey Yasskin
2016/08/18 16:04:32
Not from this change, but can this be a 'const aut
ortuno
2016/08/19 20:50:32
Done.
|
| - base::BinaryValue* data = device->GetServiceData(uuid); |
| - if (data->GetSize() == 0) |
| - continue; |
| - std::string data_str; |
| - if (!data->GetAsString(&data_str)) |
| - continue; |
| - |
| mojom::BluetoothAdvertisingDataPtr service_data_element = |
| mojom::BluetoothAdvertisingData::New(); |
| mojom::BluetoothServiceDataPtr service_data = |
| @@ -1568,8 +1566,12 @@ ArcBluetoothBridge::GetAdvertisingData(BluetoothDevice* device) const { |
| std::string uuid_str = uuid.canonical_value(); |
| // Convert xxxxyyyy-xxxx-xxxx-xxxx-xxxxxxxxxxxx to int16 yyyy |
| service_data->uuid_16bit = std::stoi(uuid_str.substr(4, 4), nullptr, 16); |
| - for (auto& c : data_str) { |
| - service_data->data.push_back(c); |
| + |
| + const std::vector<uint8_t>* data = device->GetServiceDataForUUID(uuid); |
| + DCHECK(data != nullptr); |
| + |
| + for (const uint8_t& byte : *data) { |
|
Jeffrey Yasskin
2016/08/18 16:04:32
I think you can use "service_data->data.assign(dat
ortuno
2016/08/19 20:50:32
Close. service_data->data is a mojo::Array and tha
|
| + service_data->data.push_back(byte); |
| } |
| service_data_element->set_service_data(std::move(service_data)); |
| advertising_data.push_back(std::move(service_data_element)); |