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 #include "device/bluetooth/bluetooth_adapter_mac.h" | 5 #include "device/bluetooth/bluetooth_adapter_mac.h" |
6 | 6 |
7 #import <IOBluetooth/objc/IOBluetoothDevice.h> | 7 #import <IOBluetooth/objc/IOBluetoothDevice.h> |
8 #import <IOBluetooth/objc/IOBluetoothHostController.h> | 8 #import <IOBluetooth/objc/IOBluetoothHostController.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 BluetoothAdapterMac* adapter = new BluetoothAdapterMac(); | 61 BluetoothAdapterMac* adapter = new BluetoothAdapterMac(); |
62 adapter->InitForTest(ui_task_runner); | 62 adapter->InitForTest(ui_task_runner); |
63 adapter->name_ = name; | 63 adapter->name_ = name; |
64 adapter->address_ = address; | 64 adapter->address_ = address; |
65 return adapter->weak_ptr_factory_.GetWeakPtr(); | 65 return adapter->weak_ptr_factory_.GetWeakPtr(); |
66 } | 66 } |
67 | 67 |
68 // static | 68 // static |
69 BluetoothUUID BluetoothAdapterMac::BluetoothUUIDWithCBUUID(CBUUID* uuid) { | 69 BluetoothUUID BluetoothAdapterMac::BluetoothUUIDWithCBUUID(CBUUID* uuid) { |
70 // UUIDString only available OS X >= 10.10. | 70 // UUIDString only available OS X >= 10.10. |
71 DCHECK(base::mac::IsOSYosemiteOrLater()); | 71 DCHECK(base::mac::IsAtLeastOS10_10()); |
72 std::string uuid_c_string = base::SysNSStringToUTF8([uuid UUIDString]); | 72 std::string uuid_c_string = base::SysNSStringToUTF8([uuid UUIDString]); |
73 return device::BluetoothUUID(uuid_c_string); | 73 return device::BluetoothUUID(uuid_c_string); |
74 } | 74 } |
75 | 75 |
76 BluetoothAdapterMac::BluetoothAdapterMac() | 76 BluetoothAdapterMac::BluetoothAdapterMac() |
77 : BluetoothAdapter(), | 77 : BluetoothAdapter(), |
78 classic_powered_(false), | 78 classic_powered_(false), |
79 num_discovery_sessions_(0), | 79 num_discovery_sessions_(0), |
80 classic_discovery_manager_( | 80 classic_discovery_manager_( |
81 BluetoothDiscoveryManagerMac::CreateClassic(this)), | 81 BluetoothDiscoveryManagerMac::CreateClassic(this)), |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 void BluetoothAdapterMac::DeviceConnected(IOBluetoothDevice* device) { | 234 void BluetoothAdapterMac::DeviceConnected(IOBluetoothDevice* device) { |
235 // TODO(isherman): Investigate whether this method can be replaced with a call | 235 // TODO(isherman): Investigate whether this method can be replaced with a call |
236 // to +registerForConnectNotifications:selector:. | 236 // to +registerForConnectNotifications:selector:. |
237 DVLOG(1) << "Adapter registered a new connection from device with address: " | 237 DVLOG(1) << "Adapter registered a new connection from device with address: " |
238 << BluetoothClassicDeviceMac::GetDeviceAddress(device); | 238 << BluetoothClassicDeviceMac::GetDeviceAddress(device); |
239 ClassicDeviceAdded(device); | 239 ClassicDeviceAdded(device); |
240 } | 240 } |
241 | 241 |
242 // static | 242 // static |
243 bool BluetoothAdapterMac::IsLowEnergyAvailable() { | 243 bool BluetoothAdapterMac::IsLowEnergyAvailable() { |
244 return base::mac::IsOSYosemiteOrLater(); | 244 return base::mac::IsAtLeastOS10_10(); |
245 } | 245 } |
246 | 246 |
247 void BluetoothAdapterMac::RemovePairingDelegateInternal( | 247 void BluetoothAdapterMac::RemovePairingDelegateInternal( |
248 BluetoothDevice::PairingDelegate* pairing_delegate) {} | 248 BluetoothDevice::PairingDelegate* pairing_delegate) {} |
249 | 249 |
250 void BluetoothAdapterMac::SetCentralManagerForTesting( | 250 void BluetoothAdapterMac::SetCentralManagerForTesting( |
251 CBCentralManager* central_manager) { | 251 CBCentralManager* central_manager) { |
252 CHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); | 252 CHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); |
253 central_manager.delegate = low_energy_central_manager_delegate_; | 253 central_manager.delegate = low_energy_central_manager_delegate_; |
254 low_energy_central_manager_.reset(central_manager, | 254 low_energy_central_manager_.reset(central_manager, |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 std::string device_address = | 635 std::string device_address = |
636 BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral); | 636 BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral); |
637 DevicesMap::const_iterator iter = devices_.find(device_address); | 637 DevicesMap::const_iterator iter = devices_.find(device_address); |
638 if (iter == devices_.end()) { | 638 if (iter == devices_.end()) { |
639 return nil; | 639 return nil; |
640 } | 640 } |
641 return static_cast<BluetoothLowEnergyDeviceMac*>(iter->second); | 641 return static_cast<BluetoothLowEnergyDeviceMac*>(iter->second); |
642 } | 642 } |
643 | 643 |
644 } // namespace device | 644 } // namespace device |
OLD | NEW |