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 23 matching lines...) Expand all Loading... |
34 class BluetoothChromeOSTest; | 34 class BluetoothChromeOSTest; |
35 class BluetoothAdapterProfileChromeOS; | 35 class BluetoothAdapterProfileChromeOS; |
36 class BluetoothDeviceChromeOS; | 36 class BluetoothDeviceChromeOS; |
37 class BluetoothPairingChromeOS; | 37 class BluetoothPairingChromeOS; |
38 class BluetoothRemoteGattCharacteristicChromeOS; | 38 class BluetoothRemoteGattCharacteristicChromeOS; |
39 class BluetoothRemoteGattDescriptorChromeOS; | 39 class BluetoothRemoteGattDescriptorChromeOS; |
40 class BluetoothRemoteGattServiceChromeOS; | 40 class BluetoothRemoteGattServiceChromeOS; |
41 | 41 |
42 // The BluetoothAdapterChromeOS class implements BluetoothAdapter for the | 42 // The BluetoothAdapterChromeOS class implements BluetoothAdapter for the |
43 // Chrome OS platform. | 43 // Chrome OS platform. |
| 44 // |
| 45 // Methods tolerate a shutdown scenario where BluetoothAdapterChromeOS::Shutdown |
| 46 // causes IsPresent to return false just before the dbus system is shutdown but |
| 47 // while references to the BluetoothAdapterChromeOS object still exists. |
| 48 // |
| 49 // When adding methods to this class verify shutdown behavior in |
| 50 // BluetoothChromeOSTest, Shutdown. |
44 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS | 51 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterChromeOS |
45 : public device::BluetoothAdapter, | 52 : public device::BluetoothAdapter, |
46 public chromeos::BluetoothAdapterClient::Observer, | 53 public chromeos::BluetoothAdapterClient::Observer, |
47 public chromeos::BluetoothDeviceClient::Observer, | 54 public chromeos::BluetoothDeviceClient::Observer, |
48 public chromeos::BluetoothInputClient::Observer, | 55 public chromeos::BluetoothInputClient::Observer, |
49 public chromeos::BluetoothAgentServiceProvider::Delegate { | 56 public chromeos::BluetoothAgentServiceProvider::Delegate { |
50 public: | 57 public: |
51 typedef base::Callback<void(const std::string& error_message)> | 58 typedef base::Callback<void(const std::string& error_message)> |
52 ErrorCompletionCallback; | 59 ErrorCompletionCallback; |
53 typedef base::Callback<void(BluetoothAdapterProfileChromeOS* profile)> | 60 typedef base::Callback<void(BluetoothAdapterProfileChromeOS* profile)> |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 void ReleaseProfile(const device::BluetoothUUID& uuid); | 149 void ReleaseProfile(const device::BluetoothUUID& uuid); |
143 | 150 |
144 protected: | 151 protected: |
145 // BluetoothAdapter: | 152 // BluetoothAdapter: |
146 void RemovePairingDelegateInternal( | 153 void RemovePairingDelegateInternal( |
147 device::BluetoothDevice::PairingDelegate* pairing_delegate) override; | 154 device::BluetoothDevice::PairingDelegate* pairing_delegate) override; |
148 | 155 |
149 private: | 156 private: |
150 friend class base::DeleteHelper<BluetoothAdapterChromeOS>; | 157 friend class base::DeleteHelper<BluetoothAdapterChromeOS>; |
151 friend class BluetoothChromeOSTest; | 158 friend class BluetoothChromeOSTest; |
| 159 friend class BluetoothChromeOSTest_Shutdown_Test; |
| 160 friend class BluetoothChromeOSTest_Shutdown_OnStartDiscovery_Test; |
| 161 friend class BluetoothChromeOSTest_Shutdown_OnStartDiscoveryError_Test; |
| 162 friend class BluetoothChromeOSTest_Shutdown_OnStopDiscovery_Test; |
| 163 friend class BluetoothChromeOSTest_Shutdown_OnStopDiscoveryError_Test; |
152 | 164 |
153 // typedef for callback parameters that are passed to AddDiscoverySession | 165 // typedef for callback parameters that are passed to AddDiscoverySession |
154 // and RemoveDiscoverySession. This is used to queue incoming requests while | 166 // and RemoveDiscoverySession. This is used to queue incoming requests while |
155 // a call to BlueZ is pending. | 167 // a call to BlueZ is pending. |
156 typedef std::pair<base::Closure, ErrorCallback> DiscoveryCallbackPair; | 168 typedef std::pair<base::Closure, ErrorCallback> DiscoveryCallbackPair; |
157 typedef std::queue<DiscoveryCallbackPair> DiscoveryCallbackQueue; | 169 typedef std::queue<DiscoveryCallbackPair> DiscoveryCallbackQueue; |
158 | 170 |
159 BluetoothAdapterChromeOS(); | 171 BluetoothAdapterChromeOS(); |
160 ~BluetoothAdapterChromeOS() override; | 172 ~BluetoothAdapterChromeOS() override; |
161 | 173 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // Called by dbus:: on completion of the D-Bus method call to request that | 217 // Called by dbus:: on completion of the D-Bus method call to request that |
206 // the pairing agent be made the default. | 218 // the pairing agent be made the default. |
207 void OnRequestDefaultAgent(); | 219 void OnRequestDefaultAgent(); |
208 void OnRequestDefaultAgentError(const std::string& error_name, | 220 void OnRequestDefaultAgentError(const std::string& error_name, |
209 const std::string& error_message); | 221 const std::string& error_message); |
210 | 222 |
211 // Called by BluetoothAudioSinkChromeOS on completion of registering an audio | 223 // Called by BluetoothAudioSinkChromeOS on completion of registering an audio |
212 // sink. | 224 // sink. |
213 void OnRegisterAudioSink( | 225 void OnRegisterAudioSink( |
214 const device::BluetoothAdapter::AcquiredCallback& callback, | 226 const device::BluetoothAdapter::AcquiredCallback& callback, |
| 227 const device::BluetoothAudioSink::ErrorCallback& error_callback, |
215 scoped_refptr<device::BluetoothAudioSink> audio_sink); | 228 scoped_refptr<device::BluetoothAudioSink> audio_sink); |
216 | 229 |
217 // Internal method to obtain a BluetoothPairingChromeOS object for the device | 230 // Internal method to obtain a BluetoothPairingChromeOS object for the device |
218 // with path |object_path|. Returns the existing pairing object if the device | 231 // with path |object_path|. Returns the existing pairing object if the device |
219 // already has one (usually an outgoing connection in progress) or a new | 232 // already has one (usually an outgoing connection in progress) or a new |
220 // pairing object with the default pairing delegate if not. If no default | 233 // pairing object with the default pairing delegate if not. If no default |
221 // pairing object exists, NULL will be returned. | 234 // pairing object exists, NULL will be returned. |
222 BluetoothPairingChromeOS* GetPairing(const dbus::ObjectPath& object_path); | 235 BluetoothPairingChromeOS* GetPairing(const dbus::ObjectPath& object_path); |
223 | 236 |
224 // Set the tracked adapter to the one in |object_path|, this object will | 237 // Set the tracked adapter to the one in |object_path|, this object will |
(...skipping 23 matching lines...) Expand all Loading... |
248 const ErrorCallback& error_callback, | 261 const ErrorCallback& error_callback, |
249 bool success); | 262 bool success); |
250 | 263 |
251 // BluetoothAdapter: | 264 // BluetoothAdapter: |
252 void AddDiscoverySession(const base::Closure& callback, | 265 void AddDiscoverySession(const base::Closure& callback, |
253 const ErrorCallback& error_callback) override; | 266 const ErrorCallback& error_callback) override; |
254 void RemoveDiscoverySession(const base::Closure& callback, | 267 void RemoveDiscoverySession(const base::Closure& callback, |
255 const ErrorCallback& error_callback) override; | 268 const ErrorCallback& error_callback) override; |
256 | 269 |
257 // Called by dbus:: on completion of the D-Bus method call to start discovery. | 270 // Called by dbus:: on completion of the D-Bus method call to start discovery. |
258 void OnStartDiscovery(const base::Closure& callback); | 271 void OnStartDiscovery(const base::Closure& callback, |
| 272 const ErrorCallback& error_callback); |
259 void OnStartDiscoveryError(const base::Closure& callback, | 273 void OnStartDiscoveryError(const base::Closure& callback, |
260 const ErrorCallback& error_callback, | 274 const ErrorCallback& error_callback, |
261 const std::string& error_name, | 275 const std::string& error_name, |
262 const std::string& error_message); | 276 const std::string& error_message); |
263 | 277 |
264 // 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. |
265 void OnStopDiscovery(const base::Closure& callback); | 279 void OnStopDiscovery(const base::Closure& callback); |
266 void OnStopDiscoveryError(const ErrorCallback& error_callback, | 280 void OnStopDiscoveryError(const ErrorCallback& error_callback, |
267 const std::string& error_name, | 281 const std::string& error_name, |
268 const std::string& error_message); | 282 const std::string& error_message); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 // 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 |
330 // invalidate its weak pointers before any other members are destroyed. | 344 // invalidate its weak pointers before any other members are destroyed. |
331 base::WeakPtrFactory<BluetoothAdapterChromeOS> weak_ptr_factory_; | 345 base::WeakPtrFactory<BluetoothAdapterChromeOS> weak_ptr_factory_; |
332 | 346 |
333 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterChromeOS); | 347 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterChromeOS); |
334 }; | 348 }; |
335 | 349 |
336 } // namespace chromeos | 350 } // namespace chromeos |
337 | 351 |
338 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ | 352 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_CHROMEOS_H_ |
OLD | NEW |