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

Side by Side Diff: content/renderer/bluetooth/bluetooth_dispatcher.h

Issue 1502663003: bluetooth: Implement allowed devices map (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Forgot test file Created 5 years 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 unified diff | Download patch
OLDNEW
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 <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 10
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ThreadSafeSender* thread_safe_sender); 54 ThreadSafeSender* thread_safe_sender);
55 55
56 // IPC Send and Receiving interface, see IPC::Sender and IPC::Listener. 56 // IPC Send and Receiving interface, see IPC::Sender and IPC::Listener.
57 bool Send(IPC::Message* msg); 57 bool Send(IPC::Message* msg);
58 void OnMessageReceived(const IPC::Message& msg); 58 void OnMessageReceived(const IPC::Message& msg);
59 59
60 // Corresponding to WebBluetoothImpl methods. 60 // Corresponding to WebBluetoothImpl methods.
61 void requestDevice(int frame_routing_id, 61 void requestDevice(int frame_routing_id,
62 const blink::WebRequestDeviceOptions& options, 62 const blink::WebRequestDeviceOptions& options,
63 blink::WebBluetoothRequestDeviceCallbacks* callbacks); 63 blink::WebBluetoothRequestDeviceCallbacks* callbacks);
64 void connectGATT(const blink::WebString& device_id, 64 void connectGATT(int frame_routing_id,
65 const blink::WebString& device_id,
65 blink::WebBluetoothConnectGATTCallbacks* callbacks); 66 blink::WebBluetoothConnectGATTCallbacks* callbacks);
66 void getPrimaryService( 67 void getPrimaryService(
68 int frame_routing_id,
67 const blink::WebString& device_id, 69 const blink::WebString& device_id,
68 const blink::WebString& service_uuid, 70 const blink::WebString& service_uuid,
69 blink::WebBluetoothGetPrimaryServiceCallbacks* callbacks); 71 blink::WebBluetoothGetPrimaryServiceCallbacks* callbacks);
70 72
71 void getCharacteristic( 73 void getCharacteristic(
74 int frame_routing_id,
72 const blink::WebString& service_instance_id, 75 const blink::WebString& service_instance_id,
73 const blink::WebString& characteristic_uuid, 76 const blink::WebString& characteristic_uuid,
74 blink::WebBluetoothGetCharacteristicCallbacks* callbacks); 77 blink::WebBluetoothGetCharacteristicCallbacks* callbacks);
75 void readValue(const blink::WebString& characteristic_instance_id, 78 void readValue(int frame_routing_id,
79 const blink::WebString& characteristic_instance_id,
76 blink::WebBluetoothReadValueCallbacks* callbacks); 80 blink::WebBluetoothReadValueCallbacks* callbacks);
77 void writeValue(const blink::WebString& characteristic_instance_id, 81 void writeValue(int frame_routing_id,
82 const blink::WebString& characteristic_instance_id,
78 const blink::WebVector<uint8_t>& value, 83 const blink::WebVector<uint8_t>& value,
79 blink::WebBluetoothWriteValueCallbacks*); 84 blink::WebBluetoothWriteValueCallbacks*);
80 void startNotifications(const blink::WebString& characteristic_instance_id, 85 void startNotifications(int frame_routing_id,
86 const blink::WebString& characteristic_instance_id,
81 blink::WebBluetoothGATTCharacteristic* delegate, 87 blink::WebBluetoothGATTCharacteristic* delegate,
82 blink::WebBluetoothNotificationsCallbacks*); 88 blink::WebBluetoothNotificationsCallbacks*);
83 void stopNotifications(const blink::WebString& characteristic_instance_id, 89 void stopNotifications(int frame_routing_id,
90 const blink::WebString& characteristic_instance_id,
84 blink::WebBluetoothGATTCharacteristic* delegate, 91 blink::WebBluetoothGATTCharacteristic* delegate,
85 blink::WebBluetoothNotificationsCallbacks*); 92 blink::WebBluetoothNotificationsCallbacks*);
86 void characteristicObjectRemoved( 93 void characteristicObjectRemoved(
94 int frame_routing_id,
87 const blink::WebString& characteristic_instance_id, 95 const blink::WebString& characteristic_instance_id,
88 blink::WebBluetoothGATTCharacteristic* delegate); 96 blink::WebBluetoothGATTCharacteristic* delegate);
89 void registerCharacteristicObject( 97 void registerCharacteristicObject(
98 int frame_routing_id,
90 const blink::WebString& characteristic_instance_id, 99 const blink::WebString& characteristic_instance_id,
91 blink::WebBluetoothGATTCharacteristic* characteristic); 100 blink::WebBluetoothGATTCharacteristic* characteristic);
92 101
93 // WorkerThread::Observer implementation. 102 // WorkerThread::Observer implementation.
94 void WillStopCurrentWorkerThread() override; 103 void WillStopCurrentWorkerThread() override;
95 104
96 enum class NotificationsRequestType { START = 0, STOP = 1 }; 105 enum class NotificationsRequestType { START = 0, STOP = 1 };
97 106
98 private: 107 private:
99 // Notifications Queueing Notes: 108 // Notifications Queueing Notes:
100 // To avoid races and sending unnecessary IPC messages we implement 109 // To avoid races and sending unnecessary IPC messages we implement
101 // a queueing system for notification requests. When receiving 110 // a queueing system for notification requests. When receiving
102 // a notification request, the request is immediately queued. If 111 // a notification request, the request is immediately queued. If
103 // there are no other pending requests then the request is processed. 112 // there are no other pending requests then the request is processed.
104 // When a characteristic object gets destroyed BluetoothDispatcher 113 // When a characteristic object gets destroyed BluetoothDispatcher
105 // gets notified by characteristicObjectRemoved. When this happens 114 // gets notified by characteristicObjectRemoved. When this happens
106 // a stop request should be queued if the characteristic was subscribed 115 // a stop request should be queued if the characteristic was subscribed
107 // to notifications. 116 // to notifications.
108 117
109 // Helper functions for notification requests queue: 118 // Helper functions for notification requests queue:
110 119
111 // Creates a notification request and queues it. 120 // Creates a notification request and queues it.
112 int QueueNotificationRequest( 121 int QueueNotificationRequest(
122 int frame_routing_id,
113 const std::string& characteristic_instance_id, 123 const std::string& characteristic_instance_id,
114 blink::WebBluetoothGATTCharacteristic* characteristic, 124 blink::WebBluetoothGATTCharacteristic* characteristic,
115 blink::WebBluetoothNotificationsCallbacks* callbacks, 125 blink::WebBluetoothNotificationsCallbacks* callbacks,
116 NotificationsRequestType type); 126 NotificationsRequestType type);
117 // Pops the last requests and runs the next request in the queue. 127 // Pops the last requests and runs the next request in the queue.
118 void PopNotificationRequestQueueAndProcessNext(int request_id); 128 void PopNotificationRequestQueueAndProcessNext(int request_id);
119 // Checks if there is more than one request in the queue i.e. if there 129 // Checks if there is more than one request in the queue i.e. if there
120 // are other requests besides the one being processed. 130 // are other requests besides the one being processed.
121 bool HasNotificationRequestResponsePending( 131 bool HasNotificationRequestResponsePending(
122 const std::string& characteristic_instance_id); 132 const std::string& characteristic_instance_id);
(...skipping 24 matching lines...) Expand all
147 // events for the characteristic. 157 // events for the characteristic.
148 // 158 //
149 // TODO(ortuno): We should unregister a characteristic once there are no 159 // TODO(ortuno): We should unregister a characteristic once there are no
150 // characteristic objects that have listeners attached. 160 // characteristic objects that have listeners attached.
151 // For now, we call this function when an object gets destroyed. So if there 161 // For now, we call this function when an object gets destroyed. So if there
152 // are two frames registered for notifications from the same characteristic 162 // are two frames registered for notifications from the same characteristic
153 // and one of the characteristic objects gets destroyed both will stop 163 // and one of the characteristic objects gets destroyed both will stop
154 // receiving notifications. 164 // receiving notifications.
155 // https://crbug.com/541388 165 // https://crbug.com/541388
156 void UnregisterCharacteristicObject( 166 void UnregisterCharacteristicObject(
167 int frame_routing_id,
157 const blink::WebString& characteristic_instance_id); 168 const blink::WebString& characteristic_instance_id);
158 169
159 // IPC Handlers, see definitions in bluetooth_messages.h. 170 // IPC Handlers, see definitions in bluetooth_messages.h.
160 void OnRequestDeviceSuccess(int thread_id, 171 void OnRequestDeviceSuccess(int thread_id,
161 int request_id, 172 int request_id,
162 const BluetoothDevice& device); 173 const BluetoothDevice& device);
163 void OnRequestDeviceError(int thread_id, 174 void OnRequestDeviceError(int thread_id,
164 int request_id, 175 int request_id,
165 blink::WebBluetoothError error); 176 blink::WebBluetoothError error);
166 void OnConnectGATTSuccess(int thread_id, 177 void OnConnectGATTSuccess(int thread_id,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 // http://crbug.com/541388 257 // http://crbug.com/541388
247 std::map<std::string, blink::WebBluetoothGATTCharacteristic*> 258 std::map<std::string, blink::WebBluetoothGATTCharacteristic*>
248 active_characteristics_; 259 active_characteristics_;
249 260
250 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher); 261 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcher);
251 }; 262 };
252 263
253 } // namespace content 264 } // namespace content
254 265
255 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_ 266 #endif // CONTENT_CHILD_BLUETOOTH_BLUETOOTH_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698