| 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 <memory> | 10 #include <memory> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterMac | 43 class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterMac |
| 44 : public BluetoothAdapter, | 44 : public BluetoothAdapter, |
| 45 public BluetoothDiscoveryManagerMac::Observer, | 45 public BluetoothDiscoveryManagerMac::Observer, |
| 46 public BluetoothLowEnergyDiscoveryManagerMac::Observer { | 46 public BluetoothLowEnergyDiscoveryManagerMac::Observer { |
| 47 public: | 47 public: |
| 48 static base::WeakPtr<BluetoothAdapterMac> CreateAdapter(); | 48 static base::WeakPtr<BluetoothAdapterMac> CreateAdapter(); |
| 49 static base::WeakPtr<BluetoothAdapterMac> CreateAdapterForTest( | 49 static base::WeakPtr<BluetoothAdapterMac> CreateAdapterForTest( |
| 50 std::string name, | 50 std::string name, |
| 51 std::string address, | 51 std::string address, |
| 52 scoped_refptr<base::SequencedTaskRunner> ui_task_runner); | 52 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, |
| 53 CBCentralManager* central_manager = nil); |
| 53 | 54 |
| 54 // Converts CBUUID into BluetoothUUID | 55 // Converts CBUUID into BluetoothUUID |
| 55 static BluetoothUUID BluetoothUUIDWithCBUUID(CBUUID* UUID); | 56 static BluetoothUUID BluetoothUUIDWithCBUUID(CBUUID* UUID); |
| 56 | 57 |
| 57 // BluetoothAdapter overrides: | 58 // BluetoothAdapter overrides: |
| 58 std::string GetAddress() const override; | 59 std::string GetAddress() const override; |
| 59 std::string GetName() const override; | 60 std::string GetName() const override; |
| 60 void SetName(const std::string& name, | 61 void SetName(const std::string& name, |
| 61 const base::Closure& callback, | 62 const base::Closure& callback, |
| 62 const ErrorCallback& error_callback) override; | 63 const ErrorCallback& error_callback) override; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 void ClassicDeviceAdded(IOBluetoothDevice* device); | 171 void ClassicDeviceAdded(IOBluetoothDevice* device); |
| 171 | 172 |
| 172 // BluetoothLowEnergyDiscoveryManagerMac::Observer override: | 173 // BluetoothLowEnergyDiscoveryManagerMac::Observer override: |
| 173 void LowEnergyDeviceUpdated(CBPeripheral* peripheral, | 174 void LowEnergyDeviceUpdated(CBPeripheral* peripheral, |
| 174 NSDictionary* advertisement_data, | 175 NSDictionary* advertisement_data, |
| 175 int rssi) override; | 176 int rssi) override; |
| 176 | 177 |
| 177 // Updates |devices_| when there is a change to the CBCentralManager's state. | 178 // Updates |devices_| when there is a change to the CBCentralManager's state. |
| 178 void LowEnergyCentralManagerUpdatedState(); | 179 void LowEnergyCentralManagerUpdatedState(); |
| 179 | 180 |
| 180 // Updates |devices_| to include the currently paired devices and notifies | 181 // Updates |devices_| to include the currently paired Bluetooth Classic |
| 181 // observers. | 182 // devices and notifies observers. |
| 182 void AddPairedDevices(); | 183 void AddPairedClassicDevices(); |
| 184 |
| 185 // Updates |devices_| to include the currently connected Bluetooth Low Energy |
| 186 // devices and notifies observers. |
| 187 void AddConnectedLowEnergyDevices(); |
| 183 | 188 |
| 184 // Returns the BLE device associated with the CoreBluetooth peripheral. | 189 // Returns the BLE device associated with the CoreBluetooth peripheral. |
| 185 BluetoothLowEnergyDeviceMac* GetBluetoothLowEnergyDeviceMac( | 190 BluetoothLowEnergyDeviceMac* GetBluetoothLowEnergyDeviceMac( |
| 186 CBPeripheral* peripheral); | 191 CBPeripheral* peripheral); |
| 187 | 192 |
| 188 std::string address_; | 193 std::string address_; |
| 189 std::string name_; | 194 std::string name_; |
| 190 bool classic_powered_; | 195 bool classic_powered_; |
| 191 int num_discovery_sessions_; | 196 int num_discovery_sessions_; |
| 192 | 197 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 205 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | 210 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
| 206 | 211 |
| 207 base::WeakPtrFactory<BluetoothAdapterMac> weak_ptr_factory_; | 212 base::WeakPtrFactory<BluetoothAdapterMac> weak_ptr_factory_; |
| 208 | 213 |
| 209 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterMac); | 214 DISALLOW_COPY_AND_ASSIGN(BluetoothAdapterMac); |
| 210 }; | 215 }; |
| 211 | 216 |
| 212 } // namespace device | 217 } // namespace device |
| 213 | 218 |
| 214 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_ | 219 #endif // DEVICE_BLUETOOTH_BLUETOOTH_ADAPTER_MAC_H_ |
| OLD | NEW |