| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "device/bluetooth/bluetooth_advertisement.h" | |
| 18 #include "device/bluetooth/bluetooth_audio_sink.h" | 17 #include "device/bluetooth/bluetooth_audio_sink.h" |
| 19 #include "device/bluetooth/bluetooth_device.h" | 18 #include "device/bluetooth/bluetooth_device.h" |
| 20 #include "device/bluetooth/bluetooth_export.h" | 19 #include "device/bluetooth/bluetooth_export.h" |
| 21 | 20 |
| 22 namespace device { | 21 namespace device { |
| 23 | 22 |
| 24 class BluetoothAdvertisement; | |
| 25 class BluetoothDiscoveryFilter; | 23 class BluetoothDiscoveryFilter; |
| 26 class BluetoothDiscoverySession; | 24 class BluetoothDiscoverySession; |
| 27 class BluetoothGattCharacteristic; | 25 class BluetoothGattCharacteristic; |
| 28 class BluetoothGattDescriptor; | 26 class BluetoothGattDescriptor; |
| 29 class BluetoothGattService; | 27 class BluetoothGattService; |
| 30 class BluetoothSocket; | 28 class BluetoothSocket; |
| 31 class BluetoothUUID; | 29 class BluetoothUUID; |
| 32 struct BluetoothAdapterDeleter; | 30 struct BluetoothAdapterDeleter; |
| 33 | 31 |
| 34 // BluetoothAdapter represents a local Bluetooth adapter which may be used to | 32 // BluetoothAdapter represents a local Bluetooth adapter which may be used to |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 typedef base::Callback<void(scoped_ptr<BluetoothDiscoverySession>)> | 183 typedef base::Callback<void(scoped_ptr<BluetoothDiscoverySession>)> |
| 186 DiscoverySessionCallback; | 184 DiscoverySessionCallback; |
| 187 typedef std::vector<BluetoothDevice*> DeviceList; | 185 typedef std::vector<BluetoothDevice*> DeviceList; |
| 188 typedef std::vector<const BluetoothDevice*> ConstDeviceList; | 186 typedef std::vector<const BluetoothDevice*> ConstDeviceList; |
| 189 typedef base::Callback<void(scoped_refptr<BluetoothSocket>)> | 187 typedef base::Callback<void(scoped_refptr<BluetoothSocket>)> |
| 190 CreateServiceCallback; | 188 CreateServiceCallback; |
| 191 typedef base::Callback<void(const std::string& message)> | 189 typedef base::Callback<void(const std::string& message)> |
| 192 CreateServiceErrorCallback; | 190 CreateServiceErrorCallback; |
| 193 typedef base::Callback<void(scoped_refptr<BluetoothAudioSink>)> | 191 typedef base::Callback<void(scoped_refptr<BluetoothAudioSink>)> |
| 194 AcquiredCallback; | 192 AcquiredCallback; |
| 195 typedef base::Callback<void(scoped_refptr<BluetoothAdvertisement>)> | |
| 196 CreateAdvertisementCallback; | |
| 197 typedef base::Callback<void(BluetoothAdvertisement::ErrorCode)> | |
| 198 CreateAdvertisementErrorCallback; | |
| 199 | 193 |
| 200 // Returns a weak pointer to a new adapter. For platforms with asynchronous | 194 // Returns a weak pointer to a new adapter. For platforms with asynchronous |
| 201 // initialization, the returned adapter will run the |init_callback| once | 195 // initialization, the returned adapter will run the |init_callback| once |
| 202 // asynchronous initialization is complete. | 196 // asynchronous initialization is complete. |
| 203 // Caution: The returned pointer also transfers ownership of the adapter. The | 197 // Caution: The returned pointer also transfers ownership of the adapter. The |
| 204 // caller is expected to call |AddRef()| on the returned pointer, typically by | 198 // caller is expected to call |AddRef()| on the returned pointer, typically by |
| 205 // storing it into a |scoped_refptr|. | 199 // storing it into a |scoped_refptr|. |
| 206 static base::WeakPtr<BluetoothAdapter> CreateAdapter( | 200 static base::WeakPtr<BluetoothAdapter> CreateAdapter( |
| 207 const InitCallback& init_callback); | 201 const InitCallback& init_callback); |
| 208 | 202 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 // Creates and registers a BluetoothAudioSink with |options|. If the fields in | 362 // Creates and registers a BluetoothAudioSink with |options|. If the fields in |
| 369 // |options| are not specified, the default values will be used. |callback| | 363 // |options| are not specified, the default values will be used. |callback| |
| 370 // will be called on success with a BluetoothAudioSink which is to be owned by | 364 // will be called on success with a BluetoothAudioSink which is to be owned by |
| 371 // the caller of this method. |error_callback| will be called on failure with | 365 // the caller of this method. |error_callback| will be called on failure with |
| 372 // a message indicating the cause. | 366 // a message indicating the cause. |
| 373 virtual void RegisterAudioSink( | 367 virtual void RegisterAudioSink( |
| 374 const BluetoothAudioSink::Options& options, | 368 const BluetoothAudioSink::Options& options, |
| 375 const AcquiredCallback& callback, | 369 const AcquiredCallback& callback, |
| 376 const BluetoothAudioSink::ErrorCallback& error_callback) = 0; | 370 const BluetoothAudioSink::ErrorCallback& error_callback) = 0; |
| 377 | 371 |
| 378 // Creates and registers an advertisement for broadcast over the LE channel. | |
| 379 // The created advertisement will be returned via the success callback. | |
| 380 virtual void RegisterAdvertisement( | |
| 381 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data, | |
| 382 const CreateAdvertisementCallback& callback, | |
| 383 const CreateAdvertisementErrorCallback& error_callback) = 0; | |
| 384 | |
| 385 protected: | 372 protected: |
| 386 friend class base::RefCounted<BluetoothAdapter>; | 373 friend class base::RefCounted<BluetoothAdapter>; |
| 387 friend class BluetoothDiscoverySession; | 374 friend class BluetoothDiscoverySession; |
| 388 | 375 |
| 389 typedef std::map<const std::string, BluetoothDevice*> DevicesMap; | 376 typedef std::map<const std::string, BluetoothDevice*> DevicesMap; |
| 390 typedef std::pair<BluetoothDevice::PairingDelegate*, PairingDelegatePriority> | 377 typedef std::pair<BluetoothDevice::PairingDelegate*, PairingDelegatePriority> |
| 391 PairingDelegatePair; | 378 PairingDelegatePair; |
| 392 | 379 |
| 393 BluetoothAdapter(); | 380 BluetoothAdapter(); |
| 394 virtual ~BluetoothAdapter(); | 381 virtual ~BluetoothAdapter(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 std::set<BluetoothDiscoverySession*> discovery_sessions_; | 475 std::set<BluetoothDiscoverySession*> discovery_sessions_; |
| 489 | 476 |
| 490 // Note: This should remain the last member so it'll be destroyed and | 477 // Note: This should remain the last member so it'll be destroyed and |
| 491 // invalidate its weak pointers before any other members are destroyed. | 478 // invalidate its weak pointers before any other members are destroyed. |
| 492 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_; | 479 base::WeakPtrFactory<BluetoothAdapter> weak_ptr_factory_; |
| 493 }; | 480 }; |
| 494 | 481 |
| 495 } // namespace device | 482 } // namespace device |
| 496 | 483 |
| 497 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ | 484 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_H_ |
| OLD | NEW |