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 c518ef6720c4f7172be312ab724807fe63a2881d..41163e92a11e9d2b621711c119b5af1c8352a48a 100644 |
--- a/content/renderer/bluetooth/web_bluetooth_impl.cc |
+++ b/content/renderer/bluetooth/web_bluetooth_impl.cc |
@@ -21,6 +21,7 @@ |
#include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothDeviceInit.h" |
#include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemoteGATTCharacteristic.h" |
#include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemoteGATTCharacteristicInit.h" |
+#include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemoteGATTDescriptorInit.h" |
#include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemoteGATTService.h" |
#include "third_party/WebKit/public/platform/modules/bluetooth/WebRequestDeviceOptions.h" |
@@ -112,7 +113,7 @@ void WebBluetoothImpl::getCharacteristics( |
base::Passed(base::WrapUnique(callbacks)))); |
} |
-void WebBluetoothImpl::readValue( |
+void WebBluetoothImpl::characteristicReadValue( |
const blink::WebString& characteristic_instance_id, |
blink::WebBluetoothReadValueCallbacks* callbacks) { |
GetWebBluetoothService().RemoteCharacteristicReadValue( |
@@ -121,7 +122,7 @@ void WebBluetoothImpl::readValue( |
base::Passed(base::WrapUnique(callbacks)))); |
} |
-void WebBluetoothImpl::writeValue( |
+void WebBluetoothImpl::characteristicWriteValue( |
const blink::WebString& characteristic_instance_id, |
const blink::WebVector<uint8_t>& value, |
blink::WebBluetoothWriteValueCallbacks* callbacks) { |
@@ -153,6 +154,25 @@ void WebBluetoothImpl::stopNotifications( |
base::Passed(base::WrapUnique(callbacks)))); |
} |
+void WebBluetoothImpl::getDescriptors( |
+ const blink::WebString& characteristic_instance_id, |
+ int32_t quantity, |
+ const blink::WebString& descriptors_uuid, |
+ blink::WebBluetoothGetDescriptorsCallbacks* callbacks) { |
+ DCHECK(blink::mojom::IsKnownEnumValue( |
+ static_cast<blink::mojom::WebBluetoothGATTQueryQuantity>(quantity))); |
+ |
+ GetWebBluetoothService().RemoteCharacteristicGetDescriptors( |
+ mojo::String::From(characteristic_instance_id), |
+ static_cast<blink::mojom::WebBluetoothGATTQueryQuantity>(quantity), |
+ descriptors_uuid.isEmpty() |
+ ? base::nullopt |
+ : base::make_optional(device::BluetoothUUID(descriptors_uuid.utf8())), |
+ base::Bind(&WebBluetoothImpl::OnGetDescriptorsComplete, |
+ base::Unretained(this), characteristic_instance_id, |
+ base::Passed(base::WrapUnique(callbacks)))); |
+} |
+ |
void WebBluetoothImpl::characteristicObjectRemoved( |
const blink::WebString& characteristic_instance_id, |
blink::WebBluetoothRemoteGATTCharacteristic* characteristic) { |
@@ -267,6 +287,29 @@ void WebBluetoothImpl::OnGetCharacteristicsComplete( |
} |
} |
+void WebBluetoothImpl::OnGetDescriptorsComplete( |
+ const blink::WebString& characteristic_instance_id, |
+ std::unique_ptr<blink::WebBluetoothGetDescriptorsCallbacks> callbacks, |
+ blink::mojom::WebBluetoothResult result, |
+ base::Optional< |
+ std::vector<blink::mojom::WebBluetoothRemoteGATTDescriptorPtr>> |
+ descriptors) { |
+ if (result == blink::mojom::WebBluetoothResult::SUCCESS) { |
+ DCHECK(descriptors); |
+ // TODO(dcheng): This WebVector should use smart pointers. |
+ blink::WebVector<blink::WebBluetoothRemoteGATTDescriptorInit*> |
+ promise_descriptors(descriptors->size()); |
+ for (size_t i = 0; i < descriptors->size(); i++) { |
+ promise_descriptors[i] = new blink::WebBluetoothRemoteGATTDescriptorInit( |
+ blink::WebString::fromUTF8(descriptors.value()[i]->instance_id), |
+ blink::WebString::fromUTF8(descriptors.value()[i]->uuid)); |
+ } |
+ callbacks->onSuccess(promise_descriptors); |
+ } else { |
+ callbacks->onError(ToInt32(result)); |
+ } |
+} |
+ |
void WebBluetoothImpl::OnReadValueComplete( |
std::unique_ptr<blink::WebBluetoothReadValueCallbacks> callbacks, |
blink::mojom::WebBluetoothResult result, |