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

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: Address jyasskin's comments 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/web_bluetooth_impl.cc
diff --git a/content/renderer/bluetooth/web_bluetooth_impl.cc b/content/renderer/bluetooth/web_bluetooth_impl.cc
index 9b981b9c0b06d4b1d20c08038296c23180748aba..d59fa9a82b2acc296e9f6231758cdbe62ea69fa5 100644
--- a/content/renderer/bluetooth/web_bluetooth_impl.cc
+++ b/content/renderer/bluetooth/web_bluetooth_impl.cc
@@ -47,19 +47,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;
+ BluetoothDeviceId device_id_obj = BluetoothDeviceId(device_id.utf8());
+ connected_devices_[device_id_obj] = device;
GetWebBluetoothService().RemoteServerConnect(
- mojo::String::From(device_id),
+ BluetoothDeviceId(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());
+ BluetoothDeviceId device_id_obj = BluetoothDeviceId(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::getPrimaryService(
@@ -67,7 +68,7 @@ void WebBluetoothImpl::getPrimaryService(
const blink::WebString& service_uuid,
blink::WebBluetoothGetPrimaryServiceCallbacks* callbacks) {
GetWebBluetoothService().RemoteServerGetPrimaryService(
- mojo::String::From(device_id),
+ BluetoothDeviceId(device_id.utf8()),
base::make_optional(device::BluetoothUUID(service_uuid.utf8())),
base::Bind(&WebBluetoothImpl::OnGetPrimaryServiceComplete,
base::Unretained(this), device_id,
@@ -169,14 +170,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(error);
}
}
-void WebBluetoothImpl::GattServerDisconnected(const mojo::String& device_id) {
+void WebBluetoothImpl::GattServerDisconnected(
+ const BluetoothDeviceId& device_id) {
auto device_iter = connected_devices_.find(device_id);
if (device_iter != connected_devices_.end()) {
device_iter->second->dispatchGattServerDisconnected();

Powered by Google App Engine
This is Rietveld 408576698