From 2a19c63448c84c1805fb1a585c3651318bb86ca7 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 28 Aug 2018 15:28:34 +0200 Subject: BASELINE: Update Chromium to 69.0.3497.70 Change-Id: I2b7b56e4e7a8b26656930def0d4575dc32b900a0 Reviewed-by: Allan Sandfeld Jensen --- .../bluetooth/bluetooth_remote_gatt_service.cc | 42 ++++++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'chromium/device/bluetooth/bluetooth_remote_gatt_service.cc') diff --git a/chromium/device/bluetooth/bluetooth_remote_gatt_service.cc b/chromium/device/bluetooth/bluetooth_remote_gatt_service.cc index 1df683b80d1..1441f58508c 100644 --- a/chromium/device/bluetooth/bluetooth_remote_gatt_service.cc +++ b/chromium/device/bluetooth/bluetooth_remote_gatt_service.cc @@ -4,6 +4,8 @@ #include "device/bluetooth/bluetooth_remote_gatt_service.h" +#include + #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" #include "device/bluetooth/bluetooth_uuid.h" @@ -13,17 +15,31 @@ BluetoothRemoteGattService::BluetoothRemoteGattService() = default; BluetoothRemoteGattService::~BluetoothRemoteGattService() = default; +std::vector +BluetoothRemoteGattService::GetCharacteristics() const { + std::vector characteristics; + characteristics.reserve(characteristics_.size()); + for (const auto& characteristic : characteristics_) + characteristics.push_back(characteristic.second.get()); + return characteristics; +} + +BluetoothRemoteGattCharacteristic* +BluetoothRemoteGattService::GetCharacteristic( + const std::string& identifier) const { + auto iter = characteristics_.find(identifier); + return iter != characteristics_.end() ? iter->second.get() : nullptr; +} + std::vector BluetoothRemoteGattService::GetCharacteristicsByUUID( - const BluetoothUUID& characteristic_uuid) { + const BluetoothUUID& characteristic_uuid) const { std::vector result; - std::vector characteristics = - GetCharacteristics(); - for (auto* characteristic : characteristics) { - if (characteristic->GetUUID() == characteristic_uuid) { - result.push_back(characteristic); - } + for (const auto& characteristic : characteristics_) { + if (characteristic.second->GetUUID() == characteristic_uuid) + result.push_back(characteristic.second.get()); } + return result; } @@ -35,4 +51,16 @@ void BluetoothRemoteGattService::SetDiscoveryComplete(bool complete) { discovery_complete_ = complete; } +bool BluetoothRemoteGattService::AddCharacteristic( + std::unique_ptr characteristic) { + if (!characteristic) + return false; + + const auto& characteristic_raw = *characteristic; + return characteristics_ + .try_emplace(characteristic_raw.GetIdentifier(), + std::move(characteristic)) + .second; +} + } // namespace device -- cgit v1.2.1