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

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 Created 4 years, 4 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 ef89b10da5d1c74e3a1d9b01214f64eafb92cec1..549d5cf18abbfaf059fa16b62b866e9f59c0b108 100644
--- a/content/renderer/bluetooth/web_bluetooth_impl.cc
+++ b/content/renderer/bluetooth/web_bluetooth_impl.cc
@@ -12,6 +12,7 @@
#include "base/optional.h"
#include "content/child/mojo/type_converters.h"
#include "content/child/thread_safe_sender.h"
+#include "content/common/bluetooth/web_bluetooth_device_id.h"
#include "content/renderer/bluetooth/bluetooth_type_converters.h"
#include "ipc/ipc_message.h"
#include "mojo/public/cpp/bindings/array.h"
@@ -57,19 +58,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(
@@ -80,7 +82,7 @@ void WebBluetoothImpl::getPrimaryServices(
DCHECK(blink::mojom::IsKnownEnumValue(
static_cast<blink::mojom::WebBluetoothGATTQueryQuantity>(quantity)));
GetWebBluetoothService().RemoteServerGetPrimaryServices(
- mojo::String::From(device_id),
+ WebBluetoothDeviceId(device_id.utf8()),
static_cast<blink::mojom::WebBluetoothGATTQueryQuantity>(quantity),
services_uuid.isEmpty()
? base::nullopt
@@ -188,7 +190,7 @@ 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()),
device->name.is_null() ? blink::WebString()
: blink::WebString::fromUTF8(device->name),
uuids)));
@@ -197,7 +199,8 @@ void WebBluetoothImpl::OnRequestDeviceComplete(
}
}
-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
« no previous file with comments | « content/renderer/bluetooth/web_bluetooth_impl.h ('k') | mojo/public/tools/bindings/chromium_bindings_configuration.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698