| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // successfully registered, |success_callback| will be called with a pointer | 131 // successfully registered, |success_callback| will be called with a pointer |
| 132 // to the profile which is managed by BluetoothAdapterChromeOS. On failure, | 132 // to the profile which is managed by BluetoothAdapterChromeOS. On failure, |
| 133 // |error_callback| will be called. | 133 // |error_callback| will be called. |
| 134 void UseProfile(const device::BluetoothUUID& uuid, | 134 void UseProfile(const device::BluetoothUUID& uuid, |
| 135 const dbus::ObjectPath& device_path, | 135 const dbus::ObjectPath& device_path, |
| 136 const BluetoothProfileManagerClient::Options& options, | 136 const BluetoothProfileManagerClient::Options& options, |
| 137 BluetoothProfileServiceProvider::Delegate* delegate, | 137 BluetoothProfileServiceProvider::Delegate* delegate, |
| 138 const ProfileRegisteredCallback& success_callback, | 138 const ProfileRegisteredCallback& success_callback, |
| 139 const ErrorCompletionCallback& error_callback); | 139 const ErrorCompletionCallback& error_callback); |
| 140 | 140 |
| 141 // Releases the profile associated with |uuid| | 141 // Release use of a profile by a device. |
| 142 void ReleaseProfile(const device::BluetoothUUID& uuid); | 142 void ReleaseProfile(const dbus::ObjectPath& device_path, |
| 143 BluetoothAdapterProfileChromeOS* profile); |
| 143 | 144 |
| 144 protected: | 145 protected: |
| 145 // BluetoothAdapter: | 146 // BluetoothAdapter: |
| 146 void RemovePairingDelegateInternal( | 147 void RemovePairingDelegateInternal( |
| 147 device::BluetoothDevice::PairingDelegate* pairing_delegate) override; | 148 device::BluetoothDevice::PairingDelegate* pairing_delegate) override; |
| 148 | 149 |
| 149 private: | 150 private: |
| 150 friend class base::DeleteHelper<BluetoothAdapterChromeOS>; | 151 friend class base::DeleteHelper<BluetoothAdapterChromeOS>; |
| 151 friend class BluetoothChromeOSTest; | 152 friend class BluetoothChromeOSTest; |
| 152 | 153 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 const std::string& error_message); | 263 const std::string& error_message); |
| 263 | 264 |
| 264 // Called by dbus:: on completion of the D-Bus method call to stop discovery. | 265 // Called by dbus:: on completion of the D-Bus method call to stop discovery. |
| 265 void OnStopDiscovery(const base::Closure& callback); | 266 void OnStopDiscovery(const base::Closure& callback); |
| 266 void OnStopDiscoveryError(const ErrorCallback& error_callback, | 267 void OnStopDiscoveryError(const ErrorCallback& error_callback, |
| 267 const std::string& error_name, | 268 const std::string& error_name, |
| 268 const std::string& error_message); | 269 const std::string& error_message); |
| 269 | 270 |
| 270 // Called by dbus:: on completion of the D-Bus method to register a profile. | 271 // Called by dbus:: on completion of the D-Bus method to register a profile. |
| 271 void OnRegisterProfile(const device::BluetoothUUID& uuid, | 272 void OnRegisterProfile(const device::BluetoothUUID& uuid, |
| 272 const dbus::ObjectPath& device_path, | 273 BluetoothAdapterProfileChromeOS* profile); |
| 273 BluetoothProfileServiceProvider::Delegate* delegate, | 274 |
| 274 const ProfileRegisteredCallback& success_callback, | 275 void SetProfileDelegate(const device::BluetoothUUID& uuid, |
| 275 const ErrorCompletionCallback& error_callback); | |
| 276 bool SetProfileDelegate(const device::BluetoothUUID& uuid, | |
| 277 const dbus::ObjectPath& device_path, | 276 const dbus::ObjectPath& device_path, |
| 278 BluetoothProfileServiceProvider::Delegate* delegate, | 277 BluetoothProfileServiceProvider::Delegate* delegate, |
| 279 const ProfileRegisteredCallback& success_callback, | 278 const ProfileRegisteredCallback& success_callback, |
| 280 const ErrorCompletionCallback& error_callback); | 279 const ErrorCompletionCallback& error_callback); |
| 281 void OnRegisterProfileError(const device::BluetoothUUID& uuid, | 280 void OnRegisterProfileError(const device::BluetoothUUID& uuid, |
| 282 const ErrorCompletionCallback& error_callback, | |
| 283 const std::string& error_name, | 281 const std::string& error_name, |
| 284 const std::string& error_message); | 282 const std::string& error_message); |
| 285 | 283 |
| 284 // Called by BluetoothAdapterProfileChromeOS when no users of a profile |
| 285 // remain. |
| 286 void RemoveProfile(const device::BluetoothUUID& uuid); |
| 287 |
| 286 // Processes the queued discovery requests. For each DiscoveryCallbackPair in | 288 // Processes the queued discovery requests. For each DiscoveryCallbackPair in |
| 287 // the queue, this method will try to add a new discovery session. This method | 289 // the queue, this method will try to add a new discovery session. This method |
| 288 // is called whenever a pending D-Bus call to start or stop discovery has | 290 // is called whenever a pending D-Bus call to start or stop discovery has |
| 289 // ended (with either success or failure). | 291 // ended (with either success or failure). |
| 290 void ProcessQueuedDiscoveryRequests(); | 292 void ProcessQueuedDiscoveryRequests(); |
| 291 | 293 |
| 292 // Set in |Shutdown()|, makes IsPresent()| return false. | 294 // Set in |Shutdown()|, makes IsPresent()| return false. |
| 293 bool dbus_is_shutdown_; | 295 bool dbus_is_shutdown_; |
| 294 | 296 |
| 295 // Number of discovery sessions that have been added. | 297 // Number of discovery sessions that have been added. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 319 // our own class as its delegate. | 321 // our own class as its delegate. |
| 320 scoped_ptr<BluetoothAgentServiceProvider> agent_; | 322 scoped_ptr<BluetoothAgentServiceProvider> agent_; |
| 321 | 323 |
| 322 // UI thread task runner and socket thread object used to create sockets. | 324 // UI thread task runner and socket thread object used to create sockets. |
| 323 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | 325 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
| 324 scoped_refptr<device::BluetoothSocketThread> socket_thread_; | 326 scoped_refptr<device::BluetoothSocketThread> socket_thread_; |
| 325 | 327 |
| 326 // The profiles we have registered with the bluetooth daemon. | 328 // The profiles we have registered with the bluetooth daemon. |
| 327 std::map<device::BluetoothUUID, BluetoothAdapterProfileChromeOS*> profiles_; | 329 std::map<device::BluetoothUUID, BluetoothAdapterProfileChromeOS*> profiles_; |
| 328 | 330 |
| 331 // Callback pair for the profile registration queue. |
| 332 typedef std::pair<base::Closure, ErrorCompletionCallback> |
| 333 RegisterProfileCompletionPair; |
| 334 |
| 335 // Queue of delegates waiting for a profile to register. |
| 336 std::map<device::BluetoothUUID, std::vector<RegisterProfileCompletionPair>*> |
| 337 profile_queues_; |
| 338 |
| 329 // Note: This should remain the last member so it'll be destroyed and | 339 // Note: This should remain the last member so it'll be destroyed and |
| 330 // invalidate its weak pointers before any other members are destroyed. | 340 // invalidate its weak pointers before any other members are destroyed. |
| 331 base::WeakPtrFactory<BluetoothAdapterChromeOS> weak_ptr_factory_; | 341 base::WeakPtrFactory<BluetoothAdapterChromeOS> weak_ptr_factory_; |
| 332 | 342 |
| 333 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterChromeOS); | 343 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterChromeOS); |
| 334 }; | 344 }; |
| 335 | 345 |
| 336 } // namespace chromeos | 346 } // namespace chromeos |
| 337 | 347 |
| 338 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ | 348 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ |
| OLD | NEW |