| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_remote_gatt_service_mac.h" | 5 #include "device/bluetooth/bluetooth_remote_gatt_service_mac.h" |
| 6 | 6 |
| 7 #import <CoreBluetooth/CoreBluetooth.h> | 7 #import <CoreBluetooth/CoreBluetooth.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 CBPeripheral* BluetoothRemoteGattServiceMac::GetCBPeripheral() const { | 185 CBPeripheral* BluetoothRemoteGattServiceMac::GetCBPeripheral() const { |
| 186 return bluetooth_device_mac_->GetPeripheral(); | 186 return bluetooth_device_mac_->GetPeripheral(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 CBService* BluetoothRemoteGattServiceMac::GetService() const { | 189 CBService* BluetoothRemoteGattServiceMac::GetService() const { |
| 190 return service_; | 190 return service_; |
| 191 } | 191 } |
| 192 | 192 |
| 193 BluetoothRemoteGattCharacteristicMac* | 193 BluetoothRemoteGattCharacteristicMac* |
| 194 BluetoothRemoteGattServiceMac::GetBluetoothRemoteGattCharacteristicMac( | 194 BluetoothRemoteGattServiceMac::GetBluetoothRemoteGattCharacteristicMac( |
| 195 CBCharacteristic* characteristic) const { | 195 CBCharacteristic* cb_characteristic) const { |
| 196 auto found = std::find_if( | 196 auto found = std::find_if( |
| 197 gatt_characteristic_macs_.begin(), gatt_characteristic_macs_.end(), | 197 gatt_characteristic_macs_.begin(), gatt_characteristic_macs_.end(), |
| 198 [characteristic]( | 198 [cb_characteristic]( |
| 199 const std::pair< | 199 const std::pair< |
| 200 const std::string, | 200 const std::string, |
| 201 std::unique_ptr<BluetoothRemoteGattCharacteristicMac>>& pair) { | 201 std::unique_ptr<BluetoothRemoteGattCharacteristicMac>>& pair) { |
| 202 return pair.second->GetCBCharacteristic() == characteristic; | 202 return pair.second->GetCBCharacteristic() == cb_characteristic; |
| 203 }); | 203 }); |
| 204 if (found == gatt_characteristic_macs_.end()) { | 204 if (found == gatt_characteristic_macs_.end()) { |
| 205 return nullptr; | 205 return nullptr; |
| 206 } else { | 206 } else { |
| 207 return found->second.get(); | 207 return found->second.get(); |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 BluetoothRemoteGattDescriptorMac* |
| 212 BluetoothRemoteGattServiceMac::GetBluetoothRemoteGattDescriptorMac( |
| 213 CBDescriptor* cb_descriptor) const { |
| 214 CBCharacteristic* cb_characteristic = [cb_descriptor characteristic]; |
| 215 BluetoothRemoteGattCharacteristicMac* gatt_characteristic_mac = |
| 216 GetBluetoothRemoteGattCharacteristicMac(cb_characteristic); |
| 217 if (!gatt_characteristic_mac) { |
| 218 return nullptr; |
| 219 } |
| 220 return gatt_characteristic_mac->GetBluetoothRemoteGattDescriptorMac( |
| 221 cb_descriptor); |
| 222 } |
| 223 |
| 211 DEVICE_BLUETOOTH_EXPORT std::ostream& operator<<( | 224 DEVICE_BLUETOOTH_EXPORT std::ostream& operator<<( |
| 212 std::ostream& out, | 225 std::ostream& out, |
| 213 const BluetoothRemoteGattServiceMac& service) { | 226 const BluetoothRemoteGattServiceMac& service) { |
| 214 const BluetoothLowEnergyDeviceMac* bluetooth_device_mac_ = | 227 const BluetoothLowEnergyDeviceMac* bluetooth_device_mac_ = |
| 215 static_cast<const BluetoothLowEnergyDeviceMac*>(service.GetDevice()); | 228 static_cast<const BluetoothLowEnergyDeviceMac*>(service.GetDevice()); |
| 216 return out << "<BluetoothRemoteGattServiceMac " | 229 return out << "<BluetoothRemoteGattServiceMac " |
| 217 << service.GetUUID().canonical_value() << "/" << &service | 230 << service.GetUUID().canonical_value() << "/" << &service |
| 218 << ", device: " << bluetooth_device_mac_->GetAddress() << "/" | 231 << ", device: " << bluetooth_device_mac_->GetAddress() << "/" |
| 219 << bluetooth_device_mac_ << ">"; | 232 << bluetooth_device_mac_ << ">"; |
| 220 } | 233 } |
| 221 | 234 |
| 222 } // namespace device | 235 } // namespace device |
| OLD | NEW |