diff options
Diffstat (limited to 'chromium/device/bluetooth/bluetooth_adapter_mac.h')
-rw-r--r-- | chromium/device/bluetooth/bluetooth_adapter_mac.h | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/chromium/device/bluetooth/bluetooth_adapter_mac.h b/chromium/device/bluetooth/bluetooth_adapter_mac.h index 7054acf5d0e..7040932db28 100644 --- a/chromium/device/bluetooth/bluetooth_adapter_mac.h +++ b/chromium/device/bluetooth/bluetooth_adapter_mac.h @@ -11,24 +11,16 @@ #include <vector> #include "base/containers/hash_tables.h" +#include "base/mac/scoped_nsobject.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "device/bluetooth/bluetooth_adapter.h" +#include "device/bluetooth/bluetooth_discovery_manager_mac.h" -#ifdef __OBJC__ -@class BluetoothAdapterMacDelegate; @class IOBluetoothDevice; -@class IOBluetoothDeviceInquiry; @class NSArray; @class NSDate; -#else -class BluetoothAdapterMacDelegate; -class IOBluetoothDevice; -class IOBluetoothDeviceInquiry; -class NSArray; -class NSDate; -#endif namespace base { @@ -40,13 +32,19 @@ namespace device { class BluetoothAdapterMacTest; -class BluetoothAdapterMac : public BluetoothAdapter { +class BluetoothAdapterMac : public BluetoothAdapter, + public BluetoothDiscoveryManagerMac::Observer { public: - // BluetoothAdapter override + static base::WeakPtr<BluetoothAdapter> CreateAdapter(); + + // BluetoothAdapter: virtual void AddObserver(BluetoothAdapter::Observer* observer) OVERRIDE; virtual void RemoveObserver(BluetoothAdapter::Observer* observer) OVERRIDE; virtual std::string GetAddress() const OVERRIDE; virtual std::string GetName() const OVERRIDE; + virtual void SetName(const std::string& name, + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE; virtual bool IsInitialized() const OVERRIDE; virtual bool IsPresent() const OVERRIDE; virtual bool IsPowered() const OVERRIDE; @@ -54,66 +52,68 @@ class BluetoothAdapterMac : public BluetoothAdapter { bool powered, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE; - virtual bool IsDiscovering() const OVERRIDE; - - virtual void StartDiscovering( - const base::Closure& callback, - const ErrorCallback& error_callback) OVERRIDE; - virtual void StopDiscovering( + virtual bool IsDiscoverable() const OVERRIDE; + virtual void SetDiscoverable( + bool discoverable, const base::Closure& callback, const ErrorCallback& error_callback) OVERRIDE; - virtual void ReadLocalOutOfBandPairingData( - const BluetoothOutOfBandPairingDataCallback& callback, - const ErrorCallback& error_callback) OVERRIDE; - - // called by BluetoothAdapterMacDelegate. - void DeviceInquiryStarted(IOBluetoothDeviceInquiry* inquiry); - void DeviceFound(IOBluetoothDeviceInquiry* inquiry, - IOBluetoothDevice* device); - void DeviceInquiryComplete(IOBluetoothDeviceInquiry* inquiry, - IOReturn error, - bool aborted); + virtual bool IsDiscovering() const OVERRIDE; + virtual void CreateRfcommService( + const BluetoothUUID& uuid, + int channel, + const CreateServiceCallback& callback, + const CreateServiceErrorCallback& error_callback) OVERRIDE; + virtual void CreateL2capService( + const BluetoothUUID& uuid, + int psm, + const CreateServiceCallback& callback, + const CreateServiceErrorCallback& error_callback) OVERRIDE; + + // BluetoothDiscoveryManagerMac::Observer overrides + virtual void DeviceFound(BluetoothDiscoveryManagerMac* manager, + IOBluetoothDevice* device) OVERRIDE; + virtual void DiscoveryStopped(BluetoothDiscoveryManagerMac* manager, + bool unexpected) OVERRIDE; + + // Registers that a new |device| has connected to the local host. + void DeviceConnected(IOBluetoothDevice* device); + + protected: + // BluetoothAdapter: + virtual void RemovePairingDelegateInternal( + device::BluetoothDevice::PairingDelegate* pairing_delegate) OVERRIDE; private: - friend class BluetoothAdapterFactory; friend class BluetoothAdapterMacTest; - enum DiscoveryStatus { - NOT_DISCOVERING, - DISCOVERY_STARTING, - DISCOVERING, - DISCOVERY_STOPPING - }; - BluetoothAdapterMac(); virtual ~BluetoothAdapterMac(); + // BluetoothAdapter: + virtual void AddDiscoverySession( + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE; + virtual void RemoveDiscoverySession( + const base::Closure& callback, + const ErrorCallback& error_callback) OVERRIDE; + void Init(); void InitForTest(scoped_refptr<base::SequencedTaskRunner> ui_task_runner); void PollAdapter(); - // Updates |devices_| to be consistent with |devices|. - void UpdateDevices(NSArray* devices); - - void MaybeStartDeviceInquiry(); - void MaybeStopDeviceInquiry(); - - typedef std::vector<std::pair<base::Closure, ErrorCallback> > - DiscoveryCallbackList; - void RunCallbacks(const DiscoveryCallbackList& callback_list, - bool success) const; + // Updates |devices_| to include the currently paired devices, as well as any + // connected, but unpaired, devices. Notifies observers if any previously + // paired or connected devices are no longer present. + void UpdateDevices(); std::string address_; std::string name_; bool powered_; - DiscoveryStatus discovery_status_; - DiscoveryCallbackList on_start_discovery_callbacks_; - DiscoveryCallbackList on_stop_discovery_callbacks_; - size_t num_discovery_listeners_; + int num_discovery_sessions_; - BluetoothAdapterMacDelegate* adapter_delegate_; - IOBluetoothDeviceInquiry* device_inquiry_; + // Discovery manager for Bluetooth Classic. + scoped_ptr<BluetoothDiscoveryManagerMac> classic_discovery_manager_; // A list of discovered device addresses. // This list is used to check if the same device is discovered twice during @@ -122,7 +122,7 @@ class BluetoothAdapterMac : public BluetoothAdapter { // Timestamp for the recently accessed device. // Used to determine if |devices_| needs an update. - NSDate* recently_accessed_device_timestamp_; + base::scoped_nsobject<NSDate> recently_accessed_device_timestamp_; scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |