OLD | NEW |
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_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 6 #define CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 void OnRequestDevice( | 100 void OnRequestDevice( |
101 int thread_id, | 101 int thread_id, |
102 int request_id, | 102 int request_id, |
103 int frame_routing_id, | 103 int frame_routing_id, |
104 const std::vector<content::BluetoothScanFilter>& filters, | 104 const std::vector<content::BluetoothScanFilter>& filters, |
105 const std::vector<device::BluetoothUUID>& optional_services); | 105 const std::vector<device::BluetoothUUID>& optional_services); |
106 void OnConnectGATT(int thread_id, | 106 void OnConnectGATT(int thread_id, |
107 int request_id, | 107 int request_id, |
108 int frame_routing_id, | 108 int frame_routing_id, |
109 const std::string& device_id); | 109 const std::string& device_id); |
| 110 void OnDisconnect(int thread_id, |
| 111 int frame_routing_id, |
| 112 const std::string& device_id); |
110 void OnGetPrimaryService(int thread_id, | 113 void OnGetPrimaryService(int thread_id, |
111 int request_id, | 114 int request_id, |
112 int frame_routing_id, | 115 int frame_routing_id, |
113 const std::string& device_id, | 116 const std::string& device_id, |
114 const std::string& service_uuid); | 117 const std::string& service_uuid); |
115 void OnGetCharacteristic(int thread_id, | 118 void OnGetCharacteristic(int thread_id, |
116 int request_id, | 119 int request_id, |
117 int frame_routing_id, | 120 int frame_routing_id, |
118 const std::string& service_instance_id, | 121 const std::string& service_instance_id, |
119 const std::string& characteristic_uuid); | 122 const std::string& characteristic_uuid); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 scoped_refptr<device::BluetoothAdapter> adapter_; | 294 scoped_refptr<device::BluetoothAdapter> adapter_; |
292 | 295 |
293 // Automatically stops Bluetooth discovery a set amount of time after it was | 296 // Automatically stops Bluetooth discovery a set amount of time after it was |
294 // started. We have a single timer for all of Web Bluetooth because it's | 297 // started. We have a single timer for all of Web Bluetooth because it's |
295 // simpler than tracking timeouts for each RequestDeviceSession individually, | 298 // simpler than tracking timeouts for each RequestDeviceSession individually, |
296 // and because there's no harm in extending the length of a few discovery | 299 // and because there's no harm in extending the length of a few discovery |
297 // sessions when other sessions are active. | 300 // sessions when other sessions are active. |
298 base::Timer discovery_session_timer_; | 301 base::Timer discovery_session_timer_; |
299 | 302 |
300 // Retain BluetoothGattConnection objects to keep connections open. | 303 // Retain BluetoothGattConnection objects to keep connections open. |
301 // TODO(scheib): Destroy as connections are closed. http://crbug.com/539643 | 304 std::map<std::string, scoped_ptr<device::BluetoothGattConnection>> |
302 ScopedVector<device::BluetoothGattConnection> connections_; | 305 device_id_to_connection_map_; |
303 | 306 |
304 // Map of device_address's to primary-services requests that need responses | 307 // Map of device_address's to primary-services requests that need responses |
305 // when that device's service discovery completes. | 308 // when that device's service discovery completes. |
306 std::map<std::string, std::vector<PrimaryServicesRequest>> | 309 std::map<std::string, std::vector<PrimaryServicesRequest>> |
307 pending_primary_services_requests_; | 310 pending_primary_services_requests_; |
308 | 311 |
309 // |weak_ptr_on_ui_thread_| provides weak pointers, e.g. for callbacks, and | 312 // |weak_ptr_on_ui_thread_| provides weak pointers, e.g. for callbacks, and |
310 // because it exists and has been bound to the UI thread enforces that all | 313 // because it exists and has been bound to the UI thread enforces that all |
311 // copies verify they are also used on the UI thread. | 314 // copies verify they are also used on the UI thread. |
312 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_; | 315 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_; |
313 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; | 316 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; |
314 | 317 |
315 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); | 318 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); |
316 }; | 319 }; |
317 | 320 |
318 } // namespace content | 321 } // namespace content |
319 | 322 |
320 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 323 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
OLD | NEW |