Chromium Code Reviews| 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 4dc301f448a5f18c42ba9885e61d22d010933e6f..cdbfe0a693453351e4646035c39c4b8357db5b25 100644 |
| --- a/content/renderer/bluetooth/web_bluetooth_impl.cc |
| +++ b/content/renderer/bluetooth/web_bluetooth_impl.cc |
| @@ -14,6 +14,7 @@ |
| #include "ipc/ipc_message.h" |
| #include "mojo/public/cpp/bindings/array.h" |
| #include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemoteGATTCharacteristic.h" |
| +#include "third_party/WebKit/public/platform/modules/bluetooth/WebBluetoothRemoteGATTCharacteristicInit.h" |
| namespace content { |
| @@ -52,20 +53,19 @@ void WebBluetoothImpl::getPrimaryService( |
| callbacks); |
| } |
| -void WebBluetoothImpl::getCharacteristic( |
| - const blink::WebString& service_instance_id, |
| - const blink::WebString& characteristics_uuid, |
| - blink::WebBluetoothGetCharacteristicCallbacks* callbacks) { |
| - GetDispatcher()->getCharacteristic(frame_routing_id_, service_instance_id, |
| - characteristics_uuid, callbacks); |
| -} |
| - |
| void WebBluetoothImpl::getCharacteristics( |
| const blink::WebString& service_instance_id, |
| - const blink::WebString& characteristic_uuid, |
| + bool single_characteristic, |
| + const blink::WebString& characteristics_uuid, |
| blink::WebBluetoothGetCharacteristicsCallbacks* callbacks) { |
| - GetDispatcher()->getCharacteristics(frame_routing_id_, service_instance_id, |
| - characteristic_uuid, callbacks); |
| + GetWebBluetoothService().RemoteServiceGetCharacteristics( |
| + mojo::String::From(service_instance_id), single_characteristic, |
| + characteristics_uuid.isEmpty() ? nullptr |
| + : mojo::String::From(characteristics_uuid), |
| + base::Bind(&WebBluetoothImpl::OnGetCharacteristicsComplete, |
| + base::Unretained(this), service_instance_id, |
| + characteristics_uuid, |
| + base::Passed(base::WrapUnique(callbacks)))); |
| } |
| void WebBluetoothImpl::readValue( |
| @@ -137,6 +137,33 @@ void WebBluetoothImpl::RemoteCharacteristicValueChanged( |
| value.PassStorage())); |
| } |
| +void WebBluetoothImpl::OnGetCharacteristicsComplete( |
| + const blink::WebString& service_instance_id, |
| + const blink::WebString& characteristics_uuid, |
| + std::unique_ptr<blink::WebBluetoothGetCharacteristicsCallbacks> callbacks, |
| + blink::mojom::WebBluetoothError error, |
| + mojo::Array<blink::mojom::WebBluetoothRemoteGATTCharacteristicPtr> |
| + characteristics) { |
| + if (error == blink::mojom::WebBluetoothError::SUCCESS) { |
| + blink::WebVector<blink::WebBluetoothRemoteGATTCharacteristicInit*> |
|
Jeffrey Yasskin
2016/04/22 01:16:38
Keep dcheng's TODO here, to make this work with sm
ortuno
2016/04/25 15:29:45
Done.
|
| + promise_characteristics(characteristics.size()); |
| + |
| + for (size_t i = 0; i < characteristics.size(); i++) { |
| + promise_characteristics[i] = |
| + new blink::WebBluetoothRemoteGATTCharacteristicInit( |
| + service_instance_id, |
| + blink::WebString::fromUTF8(characteristics[i]->instance_id), |
| + characteristics_uuid.isEmpty() |
| + ? blink::WebString::fromUTF8(characteristics[i]->uuid) |
| + : characteristics_uuid, |
| + characteristics[i]->properties); |
| + } |
| + callbacks->onSuccess(promise_characteristics); |
|
Jeffrey Yasskin
2016/04/22 01:16:38
std::move the vector?
ortuno
2016/04/25 15:29:45
This is passed by reference. Is that wrong?
Jeffrey Yasskin
2016/04/25 17:26:10
Eventually, we should make as much as possible mov
ortuno
2016/04/25 20:37:41
Acknowledge.
|
| + } else { |
| + callbacks->onError(error); |
| + } |
| +} |
| + |
| void WebBluetoothImpl::OnReadValueComplete( |
| std::unique_ptr<blink::WebBluetoothReadValueCallbacks> callbacks, |
| blink::mojom::WebBluetoothError error, |