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

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

Powered by Google App Engine
This is Rietveld 408576698