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

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

Issue 2019853002: bluetooth: Use WebBluetoothDeviceId instead of string (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-uuid-typemap
Patch Set: Rebase on top of another patch Created 4 years, 5 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/web_bluetooth_impl.cc
diff --git a/content/renderer/bluetooth/web_bluetooth_impl.cc b/content/renderer/bluetooth/web_bluetooth_impl.cc
index f87bb37ef2056358a19a0d04d34a6cdc9ca41dc3..9ce604f52669356aeddef87f044e707498f28504 100644
--- a/content/renderer/bluetooth/web_bluetooth_impl.cc
+++ b/content/renderer/bluetooth/web_bluetooth_impl.cc
@@ -57,19 +57,20 @@ void WebBluetoothImpl::connect(
blink::WebBluetoothRemoteGATTServerConnectCallbacks* callbacks) {
// TODO(crbug.com/495270): After the Bluetooth Tree is implemented, there will
// only be one object per device. But for now we replace the previous object.
- connected_devices_[device_id.utf8()] = device;
+ WebBluetoothDeviceId device_id_obj = WebBluetoothDeviceId(device_id.utf8());
+ connected_devices_[device_id_obj] = device;
GetWebBluetoothService().RemoteServerConnect(
- mojo::String::From(device_id),
+ std::move(device_id_obj),
base::Bind(&WebBluetoothImpl::OnConnectComplete, base::Unretained(this),
base::Passed(base::WrapUnique(callbacks))));
}
void WebBluetoothImpl::disconnect(const blink::WebString& device_id) {
- connected_devices_.erase(device_id.utf8());
+ WebBluetoothDeviceId device_id_obj = WebBluetoothDeviceId(device_id.utf8());
+ connected_devices_.erase(device_id_obj);
- GetWebBluetoothService().RemoteServerDisconnect(
- mojo::String::From(device_id));
+ GetWebBluetoothService().RemoteServerDisconnect(std::move(device_id_obj));
}
void WebBluetoothImpl::getPrimaryServices(
@@ -78,7 +79,7 @@ void WebBluetoothImpl::getPrimaryServices(
const blink::WebString& services_uuid,
blink::WebBluetoothGetPrimaryServicesCallbacks* callbacks) {
GetWebBluetoothService().RemoteServerGetPrimaryServices(
- mojo::String::From(device_id),
+ WebBluetoothDeviceId(device_id.utf8()),
static_cast<blink::mojom::WebBluetoothGATTQueryQuantity>(quantity),
services_uuid.isEmpty()
? base::nullopt
@@ -184,14 +185,15 @@ void WebBluetoothImpl::OnRequestDeviceComplete(
uuids[i] = blink::WebString::fromUTF8(device->uuids[i]);
callbacks->onSuccess(base::WrapUnique(new blink::WebBluetoothDeviceInit(
- blink::WebString::fromUTF8(device->id),
+ blink::WebString::fromUTF8(device->id.str()),
blink::WebString::fromUTF8(device->name), uuids)));
} else {
callbacks->onError(ToInt32(error));
}
}
-void WebBluetoothImpl::GattServerDisconnected(const mojo::String& device_id) {
+void WebBluetoothImpl::GattServerDisconnected(
+ const WebBluetoothDeviceId& device_id) {
auto device_iter = connected_devices_.find(device_id);
if (device_iter != connected_devices_.end()) {
// Remove device from the map before calling dispatchGattServerDisconnected

Powered by Google App Engine
This is Rietveld 408576698