| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 // code that's still using the RequestDeviceSession, and continues with this | 161 // code that's still using the RequestDeviceSession, and continues with this |
| 159 // function. | 162 // function. |
| 160 void FinishClosingChooser(int chooser_id, | 163 void FinishClosingChooser(int chooser_id, |
| 161 BluetoothChooser::Event event, | 164 BluetoothChooser::Event event, |
| 162 const std::string& device_id); | 165 const std::string& device_id); |
| 163 | 166 |
| 164 // Callbacks for BluetoothDevice::CreateGattConnection. | 167 // Callbacks for BluetoothDevice::CreateGattConnection. |
| 165 void OnGATTConnectionCreated( | 168 void OnGATTConnectionCreated( |
| 166 int thread_id, | 169 int thread_id, |
| 167 int request_id, | 170 int request_id, |
| 171 int frame_routing_id, |
| 168 const std::string& device_id, | 172 const std::string& device_id, |
| 169 base::TimeTicks start_time, | 173 base::TimeTicks start_time, |
| 170 scoped_ptr<device::BluetoothGattConnection> connection); | 174 scoped_ptr<device::BluetoothGattConnection> connection); |
| 171 void OnCreateGATTConnectionError( | 175 void OnCreateGATTConnectionError( |
| 172 int thread_id, | 176 int thread_id, |
| 173 int request_id, | 177 int request_id, |
| 174 const std::string& device_id, | 178 const std::string& device_id, |
| 175 base::TimeTicks start_time, | 179 base::TimeTicks start_time, |
| 176 device::BluetoothDevice::ConnectErrorCode error_code); | 180 device::BluetoothDevice::ConnectErrorCode error_code); |
| 177 | 181 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 scoped_refptr<device::BluetoothAdapter> adapter_; | 295 scoped_refptr<device::BluetoothAdapter> adapter_; |
| 292 | 296 |
| 293 // Automatically stops Bluetooth discovery a set amount of time after it was | 297 // 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 | 298 // started. We have a single timer for all of Web Bluetooth because it's |
| 295 // simpler than tracking timeouts for each RequestDeviceSession individually, | 299 // simpler than tracking timeouts for each RequestDeviceSession individually, |
| 296 // and because there's no harm in extending the length of a few discovery | 300 // and because there's no harm in extending the length of a few discovery |
| 297 // sessions when other sessions are active. | 301 // sessions when other sessions are active. |
| 298 base::Timer discovery_session_timer_; | 302 base::Timer discovery_session_timer_; |
| 299 | 303 |
| 300 // Retain BluetoothGattConnection objects to keep connections open. | 304 // Retain BluetoothGattConnection objects to keep connections open. |
| 301 // TODO(scheib): Destroy as connections are closed. http://crbug.com/539643 | 305 std::map<std::string, scoped_ptr<device::BluetoothGattConnection>> |
| 302 ScopedVector<device::BluetoothGattConnection> connections_; | 306 device_id_to_connection_map_; |
| 303 | 307 |
| 304 // Keeps track of which devices have had their services discovered. | 308 // Keeps track of which devices have had their services discovered. |
| 305 std::set<std::string> devices_with_discovered_services_; | 309 std::set<std::string> devices_with_discovered_services_; |
| 306 | 310 |
| 307 // Map of device_address's to primary-services requests that need responses | 311 // Map of device_address's to primary-services requests that need responses |
| 308 // when that device's service discovery completes. | 312 // when that device's service discovery completes. |
| 309 std::map<std::string, std::vector<PrimaryServicesRequest>> | 313 std::map<std::string, std::vector<PrimaryServicesRequest>> |
| 310 pending_primary_services_requests_; | 314 pending_primary_services_requests_; |
| 311 | 315 |
| 312 // |weak_ptr_on_ui_thread_| provides weak pointers, e.g. for callbacks, and | 316 // |weak_ptr_on_ui_thread_| provides weak pointers, e.g. for callbacks, and |
| 313 // because it exists and has been bound to the UI thread enforces that all | 317 // because it exists and has been bound to the UI thread enforces that all |
| 314 // copies verify they are also used on the UI thread. | 318 // copies verify they are also used on the UI thread. |
| 315 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_; | 319 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_; |
| 316 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; | 320 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; |
| 317 | 321 |
| 318 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); | 322 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); |
| 319 }; | 323 }; |
| 320 | 324 |
| 321 } // namespace content | 325 } // namespace content |
| 322 | 326 |
| 323 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 327 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
| OLD | NEW |