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

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

Issue 1382743002: bluetooth: Add characteristicvaluechanged event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-notifications-1
Patch Set: Final clean up Created 5 years, 2 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.h
diff --git a/content/renderer/bluetooth/bluetooth_dispatcher.h b/content/renderer/bluetooth/bluetooth_dispatcher.h
index 40d28b24620b70782ca402a5ed19869f81ccb1f1..ef86da8d874e7f233bcc7ff6a55b9246cde15491 100644
--- a/content/renderer/bluetooth/bluetooth_dispatcher.h
+++ b/content/renderer/bluetooth/bluetooth_dispatcher.h
@@ -86,6 +86,9 @@ class BluetoothDispatcher : public WorkerThread::Observer {
void characteristicObjectRemoved(
const blink::WebString& characteristic_instance_id,
blink::WebBluetoothGATTCharacteristic* delegate);
+ void registerCharacteristicObject(
+ const blink::WebString& characteristic_instance_id,
+ blink::WebBluetoothGATTCharacteristic* characteristic);
// WorkerThread::Observer implementation.
void WillStopCurrentWorkerThread() override;
@@ -140,6 +143,15 @@ class BluetoothDispatcher : public WorkerThread::Observer {
void ResolveOrSendStartNotificationRequest(int request_id);
void ResolveOrSendStopNotificationsRequest(int request_id);
+ // Tells BluetoothDispatcherHost that we are no longer interested in
+ // events for the characteristic.
+ // TODO(ortuno): We should unregister a characteristic once there are no
+ // characteristic objects that have listeners attached.
+ // For now, we only call this function when the object gets destroyed.
+ // http://crbug.com/541390
+ void UnregisterCharacteristicObject(
+ const blink::WebString& characteristic_instance_id);
+
// IPC Handlers, see definitions in bluetooth_messages.h.
void OnRequestDeviceSuccess(int thread_id,
int request_id,
@@ -181,6 +193,10 @@ class BluetoothDispatcher : public WorkerThread::Observer {
int request_id,
blink::WebBluetoothError error);
void OnStopNotificationsSuccess(int thread_id, int request_id);
+ void OnCharacteristicValueChanged(
+ int thread_id,
+ const std::string& characteristic_instance_id,
+ const std::vector<uint8_t> value);
scoped_refptr<ThreadSafeSender> thread_safe_sender_;
@@ -217,6 +233,16 @@ class BluetoothDispatcher : public WorkerThread::Observer {
std::map<std::string, std::set<blink::WebBluetoothGATTCharacteristic*>>
active_notification_subscriptions_;
+ // Map of characteristic_instance_ids to WebBluetoothGATTCharacteristics.
+ // Keeps track of what characteristics have listeners.
+ // TODO(ortuno): We are assuming that there exists a single frame per
+ // dispatcher, so there could be at most one characteristic object per
+ // characteristic_instance_id. Change to a set when we support multiple
+ // frames.
+ // http://crbug.com/541388
+ std::map<std::string, blink::WebBluetoothGATTCharacteristic*>
+ active_characteristics_;
+
DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher);
};

Powered by Google App Engine
This is Rietveld 408576698