Chromium Code Reviews| Index: content/renderer/bluetooth/bluetooth_dispatcher.h |
| diff --git a/content/renderer/bluetooth/bluetooth_dispatcher.h b/content/renderer/bluetooth/bluetooth_dispatcher.h |
| index 4109414400c2bd31b62e9309db61f11cbd7e9227..2eecb8373b9933457ea87d872b05a2e6d2fb27ca 100644 |
| --- a/content/renderer/bluetooth/bluetooth_dispatcher.h |
| +++ b/content/renderer/bluetooth/bluetooth_dispatcher.h |
| @@ -17,12 +17,17 @@ class MessageLoop; |
| class TaskRunner; |
| } |
| +namespace blink { |
| +class WebBluetoothGATTCharacteristicDelegate; |
| +} |
| + |
| namespace IPC { |
| class Message; |
| } |
| struct BluetoothCharacteristicRequest; |
| struct BluetoothPrimaryServiceRequest; |
| +struct BluetoothNotificationsRequest; |
| namespace content { |
| class ThreadSafeSender; |
| @@ -69,11 +74,33 @@ class BluetoothDispatcher : public WorkerThread::Observer { |
| void writeValue(const blink::WebString& characteristic_instance_id, |
| const std::vector<uint8_t>& value, |
| blink::WebBluetoothWriteValueCallbacks*); |
| + void startNotifications( |
| + const blink::WebString& characteristic_instance_id, |
| + blink::WebBluetoothGATTCharacteristicDelegate* delegate, |
| + blink::WebBluetoothNotificationsCallbacks*); |
| + void stopNotifications( |
| + const blink::WebString& characteristic_instance_id, |
| + blink::WebBluetoothGATTCharacteristicDelegate* delegate, |
| + blink::WebBluetoothNotificationsCallbacks*); |
| + void characteristicDelegateRemoved( |
| + const blink::WebString& characteristic_instance_id, |
| + blink::WebBluetoothGATTCharacteristicDelegate* delegate); |
| // WorkerThread::Observer implementation. |
| void WillStopCurrentWorkerThread() override; |
| private: |
| + bool IsActiveCharacteristicNotification( |
|
Jeffrey Yasskin
2015/09/15 03:45:37
Maybe s/Is/Has/?
ortuno
2015/09/15 21:38:20
Done.
|
| + const blink::WebString& characteristic_instance_id); |
| + |
| + void AddToActiveNotificationsMap( |
| + const blink::WebString& characteristic_instance_id, |
| + blink::WebBluetoothGATTCharacteristicDelegate* delegate); |
| + |
| + void RemoveFromActiveNotificationsMap( |
| + const blink::WebString& characteristic_instance_id, |
| + blink::WebBluetoothGATTCharacteristicDelegate* delegate); |
| + |
| // IPC Handlers, see definitions in bluetooth_messages.h. |
| void OnRequestDeviceSuccess(int thread_id, |
| int request_id, |
| @@ -112,9 +139,20 @@ class BluetoothDispatcher : public WorkerThread::Observer { |
| void OnWriteValueError(int thread_id, |
| int request_id, |
| blink::WebBluetoothError error); |
| + void OnStartNotificationsSuccess(int thread_id, int request_id); |
| + void OnStartNotificationsError(int thread_id, |
| + int request_id, |
| + blink::WebBluetoothError error); |
| + void OnStopNotificationsSuccess(int thread_id, int request_id); |
| scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| + // Map that keeps track of which characteristic are subscribed to |
|
Jeffrey Yasskin
2015/09/15 03:45:37
Mention that the keys are characteristic UUIDs.
ortuno
2015/09/15 21:38:20
You mean instance IDs right? Multiple characterist
|
| + // notifications. |
| + std::map<std::string, |
| + std::set<blink::WebBluetoothGATTCharacteristicDelegate*>> |
| + active_characteristic_notifications; |
| + |
| // Tracks device requests sent to browser to match replies with callbacks. |
| // Owns callback objects. |
| IDMap<blink::WebBluetoothRequestDeviceCallbacks, IDMapOwnPointer> |
| @@ -135,6 +173,12 @@ class BluetoothDispatcher : public WorkerThread::Observer { |
| pending_read_value_requests_; |
| IDMap<blink::WebBluetoothWriteValueCallbacks, IDMapOwnPointer> |
| pending_write_value_requests_; |
| + // Tracks requests to start notifications from a characteristic. |
| + IDMap<BluetoothNotificationsRequest, IDMapOwnPointer> |
| + pending_start_notifications_requests_; |
| + // Tracks requests to stop notifications from a characteristic. |
| + IDMap<BluetoothNotificationsRequest, IDMapOwnPointer> |
| + pending_stop_notifications_requests_; |
| DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher); |
| }; |