diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-28 15:28:34 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-28 13:54:51 +0000 |
commit | 2a19c63448c84c1805fb1a585c3651318bb86ca7 (patch) | |
tree | eb17888e8531aa6ee5e85721bd553b832a7e5156 /chromium/device/bluetooth/bluetooth_remote_gatt_service.cc | |
parent | b014812705fc80bff0a5c120dfcef88f349816dc (diff) | |
download | qtwebengine-chromium-2a19c63448c84c1805fb1a585c3651318bb86ca7.tar.gz |
BASELINE: Update Chromium to 69.0.3497.70
Change-Id: I2b7b56e4e7a8b26656930def0d4575dc32b900a0
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/device/bluetooth/bluetooth_remote_gatt_service.cc')
-rw-r--r-- | chromium/device/bluetooth/bluetooth_remote_gatt_service.cc | 42 |
1 files changed, 35 insertions, 7 deletions
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 <utility> + #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" #include "device/bluetooth/bluetooth_uuid.h" @@ -14,16 +16,30 @@ BluetoothRemoteGattService::BluetoothRemoteGattService() = default; BluetoothRemoteGattService::~BluetoothRemoteGattService() = default; std::vector<BluetoothRemoteGattCharacteristic*> +BluetoothRemoteGattService::GetCharacteristics() const { + std::vector<BluetoothRemoteGattCharacteristic*> 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<BluetoothRemoteGattCharacteristic*> BluetoothRemoteGattService::GetCharacteristicsByUUID( - const BluetoothUUID& characteristic_uuid) { + const BluetoothUUID& characteristic_uuid) const { std::vector<BluetoothRemoteGattCharacteristic*> result; - std::vector<BluetoothRemoteGattCharacteristic*> 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<BluetoothRemoteGattCharacteristic> characteristic) { + if (!characteristic) + return false; + + const auto& characteristic_raw = *characteristic; + return characteristics_ + .try_emplace(characteristic_raw.GetIdentifier(), + std::move(characteristic)) + .second; +} + } // namespace device |