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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // successfully registered, |success_callback| will be called with a pointer | 138 // successfully registered, |success_callback| will be called with a pointer |
139 // to the profile which is managed by BluetoothAdapterChromeOS. On failure, | 139 // to the profile which is managed by BluetoothAdapterChromeOS. On failure, |
140 // |error_callback| will be called. | 140 // |error_callback| will be called. |
141 void UseProfile(const device::BluetoothUUID& uuid, | 141 void UseProfile(const device::BluetoothUUID& uuid, |
142 const dbus::ObjectPath& device_path, | 142 const dbus::ObjectPath& device_path, |
143 const BluetoothProfileManagerClient::Options& options, | 143 const BluetoothProfileManagerClient::Options& options, |
144 BluetoothProfileServiceProvider::Delegate* delegate, | 144 BluetoothProfileServiceProvider::Delegate* delegate, |
145 const ProfileRegisteredCallback& success_callback, | 145 const ProfileRegisteredCallback& success_callback, |
146 const ErrorCompletionCallback& error_callback); | 146 const ErrorCompletionCallback& error_callback); |
147 | 147 |
148 // Release use of a profile by a device. | 148 // Releases the profile associated with |uuid| |
149 void ReleaseProfile(const dbus::ObjectPath& device_path, | 149 void ReleaseProfile(const device::BluetoothUUID& uuid); |
150 BluetoothAdapterProfileChromeOS* profile); | |
151 | 150 |
152 protected: | 151 protected: |
153 // BluetoothAdapter: | 152 // BluetoothAdapter: |
154 void RemovePairingDelegateInternal( | 153 void RemovePairingDelegateInternal( |
155 device::BluetoothDevice::PairingDelegate* pairing_delegate) override; | 154 device::BluetoothDevice::PairingDelegate* pairing_delegate) override; |
156 | 155 |
157 private: | 156 private: |
158 friend class base::DeleteHelper<BluetoothAdapterChromeOS>; | 157 friend class base::DeleteHelper<BluetoothAdapterChromeOS>; |
159 friend class BluetoothChromeOSTest; | 158 friend class BluetoothChromeOSTest; |
160 friend class BluetoothChromeOSTest_Shutdown_Test; | 159 friend class BluetoothChromeOSTest_Shutdown_Test; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 const std::string& error_message); | 276 const std::string& error_message); |
278 | 277 |
279 // Called by dbus:: on completion of the D-Bus method call to stop discovery. | 278 // Called by dbus:: on completion of the D-Bus method call to stop discovery. |
280 void OnStopDiscovery(const base::Closure& callback); | 279 void OnStopDiscovery(const base::Closure& callback); |
281 void OnStopDiscoveryError(const ErrorCallback& error_callback, | 280 void OnStopDiscoveryError(const ErrorCallback& error_callback, |
282 const std::string& error_name, | 281 const std::string& error_name, |
283 const std::string& error_message); | 282 const std::string& error_message); |
284 | 283 |
285 // Called by dbus:: on completion of the D-Bus method to register a profile. | 284 // Called by dbus:: on completion of the D-Bus method to register a profile. |
286 void OnRegisterProfile(const device::BluetoothUUID& uuid, | 285 void OnRegisterProfile(const device::BluetoothUUID& uuid, |
287 BluetoothAdapterProfileChromeOS* profile); | 286 const dbus::ObjectPath& device_path, |
288 | 287 BluetoothProfileServiceProvider::Delegate* delegate, |
289 void SetProfileDelegate(const device::BluetoothUUID& uuid, | 288 const ProfileRegisteredCallback& success_callback, |
| 289 const ErrorCompletionCallback& error_callback); |
| 290 bool SetProfileDelegate(const device::BluetoothUUID& uuid, |
290 const dbus::ObjectPath& device_path, | 291 const dbus::ObjectPath& device_path, |
291 BluetoothProfileServiceProvider::Delegate* delegate, | 292 BluetoothProfileServiceProvider::Delegate* delegate, |
292 const ProfileRegisteredCallback& success_callback, | 293 const ProfileRegisteredCallback& success_callback, |
293 const ErrorCompletionCallback& error_callback); | 294 const ErrorCompletionCallback& error_callback); |
294 void OnRegisterProfileError(const device::BluetoothUUID& uuid, | 295 void OnRegisterProfileError(const device::BluetoothUUID& uuid, |
| 296 const ErrorCompletionCallback& error_callback, |
295 const std::string& error_name, | 297 const std::string& error_name, |
296 const std::string& error_message); | 298 const std::string& error_message); |
297 | 299 |
298 // Called by BluetoothAdapterProfileChromeOS when no users of a profile | |
299 // remain. | |
300 void RemoveProfile(const device::BluetoothUUID& uuid); | |
301 | |
302 // Processes the queued discovery requests. For each DiscoveryCallbackPair in | 300 // Processes the queued discovery requests. For each DiscoveryCallbackPair in |
303 // the queue, this method will try to add a new discovery session. This method | 301 // the queue, this method will try to add a new discovery session. This method |
304 // is called whenever a pending D-Bus call to start or stop discovery has | 302 // is called whenever a pending D-Bus call to start or stop discovery has |
305 // ended (with either success or failure). | 303 // ended (with either success or failure). |
306 void ProcessQueuedDiscoveryRequests(); | 304 void ProcessQueuedDiscoveryRequests(); |
307 | 305 |
308 // Set in |Shutdown()|, makes IsPresent()| return false. | 306 // Set in |Shutdown()|, makes IsPresent()| return false. |
309 bool dbus_is_shutdown_; | 307 bool dbus_is_shutdown_; |
310 | 308 |
311 // Number of discovery sessions that have been added. | 309 // Number of discovery sessions that have been added. |
(...skipping 23 matching lines...) Expand all Loading... |
335 // our own class as its delegate. | 333 // our own class as its delegate. |
336 scoped_ptr<BluetoothAgentServiceProvider> agent_; | 334 scoped_ptr<BluetoothAgentServiceProvider> agent_; |
337 | 335 |
338 // UI thread task runner and socket thread object used to create sockets. | 336 // UI thread task runner and socket thread object used to create sockets. |
339 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | 337 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
340 scoped_refptr<device::BluetoothSocketThread> socket_thread_; | 338 scoped_refptr<device::BluetoothSocketThread> socket_thread_; |
341 | 339 |
342 // The profiles we have registered with the bluetooth daemon. | 340 // The profiles we have registered with the bluetooth daemon. |
343 std::map<device::BluetoothUUID, BluetoothAdapterProfileChromeOS*> profiles_; | 341 std::map<device::BluetoothUUID, BluetoothAdapterProfileChromeOS*> profiles_; |
344 | 342 |
345 // Callback pair for the profile registration queue. | |
346 typedef std::pair<base::Closure, ErrorCompletionCallback> | |
347 RegisterProfileCompletionPair; | |
348 | |
349 // Queue of delegates waiting for a profile to register. | |
350 std::map<device::BluetoothUUID, std::vector<RegisterProfileCompletionPair>*> | |
351 profile_queues_; | |
352 | |
353 // Note: This should remain the last member so it'll be destroyed and | 343 // Note: This should remain the last member so it'll be destroyed and |
354 // invalidate its weak pointers before any other members are destroyed. | 344 // invalidate its weak pointers before any other members are destroyed. |
355 base::WeakPtrFactory<BluetoothAdapterChromeOS> weak_ptr_factory_; | 345 base::WeakPtrFactory<BluetoothAdapterChromeOS> weak_ptr_factory_; |
356 | 346 |
357 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterChromeOS); | 347 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterChromeOS); |
358 }; | 348 }; |
359 | 349 |
360 } // namespace chromeos | 350 } // namespace chromeos |
361 | 351 |
362 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ | 352 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ |
OLD | NEW |