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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 scoped_refptr<device::BluetoothAdapter> adapter_; | 300 scoped_refptr<device::BluetoothAdapter> adapter_; |
298 | 301 |
299 // Automatically stops Bluetooth discovery a set amount of time after it was | 302 // Automatically stops Bluetooth discovery a set amount of time after it was |
300 // started. We have a single timer for all of Web Bluetooth because it's | 303 // started. We have a single timer for all of Web Bluetooth because it's |
301 // simpler than tracking timeouts for each RequestDeviceSession individually, | 304 // simpler than tracking timeouts for each RequestDeviceSession individually, |
302 // and because there's no harm in extending the length of a few discovery | 305 // and because there's no harm in extending the length of a few discovery |
303 // sessions when other sessions are active. | 306 // sessions when other sessions are active. |
304 base::Timer discovery_session_timer_; | 307 base::Timer discovery_session_timer_; |
305 | 308 |
306 // Retain BluetoothGattConnection objects to keep connections open. | 309 // Retain BluetoothGattConnection objects to keep connections open. |
307 // TODO(scheib): Destroy as connections are closed. http://crbug.com/539643 | 310 std::map<std::string, scoped_ptr<device::BluetoothGattConnection>> |
308 ScopedVector<device::BluetoothGattConnection> connections_; | 311 device_id_to_connection_map_; |
309 | 312 |
310 // Keeps track of which devices have had their services discovered. | 313 // Keeps track of which devices have had their services discovered. |
311 std::set<std::string> devices_with_discovered_services_; | 314 std::set<std::string> devices_with_discovered_services_; |
312 | 315 |
313 // Map of device_address's to primary-services requests that need responses | 316 // Map of device_address's to primary-services requests that need responses |
314 // when that device's service discovery completes. | 317 // when that device's service discovery completes. |
315 std::map<std::string, std::vector<PrimaryServicesRequest>> | 318 std::map<std::string, std::vector<PrimaryServicesRequest>> |
316 pending_primary_services_requests_; | 319 pending_primary_services_requests_; |
317 | 320 |
318 // |weak_ptr_on_ui_thread_| provides weak pointers, e.g. for callbacks, and | 321 // |weak_ptr_on_ui_thread_| provides weak pointers, e.g. for callbacks, and |
319 // because it exists and has been bound to the UI thread enforces that all | 322 // because it exists and has been bound to the UI thread enforces that all |
320 // copies verify they are also used on the UI thread. | 323 // copies verify they are also used on the UI thread. |
321 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_; | 324 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_; |
322 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; | 325 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; |
323 | 326 |
324 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); | 327 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); |
325 }; | 328 }; |
326 | 329 |
327 } // namespace content | 330 } // namespace content |
328 | 331 |
329 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 332 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
OLD | NEW |