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

Unified Diff: content/renderer/bluetooth/bluetooth_dispatcher.cc

Issue 1334763002: bluetooth: Subscribe to notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-origin
Patch Set: Created 5 years, 3 months 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/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

Powered by Google App Engine
This is Rietveld 408576698