Chromium Code Reviews| 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_MAC_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_ |
| 7 | 7 |
| 8 #include <IOKit/IOReturn.h> | 8 #include <IOKit/IOReturn.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 const BluetoothAudioSink::ErrorCallback& error_callback) override; | 76 const BluetoothAudioSink::ErrorCallback& error_callback) override; |
| 77 void RegisterAdvertisement( | 77 void RegisterAdvertisement( |
| 78 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data, | 78 scoped_ptr<BluetoothAdvertisement::Data> advertisement_data, |
| 79 const CreateAdvertisementCallback& callback, | 79 const CreateAdvertisementCallback& callback, |
| 80 const CreateAdvertisementErrorCallback& error_callback) override; | 80 const CreateAdvertisementErrorCallback& error_callback) override; |
| 81 | 81 |
| 82 // BluetoothDiscoveryManagerMac::Observer overrides: | 82 // BluetoothDiscoveryManagerMac::Observer overrides: |
| 83 void ClassicDeviceFound(IOBluetoothDevice* device) override; | 83 void ClassicDeviceFound(IOBluetoothDevice* device) override; |
| 84 void ClassicDiscoveryStopped(bool unexpected) override; | 84 void ClassicDiscoveryStopped(bool unexpected) override; |
| 85 | 85 |
| 86 // BluetoothLowEnergyDiscoveryManagerMac::Observer override: | |
| 87 void LowEnergyDeviceUpdated(CBPeripheral* peripheral, | |
| 88 NSDictionary* advertisementData, | |
| 89 int rssi) override; | |
| 90 | |
| 91 // Registers that a new |device| has connected to the local host. | 86 // Registers that a new |device| has connected to the local host. |
| 92 void DeviceConnected(IOBluetoothDevice* device); | 87 void DeviceConnected(IOBluetoothDevice* device); |
| 93 | 88 |
| 94 protected: | 89 protected: |
| 95 // BluetoothAdapter override: | 90 // BluetoothAdapter override: |
| 96 void RemovePairingDelegateInternal( | 91 void RemovePairingDelegateInternal( |
| 97 device::BluetoothDevice::PairingDelegate* pairing_delegate) override; | 92 device::BluetoothDevice::PairingDelegate* pairing_delegate) override; |
| 98 | 93 |
| 99 private: | 94 private: |
| 100 friend class BluetoothAdapterMacTest; | 95 friend class BluetoothAdapterMacTest; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 118 bool StartDiscovery(BluetoothDiscoveryFilter* discovery_filter); | 113 bool StartDiscovery(BluetoothDiscoveryFilter* discovery_filter); |
| 119 | 114 |
| 120 void Init(); | 115 void Init(); |
| 121 void InitForTest(scoped_refptr<base::SequencedTaskRunner> ui_task_runner); | 116 void InitForTest(scoped_refptr<base::SequencedTaskRunner> ui_task_runner); |
| 122 void PollAdapter(); | 117 void PollAdapter(); |
| 123 | 118 |
| 124 // Registers that a new |device| has replied to an Inquiry, is paired, or has | 119 // Registers that a new |device| has replied to an Inquiry, is paired, or has |
| 125 // connected to the local host. | 120 // connected to the local host. |
| 126 void ClassicDeviceAdded(IOBluetoothDevice* device); | 121 void ClassicDeviceAdded(IOBluetoothDevice* device); |
| 127 | 122 |
| 128 // Updates |devices_| to include the currently paired devices, as well as any | 123 // BluetoothLowEnergyDiscoveryManagerMac::Observer override: |
| 129 // connected, but unpaired, devices. Notifies observers if any previously | 124 void LowEnergyDeviceUpdated(CBPeripheral* peripheral, |
| 130 // paired or connected devices are no longer present. | 125 NSDictionary* advertisementData, |
| 131 void UpdateDevices(); | 126 int rssi) override; |
| 127 | |
| 128 // Removes from |devices_| any previously paired, connected or seen devices | |
| 129 // which are no longer present. Notifies observers. | |
| 130 void RemoveTimedOutDevices(); | |
| 131 | |
| 132 // Updates |devices_| to include the currently paired devices and notifies | |
| 133 // observers. | |
| 134 void AddPairedDevices(); | |
| 132 | 135 |
| 133 std::string address_; | 136 std::string address_; |
| 134 std::string name_; | 137 std::string name_; |
| 135 bool powered_; | 138 bool powered_; |
| 136 | 139 |
| 137 int num_discovery_sessions_; | 140 int num_discovery_sessions_; |
| 138 | 141 |
| 139 // Discovery manager for Bluetooth Classic. | 142 // Discovery manager for Bluetooth Classic. |
| 140 scoped_ptr<BluetoothDiscoveryManagerMac> classic_discovery_manager_; | 143 scoped_ptr<BluetoothDiscoveryManagerMac> classic_discovery_manager_; |
| 141 | 144 |
| 142 // Discovery manager for Bluetooth Low Energy. | 145 // Discovery manager for Bluetooth Low Energy. |
| 143 scoped_ptr<BluetoothLowEnergyDiscoveryManagerMac> | 146 scoped_ptr<BluetoothLowEnergyDiscoveryManagerMac> |
| 144 low_energy_discovery_manager_; | 147 low_energy_discovery_manager_; |
| 145 | 148 |
| 146 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | 149 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
| 147 | 150 |
| 151 // The length of time that must elapse since the last Inquiry response (on | |
| 152 // Classic devices) or call to BluetoothLowEnergyDevice::Update() (on Low | |
| 153 // Energy) before a discovered device is considered to be no longer available. | |
| 154 const static NSTimeInterval kDiscoveryTimeoutSec; | |
|
armansito
2015/07/07 19:07:21
Move this above member variable declarations, per
krstnmnlsn
2015/07/07 21:58:01
Done.
| |
| 155 | |
| 148 base::WeakPtrFactory<BluetoothAdapterMac> weak_ptr_factory_; | 156 base::WeakPtrFactory<BluetoothAdapterMac> weak_ptr_factory_; |
| 149 | 157 |
| 150 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterMac); | 158 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterMac); |
| 151 }; | 159 }; |
| 152 | 160 |
| 153 } // namespace device | 161 } // namespace device |
| 154 | 162 |
| 155 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_ | 163 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_ |
| OLD | NEW |