OLD | NEW |
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_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ | 5 #ifndef CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ |
6 #define CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ | 6 #define CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 16 matching lines...) Expand all Loading... |
27 class WebBluetoothRemoteGATTCharacteristic; | 27 class WebBluetoothRemoteGATTCharacteristic; |
28 } | 28 } |
29 | 29 |
30 namespace IPC { | 30 namespace IPC { |
31 class Message; | 31 class Message; |
32 } | 32 } |
33 | 33 |
34 struct BluetoothCharacteristicRequest; | 34 struct BluetoothCharacteristicRequest; |
35 struct BluetoothCharacteristicsRequest; | 35 struct BluetoothCharacteristicsRequest; |
36 struct BluetoothPrimaryServiceRequest; | 36 struct BluetoothPrimaryServiceRequest; |
37 struct BluetoothWriteValueRequest; | |
38 struct BluetoothNotificationsRequest; | 37 struct BluetoothNotificationsRequest; |
39 | 38 |
40 namespace content { | 39 namespace content { |
41 class ThreadSafeSender; | 40 class ThreadSafeSender; |
42 | 41 |
43 // Dispatcher for child process threads which communicates to the browser's | 42 // Dispatcher for child process threads which communicates to the browser's |
44 // BluetoothDispatcherHost. | 43 // BluetoothDispatcherHost. |
45 // | 44 // |
46 // Instances are created for each thread as necessary by WebBluetoothImpl. | 45 // Instances are created for each thread as necessary by WebBluetoothImpl. |
47 // | 46 // |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 const blink::WebString& characteristic_uuid, | 80 const blink::WebString& characteristic_uuid, |
82 blink::WebBluetoothGetCharacteristicCallbacks* callbacks); | 81 blink::WebBluetoothGetCharacteristicCallbacks* callbacks); |
83 void getCharacteristics( | 82 void getCharacteristics( |
84 int frame_routing_id, | 83 int frame_routing_id, |
85 const blink::WebString& service_instance_id, | 84 const blink::WebString& service_instance_id, |
86 const blink::WebString& characteristics_uuid, | 85 const blink::WebString& characteristics_uuid, |
87 blink::WebBluetoothGetCharacteristicsCallbacks* callbacks); | 86 blink::WebBluetoothGetCharacteristicsCallbacks* callbacks); |
88 void readValue(int frame_routing_id, | 87 void readValue(int frame_routing_id, |
89 const blink::WebString& characteristic_instance_id, | 88 const blink::WebString& characteristic_instance_id, |
90 blink::WebBluetoothReadValueCallbacks* callbacks); | 89 blink::WebBluetoothReadValueCallbacks* callbacks); |
91 void writeValue(int frame_routing_id, | |
92 const blink::WebString& characteristic_instance_id, | |
93 const blink::WebVector<uint8_t>& value, | |
94 blink::WebBluetoothWriteValueCallbacks*); | |
95 void startNotifications(int frame_routing_id, | 90 void startNotifications(int frame_routing_id, |
96 const blink::WebString& characteristic_instance_id, | 91 const blink::WebString& characteristic_instance_id, |
97 blink::WebBluetoothRemoteGATTCharacteristic* delegate, | 92 blink::WebBluetoothRemoteGATTCharacteristic* delegate, |
98 blink::WebBluetoothNotificationsCallbacks*); | 93 blink::WebBluetoothNotificationsCallbacks*); |
99 void stopNotifications(int frame_routing_id, | 94 void stopNotifications(int frame_routing_id, |
100 const blink::WebString& characteristic_instance_id, | 95 const blink::WebString& characteristic_instance_id, |
101 blink::WebBluetoothRemoteGATTCharacteristic* delegate, | 96 blink::WebBluetoothRemoteGATTCharacteristic* delegate, |
102 blink::WebBluetoothNotificationsCallbacks*); | 97 blink::WebBluetoothNotificationsCallbacks*); |
103 void characteristicObjectRemoved( | 98 void characteristicObjectRemoved( |
104 int frame_routing_id, | 99 int frame_routing_id, |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 const std::vector<uint32_t>& characteristic_properties); | 204 const std::vector<uint32_t>& characteristic_properties); |
210 void OnGetCharacteristicsError(int thread_id, | 205 void OnGetCharacteristicsError(int thread_id, |
211 int request_id, | 206 int request_id, |
212 blink::WebBluetoothError error); | 207 blink::WebBluetoothError error); |
213 void OnReadValueSuccess(int thread_id, | 208 void OnReadValueSuccess(int thread_id, |
214 int request_id, | 209 int request_id, |
215 const std::vector<uint8_t>& value); | 210 const std::vector<uint8_t>& value); |
216 void OnReadValueError(int thread_id, | 211 void OnReadValueError(int thread_id, |
217 int request_id, | 212 int request_id, |
218 blink::WebBluetoothError error); | 213 blink::WebBluetoothError error); |
219 void OnWriteValueSuccess(int thread_id, int request_id); | |
220 void OnWriteValueError(int thread_id, | |
221 int request_id, | |
222 blink::WebBluetoothError error); | |
223 void OnStartNotificationsSuccess(int thread_id, int request_id); | 214 void OnStartNotificationsSuccess(int thread_id, int request_id); |
224 void OnStartNotificationsError(int thread_id, | 215 void OnStartNotificationsError(int thread_id, |
225 int request_id, | 216 int request_id, |
226 blink::WebBluetoothError error); | 217 blink::WebBluetoothError error); |
227 void OnStopNotificationsSuccess(int thread_id, int request_id); | 218 void OnStopNotificationsSuccess(int thread_id, int request_id); |
228 void OnCharacteristicValueChanged( | 219 void OnCharacteristicValueChanged( |
229 int thread_id, | 220 int thread_id, |
230 const std::string& characteristic_instance_id, | 221 const std::string& characteristic_instance_id, |
231 const std::vector<uint8_t> value); | 222 const std::vector<uint8_t> value); |
232 | 223 |
(...skipping 17 matching lines...) Expand all Loading... |
250 pending_primary_service_requests_; | 241 pending_primary_service_requests_; |
251 // Tracks requests to get a characteristic from a service. | 242 // Tracks requests to get a characteristic from a service. |
252 IDMap<BluetoothCharacteristicRequest, IDMapOwnPointer> | 243 IDMap<BluetoothCharacteristicRequest, IDMapOwnPointer> |
253 pending_characteristic_requests_; | 244 pending_characteristic_requests_; |
254 // Tracks requests to get characteristics from a service. | 245 // Tracks requests to get characteristics from a service. |
255 IDMap<BluetoothCharacteristicsRequest, IDMapOwnPointer> | 246 IDMap<BluetoothCharacteristicsRequest, IDMapOwnPointer> |
256 pending_characteristics_requests_; | 247 pending_characteristics_requests_; |
257 // Tracks requests to read from a characteristics. | 248 // Tracks requests to read from a characteristics. |
258 IDMap<blink::WebBluetoothReadValueCallbacks, IDMapOwnPointer> | 249 IDMap<blink::WebBluetoothReadValueCallbacks, IDMapOwnPointer> |
259 pending_read_value_requests_; | 250 pending_read_value_requests_; |
260 IDMap<BluetoothWriteValueRequest, IDMapOwnPointer> | |
261 pending_write_value_requests_; | |
262 IDMap<BluetoothNotificationsRequest, IDMapOwnPointer> | 251 IDMap<BluetoothNotificationsRequest, IDMapOwnPointer> |
263 pending_notifications_requests_; | 252 pending_notifications_requests_; |
264 | 253 |
265 // Map of characteristic_instance_id to a set of | 254 // Map of characteristic_instance_id to a set of |
266 // WebBluetoothRemoteGATTCharacteristic pointers. Keeps track of which | 255 // WebBluetoothRemoteGATTCharacteristic pointers. Keeps track of which |
267 // objects are subscribed to notifications. | 256 // objects are subscribed to notifications. |
268 std::map<std::string, std::set<blink::WebBluetoothRemoteGATTCharacteristic*>> | 257 std::map<std::string, std::set<blink::WebBluetoothRemoteGATTCharacteristic*>> |
269 active_notification_subscriptions_; | 258 active_notification_subscriptions_; |
270 | 259 |
271 // Map of characteristic_instance_ids to | 260 // Map of characteristic_instance_ids to |
272 // WebBluetoothRemoteGATTCharacteristics. | 261 // WebBluetoothRemoteGATTCharacteristics. |
273 // Keeps track of what characteristics have listeners. | 262 // Keeps track of what characteristics have listeners. |
274 // TODO(ortuno): We are assuming that there exists a single frame per | 263 // TODO(ortuno): We are assuming that there exists a single frame per |
275 // dispatcher, so there could be at most one characteristic object per | 264 // dispatcher, so there could be at most one characteristic object per |
276 // characteristic_instance_id. Change to a set when we support multiple | 265 // characteristic_instance_id. Change to a set when we support multiple |
277 // frames. | 266 // frames. |
278 // http://crbug.com/541388 | 267 // http://crbug.com/541388 |
279 std::map<std::string, blink::WebBluetoothRemoteGATTCharacteristic*> | 268 std::map<std::string, blink::WebBluetoothRemoteGATTCharacteristic*> |
280 active_characteristics_; | 269 active_characteristics_; |
281 | 270 |
282 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher); | 271 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher); |
283 }; | 272 }; |
284 | 273 |
285 } // namespace content | 274 } // namespace content |
286 | 275 |
287 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ | 276 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ |
OLD | NEW |