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

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

Issue 2466223002: Implement WebBluetooth getDescriptor[s] (Closed)
Patch Set: Ensure that we throw a kGattServerNotConnected error if getDescriptor[s] is called while not connec… Created 4 years, 1 month 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.h
diff --git a/content/renderer/bluetooth/web_bluetooth_impl.h b/content/renderer/bluetooth/web_bluetooth_impl.h
index 1351bce774a99f41527a08764c56fbeff5a61227..6e8bb19de6e56c0c5fe78b711e83bcaf007695d2 100644
--- a/content/renderer/bluetooth/web_bluetooth_impl.h
+++ b/content/renderer/bluetooth/web_bluetooth_impl.h
@@ -64,11 +64,13 @@ class CONTENT_EXPORT WebBluetoothImpl
web_bluetooth.mojom */,
const blink::WebString& characteristics_uuid,
blink::WebBluetoothGetCharacteristicsCallbacks* callbacks) override;
- void readValue(const blink::WebString& characteristic_instance_id,
- blink::WebBluetoothReadValueCallbacks* callbacks) override;
- void writeValue(const blink::WebString& characteristic_instance_id,
- const blink::WebVector<uint8_t>& value,
- blink::WebBluetoothWriteValueCallbacks*) override;
+ void characteristicReadValue(
+ const blink::WebString& characteristic_instance_id,
+ blink::WebBluetoothReadValueCallbacks* callbacks) override;
+ void characteristicWriteValue(
+ const blink::WebString& characteristic_instance_id,
+ const blink::WebVector<uint8_t>& value,
+ blink::WebBluetoothWriteValueCallbacks*) override;
void startNotifications(
const blink::WebString& characteristic_instance_id,
blink::WebBluetoothNotificationsCallbacks*) override;
@@ -81,6 +83,24 @@ class CONTENT_EXPORT WebBluetoothImpl
void registerCharacteristicObject(
const blink::WebString& characteristic_instance_id,
blink::WebBluetoothRemoteGATTCharacteristic* characteristic) override;
+ void getDescriptors(
+ const blink::WebString& characteristic_instance_id,
+ int32_t quantity /* Corresponds to WebBluetoothGATTQueryQuantity in
+ web_bluetooth.mojom */,
+ const blink::WebString& descriptor_uuid,
+ blink::WebBluetoothGetDescriptorsCallbacks* callbacks) override;
+ void descriptorReadValue(
+ const blink::WebString& descriptor_instance_id,
+ blink::WebBluetoothReadValueCallbacks* callbacks) override;
+ void descriptorWriteValue(const blink::WebString& descriptor_instance_id,
+ const blink::WebVector<uint8_t>& value,
+ blink::WebBluetoothWriteValueCallbacks*) override;
+ void descriptorObjectRemoved(
+ const blink::WebString& descriptor_instance_id,
+ blink::WebBluetoothRemoteGATTDescriptor* descriptor) override;
+ void registerDescriptorObject(
ortuno 2016/11/21 03:34:08 Per comment in web_bluetooth.mojom, no need for th
+ const blink::WebString& descriptor_instance_id,
+ blink::WebBluetoothRemoteGATTDescriptor* descriptor) override;
private:
struct GetCharacteristicsCallback;
@@ -88,6 +108,8 @@ class CONTENT_EXPORT WebBluetoothImpl
void RemoteCharacteristicValueChanged(
const mojo::String& characteristic_instance_id,
mojo::Array<uint8_t> value) override;
+ void RemoteDescriptorValueChanged(const mojo::String& descriptor_instance_id,
+ mojo::Array<uint8_t> value) override;
void GattServerDisconnected(const WebBluetoothDeviceId& device_id) override;
// Callbacks for WebBluetoothService calls:
@@ -105,7 +127,7 @@ class CONTENT_EXPORT WebBluetoothImpl
blink::mojom::WebBluetoothResult result,
mojo::Array<blink::mojom::WebBluetoothRemoteGATTServicePtr> services);
void OnGetCharacteristicsComplete(
- const blink::WebString& service_instance_id,
+ const blink::WebString& characteristic_instance_id,
std::unique_ptr<blink::WebBluetoothGetCharacteristicsCallbacks> callbacks,
blink::mojom::WebBluetoothResult result,
mojo::Array<blink::mojom::WebBluetoothRemoteGATTCharacteristicPtr>
@@ -123,10 +145,17 @@ class CONTENT_EXPORT WebBluetoothImpl
blink::mojom::WebBluetoothResult result);
void OnStopNotificationsComplete(
std::unique_ptr<blink::WebBluetoothNotificationsCallbacks> callbacks);
-
+ void OnGetDescriptorsComplete(
+ const blink::WebString& service_instance_id,
+ std::unique_ptr<blink::WebBluetoothGetDescriptorsCallbacks> callbacks,
+ blink::mojom::WebBluetoothResult result,
+ mojo::Array<blink::mojom::WebBluetoothRemoteGATTDescriptorPtr>
+ characteristics);
void DispatchCharacteristicValueChanged(
const std::string& characteristic_instance_id,
const std::vector<uint8_t>& value);
+ void DispatchDescriptorValueChanged(const std::string& descriptor_instance_id,
+ const std::vector<uint8_t>& value);
blink::mojom::WebBluetoothService& GetWebBluetoothService();
service_manager::InterfaceProvider* const remote_interfaces_;
@@ -139,6 +168,13 @@ class CONTENT_EXPORT WebBluetoothImpl
std::unordered_map<std::string, blink::WebBluetoothRemoteGATTCharacteristic*>
active_characteristics_;
+ // Map of descriptor_instance_ids to
+ // WebBluetoothRemoteGATTDescriptors. When descriptorObjectRemoved is
+ // called the descriptor should be removed from the map.
+ // Keeps track of what descriptors have listeners.
+ std::unordered_map<std::string, blink::WebBluetoothRemoteGATTDescriptor*>
+ active_descriptors_;
+
// Map of device_ids to WebBluetoothDevices. Added in connect() and removed in
// disconnect(). This means a device may not actually be connected while in
// this map, but that it will definitely be removed when the page navigates.

Powered by Google App Engine
This is Rietveld 408576698