Index: content/renderer/bluetooth/bluetooth_dispatcher.cc |
diff --git a/content/renderer/bluetooth/bluetooth_dispatcher.cc b/content/renderer/bluetooth/bluetooth_dispatcher.cc |
index 1a4679e6d63291c6cb450c564ed1cd8f98f109ac..1c93b1dc94c6224726f6f104fb6389001e0579bc 100644 |
--- a/content/renderer/bluetooth/bluetooth_dispatcher.cc |
+++ b/content/renderer/bluetooth/bluetooth_dispatcher.cc |
@@ -143,6 +143,12 @@ void BluetoothDispatcher::OnMessageReceived(const IPC::Message& msg) { |
OnWriteValueSuccess); |
IPC_MESSAGE_HANDLER(BluetoothMsg_WriteCharacteristicValueError, |
OnWriteValueError); |
+ IPC_MESSAGE_HANDLER(BluetoothMsg_StartNotificationsSuccess, |
+ OnStartNotificationsSuccess) |
+ IPC_MESSAGE_HANDLER(BluetoothMsg_StartNotificationsError, |
+ OnStartNotificationsError) |
+ IPC_MESSAGE_HANDLER(BluetoothMsg_StopNotificationsSuccess, |
+ OnStopNotificationsSuccess) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
DCHECK(handled) << "Unhandled message:" << msg.type(); |
@@ -225,6 +231,24 @@ void BluetoothDispatcher::writeValue( |
CurrentWorkerId(), request_id, characteristic_instance_id.utf8(), value)); |
} |
+void BluetoothDispatcher::startNotifications( |
+ const blink::WebString& characteristic_instance_id, |
+ blink::WebBluetoothStartNotificationsCallbacks* callbacks) { |
+ int request_id = pending_start_notifications_requests_.Add(callbacks); |
+ |
+ Send(new BluetoothHostMsg_StartNotifications( |
+ CurrentWorkerId(), request_id, characteristic_instance_id.utf8())); |
+} |
+ |
+void BluetoothDispatcher::stopNotifications( |
+ const blink::WebString& characteristic_instance_id, |
+ blink::WebBluetoothStopNotificationsCallbacks* callbacks) { |
+ int request_id = pending_stop_notifications_requests_.Add(callbacks); |
+ |
+ Send(new BluetoothHostMsg_StopNotifications( |
+ CurrentWorkerId(), request_id, characteristic_instance_id.utf8())); |
+} |
+ |
void BluetoothDispatcher::WillStopCurrentWorkerThread() { |
delete this; |
} |
@@ -386,4 +410,34 @@ void BluetoothDispatcher::OnWriteValueError(int thread_id, |
pending_write_value_requests_.Remove(request_id); |
} |
+void BluetoothDispatcher::OnStartNotificationsSuccess(int thread_id, |
+ int request_id) { |
+ DCHECK(pending_start_notifications_requests_.Lookup(request_id)) |
+ << request_id; |
+ |
+ pending_start_notifications_requests_.Lookup(request_id)->onSuccess(); |
+ |
+ pending_start_notifications_requests_.Remove(request_id); |
+} |
+ |
+void BluetoothDispatcher::OnStartNotificationsError(int thread_id, |
+ int request_id, |
+ WebBluetoothError error) { |
+ DCHECK(pending_start_notifications_requests_.Lookup(request_id)) |
+ << request_id; |
+ |
+ pending_start_notifications_requests_.Lookup(request_id)->onError(error); |
+ |
+ pending_start_notifications_requests_.Remove(request_id); |
+} |
+ |
+void BluetoothDispatcher::OnStopNotificationsSuccess(int thread_id, |
+ int request_id) { |
+ DCHECK(pending_stop_notifications_requests_.Lookup(request_id)) << request_id; |
+ |
+ pending_stop_notifications_requests_.Lookup(request_id)->onSuccess(); |
+ |
+ pending_stop_notifications_requests_.Remove(request_id); |
+} |
+ |
} // namespace content |