| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 CacheQueryResult QueryCacheForDevice(const std::string& device_id); | 215 CacheQueryResult QueryCacheForDevice(const std::string& device_id); |
| 216 // Queries the platform cache for a Service with |service_instance_id|. Fills | 216 // Queries the platform cache for a Service with |service_instance_id|. Fills |
| 217 // in the |outcome| field, and |device| and |service| fields if successful. | 217 // in the |outcome| field, and |device| and |service| fields if successful. |
| 218 CacheQueryResult QueryCacheForService(const std::string& service_instance_id); | 218 CacheQueryResult QueryCacheForService(const std::string& service_instance_id); |
| 219 // Queries the platform cache for a characteristic with | 219 // Queries the platform cache for a characteristic with |
| 220 // |characteristic_instance_id|. Fills in the |outcome| field, and |device|, | 220 // |characteristic_instance_id|. Fills in the |outcome| field, and |device|, |
| 221 // |service| and |characteristic| fields if successful. | 221 // |service| and |characteristic| fields if successful. |
| 222 CacheQueryResult QueryCacheForCharacteristic( | 222 CacheQueryResult QueryCacheForCharacteristic( |
| 223 const std::string& characteristic_instance_id); | 223 const std::string& characteristic_instance_id); |
| 224 | 224 |
| 225 // Returns true if all services have been discovered for the device. |
| 226 // When the host gets a ServiceChanged indication, it automatically |
| 227 // re-discovers services, and only forwards the ServiceChanged event to this |
| 228 // class when it's done re-discovering. |
| 229 bool IsServicesDiscoveryCompleteForDevice(const std::string& device_id); |
| 230 |
| 225 // Adds the PrimaryServicesRequest to the vector of pending services requests | 231 // Adds the PrimaryServicesRequest to the vector of pending services requests |
| 226 // for that device. | 232 // for that device. |
| 227 void AddToPendingPrimaryServicesRequest( | 233 void AddToPendingPrimaryServicesRequest( |
| 228 const std::string& device_id, | 234 const std::string& device_id, |
| 229 const PrimaryServicesRequest& request); | 235 const PrimaryServicesRequest& request); |
| 230 | 236 |
| 231 // Show help pages from the chooser dialog. | 237 // Show help pages from the chooser dialog. |
| 232 void ShowBluetoothOverviewLink(); | 238 void ShowBluetoothOverviewLink(); |
| 233 void ShowBluetoothPairingLink(); | 239 void ShowBluetoothPairingLink(); |
| 234 void ShowBluetoothAdapterOffLink(); | 240 void ShowBluetoothAdapterOffLink(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 // started. We have a single timer for all of Web Bluetooth because it's | 275 // started. We have a single timer for all of Web Bluetooth because it's |
| 270 // simpler than tracking timeouts for each RequestDeviceSession individually, | 276 // simpler than tracking timeouts for each RequestDeviceSession individually, |
| 271 // and because there's no harm in extending the length of a few discovery | 277 // and because there's no harm in extending the length of a few discovery |
| 272 // sessions when other sessions are active. | 278 // sessions when other sessions are active. |
| 273 base::Timer discovery_session_timer_; | 279 base::Timer discovery_session_timer_; |
| 274 | 280 |
| 275 // Retain BluetoothGattConnection objects to keep connections open. | 281 // Retain BluetoothGattConnection objects to keep connections open. |
| 276 // TODO(scheib): Destroy as connections are closed. http://crbug.com/539643 | 282 // TODO(scheib): Destroy as connections are closed. http://crbug.com/539643 |
| 277 ScopedVector<device::BluetoothGattConnection> connections_; | 283 ScopedVector<device::BluetoothGattConnection> connections_; |
| 278 | 284 |
| 285 // Keeps track of which devices have had their services discovered. |
| 286 std::set<std::string> devices_with_discovered_services_; |
| 287 |
| 279 // Map of device_id's to primary-services requests that need responses when | 288 // Map of device_id's to primary-services requests that need responses when |
| 280 // that device's service discovery completes. | 289 // that device's service discovery completes. |
| 281 std::map<std::string, std::vector<PrimaryServicesRequest>> | 290 std::map<std::string, std::vector<PrimaryServicesRequest>> |
| 282 pending_primary_services_requests_; | 291 pending_primary_services_requests_; |
| 283 | 292 |
| 284 // |weak_ptr_on_ui_thread_| provides weak pointers, e.g. for callbacks, and | 293 // |weak_ptr_on_ui_thread_| provides weak pointers, e.g. for callbacks, and |
| 285 // because it exists and has been bound to the UI thread enforces that all | 294 // because it exists and has been bound to the UI thread enforces that all |
| 286 // copies verify they are also used on the UI thread. | 295 // copies verify they are also used on the UI thread. |
| 287 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_; | 296 base::WeakPtr<BluetoothDispatcherHost> weak_ptr_on_ui_thread_; |
| 288 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; | 297 base::WeakPtrFactory<BluetoothDispatcherHost> weak_ptr_factory_; |
| 289 | 298 |
| 290 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); | 299 DISALLOW_COPY_AND_ASSIGN(BluetoothDispatcherHost); |
| 291 }; | 300 }; |
| 292 | 301 |
| 293 } // namespace content | 302 } // namespace content |
| 294 | 303 |
| 295 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ | 304 #endif // CONTENT_BROWSER_BLUETOOTH_BLUETOOTH_DISPATCHER_HOST_H_ |
| OLD | NEW |