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

Side by Side Diff: content/renderer/bluetooth/web_bluetooth_impl.h

Issue 2466223002: Implement WebBluetooth getDescriptor[s] (Closed)
Patch Set: Addressing code review comments from ortuno (still working on test changes) 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_ 5 #ifndef CONTENT_RENDERER_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_
6 #define CONTENT_RENDERER_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_ 6 #define CONTENT_RENDERER_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 int32_t quantity /* Corresponds to WebBluetoothGATTQueryQuantity in 57 int32_t quantity /* Corresponds to WebBluetoothGATTQueryQuantity in
58 web_bluetooth.mojom */, 58 web_bluetooth.mojom */,
59 const blink::WebString& services_uuid, 59 const blink::WebString& services_uuid,
60 blink::WebBluetoothGetPrimaryServicesCallbacks* callbacks) override; 60 blink::WebBluetoothGetPrimaryServicesCallbacks* callbacks) override;
61 void getCharacteristics( 61 void getCharacteristics(
62 const blink::WebString& service_instance_id, 62 const blink::WebString& service_instance_id,
63 int32_t quantity /* Corresponds to WebBluetoothGATTQueryQuantity in 63 int32_t quantity /* Corresponds to WebBluetoothGATTQueryQuantity in
64 web_bluetooth.mojom */, 64 web_bluetooth.mojom */,
65 const blink::WebString& characteristics_uuid, 65 const blink::WebString& characteristics_uuid,
66 blink::WebBluetoothGetCharacteristicsCallbacks* callbacks) override; 66 blink::WebBluetoothGetCharacteristicsCallbacks* callbacks) override;
67 void readValue(const blink::WebString& characteristic_instance_id, 67 void characteristicReadValue(
68 blink::WebBluetoothReadValueCallbacks* callbacks) override; 68 const blink::WebString& characteristic_instance_id,
69 void writeValue(const blink::WebString& characteristic_instance_id, 69 blink::WebBluetoothReadValueCallbacks* callbacks) override;
70 const blink::WebVector<uint8_t>& value, 70 void characteristicWriteValue(
71 blink::WebBluetoothWriteValueCallbacks*) override; 71 const blink::WebString& characteristic_instance_id,
72 const blink::WebVector<uint8_t>& value,
73 blink::WebBluetoothWriteValueCallbacks*) override;
72 void startNotifications( 74 void startNotifications(
73 const blink::WebString& characteristic_instance_id, 75 const blink::WebString& characteristic_instance_id,
74 blink::WebBluetoothNotificationsCallbacks*) override; 76 blink::WebBluetoothNotificationsCallbacks*) override;
75 void stopNotifications( 77 void stopNotifications(
76 const blink::WebString& characteristic_instance_id, 78 const blink::WebString& characteristic_instance_id,
77 blink::WebBluetoothNotificationsCallbacks*) override; 79 blink::WebBluetoothNotificationsCallbacks*) override;
78 void characteristicObjectRemoved( 80 void characteristicObjectRemoved(
79 const blink::WebString& characteristic_instance_id, 81 const blink::WebString& characteristic_instance_id,
80 blink::WebBluetoothRemoteGATTCharacteristic* characteristic) override; 82 blink::WebBluetoothRemoteGATTCharacteristic* characteristic) override;
81 void registerCharacteristicObject( 83 void registerCharacteristicObject(
82 const blink::WebString& characteristic_instance_id, 84 const blink::WebString& characteristic_instance_id,
83 blink::WebBluetoothRemoteGATTCharacteristic* characteristic) override; 85 blink::WebBluetoothRemoteGATTCharacteristic* characteristic) override;
86 void getDescriptors(
87 const blink::WebString& characteristic_instance_id,
88 int32_t quantity /* Corresponds to WebBluetoothGATTQueryQuantity in
89 web_bluetooth.mojom */,
90 const blink::WebString& descriptor_uuid,
91 blink::WebBluetoothGetDescriptorsCallbacks* callbacks) override;
92 void descriptorReadValue(
93 const blink::WebString& descriptor_instance_id,
94 blink::WebBluetoothReadValueCallbacks* callbacks) override;
95 void descriptorWriteValue(const blink::WebString& descriptor_instance_id,
96 const blink::WebVector<uint8_t>& value,
97 blink::WebBluetoothWriteValueCallbacks*) override;
84 98
85 private: 99 private:
86 struct GetCharacteristicsCallback; 100 struct GetCharacteristicsCallback;
87 // WebBluetoothServiceClient methods: 101 // WebBluetoothServiceClient methods:
88 void RemoteCharacteristicValueChanged( 102 void RemoteCharacteristicValueChanged(
89 const mojo::String& characteristic_instance_id, 103 const mojo::String& characteristic_instance_id,
90 mojo::Array<uint8_t> value) override; 104 mojo::Array<uint8_t> value) override;
91 void GattServerDisconnected(const WebBluetoothDeviceId& device_id) override; 105 void GattServerDisconnected(const WebBluetoothDeviceId& device_id) override;
92 106
93 // Callbacks for WebBluetoothService calls: 107 // Callbacks for WebBluetoothService calls:
94 void OnRequestDeviceComplete( 108 void OnRequestDeviceComplete(
95 std::unique_ptr<blink::WebBluetoothRequestDeviceCallbacks> callbacks, 109 std::unique_ptr<blink::WebBluetoothRequestDeviceCallbacks> callbacks,
96 const blink::mojom::WebBluetoothResult result, 110 const blink::mojom::WebBluetoothResult result,
97 blink::mojom::WebBluetoothDevicePtr device); 111 blink::mojom::WebBluetoothDevicePtr device);
98 void OnConnectComplete( 112 void OnConnectComplete(
99 std::unique_ptr<blink::WebBluetoothRemoteGATTServerConnectCallbacks> 113 std::unique_ptr<blink::WebBluetoothRemoteGATTServerConnectCallbacks>
100 callbacks, 114 callbacks,
101 blink::mojom::WebBluetoothResult result); 115 blink::mojom::WebBluetoothResult result);
102 void OnGetPrimaryServicesComplete( 116 void OnGetPrimaryServicesComplete(
103 const blink::WebString& device_id, 117 const blink::WebString& device_id,
104 std::unique_ptr<blink::WebBluetoothGetPrimaryServicesCallbacks> callbacks, 118 std::unique_ptr<blink::WebBluetoothGetPrimaryServicesCallbacks> callbacks,
105 blink::mojom::WebBluetoothResult result, 119 blink::mojom::WebBluetoothResult result,
106 mojo::Array<blink::mojom::WebBluetoothRemoteGATTServicePtr> services); 120 mojo::Array<blink::mojom::WebBluetoothRemoteGATTServicePtr> services);
107 void OnGetCharacteristicsComplete( 121 void OnGetCharacteristicsComplete(
108 const blink::WebString& service_instance_id, 122 const blink::WebString& characteristic_instance_id,
109 std::unique_ptr<blink::WebBluetoothGetCharacteristicsCallbacks> callbacks, 123 std::unique_ptr<blink::WebBluetoothGetCharacteristicsCallbacks> callbacks,
110 blink::mojom::WebBluetoothResult result, 124 blink::mojom::WebBluetoothResult result,
111 mojo::Array<blink::mojom::WebBluetoothRemoteGATTCharacteristicPtr> 125 mojo::Array<blink::mojom::WebBluetoothRemoteGATTCharacteristicPtr>
112 characteristics); 126 characteristics);
113 void OnReadValueComplete( 127 void OnReadValueComplete(
114 std::unique_ptr<blink::WebBluetoothReadValueCallbacks> callbacks, 128 std::unique_ptr<blink::WebBluetoothReadValueCallbacks> callbacks,
115 blink::mojom::WebBluetoothResult result, 129 blink::mojom::WebBluetoothResult result,
116 mojo::Array<uint8_t> value); 130 mojo::Array<uint8_t> value);
117 void OnWriteValueComplete( 131 void OnWriteValueComplete(
118 const blink::WebVector<uint8_t>& value, 132 const blink::WebVector<uint8_t>& value,
119 std::unique_ptr<blink::WebBluetoothWriteValueCallbacks> callbacks, 133 std::unique_ptr<blink::WebBluetoothWriteValueCallbacks> callbacks,
120 blink::mojom::WebBluetoothResult result); 134 blink::mojom::WebBluetoothResult result);
121 void OnStartNotificationsComplete( 135 void OnStartNotificationsComplete(
122 std::unique_ptr<blink::WebBluetoothNotificationsCallbacks> callbacks, 136 std::unique_ptr<blink::WebBluetoothNotificationsCallbacks> callbacks,
123 blink::mojom::WebBluetoothResult result); 137 blink::mojom::WebBluetoothResult result);
124 void OnStopNotificationsComplete( 138 void OnStopNotificationsComplete(
125 std::unique_ptr<blink::WebBluetoothNotificationsCallbacks> callbacks); 139 std::unique_ptr<blink::WebBluetoothNotificationsCallbacks> callbacks);
126 140 void OnGetDescriptorsComplete(
141 const blink::WebString& service_instance_id,
142 std::unique_ptr<blink::WebBluetoothGetDescriptorsCallbacks> callbacks,
143 blink::mojom::WebBluetoothResult result,
144 mojo::Array<blink::mojom::WebBluetoothRemoteGATTDescriptorPtr>
145 characteristics);
127 void DispatchCharacteristicValueChanged( 146 void DispatchCharacteristicValueChanged(
128 const std::string& characteristic_instance_id, 147 const std::string& characteristic_instance_id,
129 const std::vector<uint8_t>& value); 148 const std::vector<uint8_t>& value);
130 149
131 blink::mojom::WebBluetoothService& GetWebBluetoothService(); 150 blink::mojom::WebBluetoothService& GetWebBluetoothService();
132 service_manager::InterfaceProvider* const remote_interfaces_; 151 service_manager::InterfaceProvider* const remote_interfaces_;
133 blink::mojom::WebBluetoothServicePtr web_bluetooth_service_; 152 blink::mojom::WebBluetoothServicePtr web_bluetooth_service_;
134 153
135 // Map of characteristic_instance_ids to 154 // Map of characteristic_instance_ids to
136 // WebBluetoothRemoteGATTCharacteristics. When characteristicObjectRemoved is 155 // WebBluetoothRemoteGATTCharacteristics. When characteristicObjectRemoved is
(...skipping 12 matching lines...) Expand all
149 168
150 // Binding associated with |web_bluetooth_service_|. 169 // Binding associated with |web_bluetooth_service_|.
151 mojo::AssociatedBinding<blink::mojom::WebBluetoothServiceClient> binding_; 170 mojo::AssociatedBinding<blink::mojom::WebBluetoothServiceClient> binding_;
152 171
153 DISALLOW_COPY_AND_ASSIGN(WebBluetoothImpl); 172 DISALLOW_COPY_AND_ASSIGN(WebBluetoothImpl);
154 }; 173 };
155 174
156 } // namespace content 175 } // namespace content
157 176
158 #endif // CONTENT_RENDERER_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_ 177 #endif // CONTENT_RENDERER_BLUETOOTH_WEB_BLUETOOTH_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698