OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "device/bluetooth/dbus/bluetooth_gatt_application_service_provider.h" |
| 6 |
| 7 #include <string> |
| 8 #include <utility> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/memory/ptr_util.h" |
| 12 #include "device/bluetooth/bluetooth_uuid.h" |
| 13 #include "device/bluetooth/bluez/bluetooth_gatt_characteristic_delegate_wrapper.
h" |
| 14 #include "device/bluetooth/bluez/bluetooth_gatt_descriptor_delegate_wrapper.h" |
| 15 #include "device/bluetooth/bluez/bluetooth_gatt_service_bluez.h" |
| 16 #include "device/bluetooth/dbus/bluetooth_gatt_application_service_provider_impl
.h" |
| 17 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.h
" |
| 18 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.h" |
| 19 #include "device/bluetooth/dbus/bluetooth_gatt_service_service_provider.h" |
| 20 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
| 21 #include "device/bluetooth/dbus/fake_bluetooth_gatt_application_service_provider
.h" |
| 22 |
| 23 namespace bluez { |
| 24 |
| 25 BluetoothGattApplicationServiceProvider:: |
| 26 BluetoothGattApplicationServiceProvider() {} |
| 27 |
| 28 BluetoothGattApplicationServiceProvider:: |
| 29 ~BluetoothGattApplicationServiceProvider() {} |
| 30 |
| 31 // static |
| 32 void BluetoothGattApplicationServiceProvider::CreateAttributeServiceProviders( |
| 33 dbus::Bus* bus, |
| 34 const std::map<dbus::ObjectPath, BluetoothLocalGattServiceBlueZ*>& services, |
| 35 std::vector<std::unique_ptr<BluetoothGattServiceServiceProvider>>* |
| 36 service_providers, |
| 37 std::vector<std::unique_ptr<BluetoothGattCharacteristicServiceProvider>>* |
| 38 characteristic_providers, |
| 39 std::vector<std::unique_ptr<BluetoothGattDescriptorServiceProvider>>* |
| 40 descriptor_providers) { |
| 41 for (const auto& service : services) { |
| 42 service_providers->push_back( |
| 43 base::WrapUnique(BluetoothGattServiceServiceProvider::Create( |
| 44 bus, service.second->object_path(), |
| 45 service.second->GetUUID().value(), |
| 46 std::vector<dbus::ObjectPath>()))); |
| 47 for (const auto& characteristic : service.second->GetCharacteristics()) { |
| 48 characteristic_providers->push_back( |
| 49 base::WrapUnique(BluetoothGattCharacteristicServiceProvider::Create( |
| 50 bus, characteristic->object_path(), |
| 51 base::WrapUnique(new BluetoothGattCharacteristicDelegateWrapper( |
| 52 service.second, characteristic.get())), |
| 53 characteristic->GetUUID().value(), std::vector<std::string>(), |
| 54 std::vector<std::string>(), service.second->object_path()))); |
| 55 for (const auto& descriptor : characteristic->GetDescriptors()) { |
| 56 descriptor_providers->push_back( |
| 57 base::WrapUnique(BluetoothGattDescriptorServiceProvider::Create( |
| 58 bus, descriptor->object_path(), |
| 59 new BluetoothGattDescriptorDelegateWrapper(service.second, |
| 60 descriptor.get()), |
| 61 descriptor->GetUUID().value(), std::vector<std::string>(), |
| 62 characteristic->object_path()))); |
| 63 } |
| 64 } |
| 65 } |
| 66 } |
| 67 |
| 68 // static |
| 69 std::unique_ptr<BluetoothGattApplicationServiceProvider> |
| 70 BluetoothGattApplicationServiceProvider::Create( |
| 71 dbus::Bus* bus, |
| 72 const dbus::ObjectPath& object_path, |
| 73 const std::map<dbus::ObjectPath, BluetoothLocalGattServiceBlueZ*>& |
| 74 services) { |
| 75 if (!bluez::BluezDBusManager::Get()->IsUsingFakes()) { |
| 76 return base::WrapUnique(new BluetoothGattApplicationServiceProviderImpl( |
| 77 bus, object_path, services)); |
| 78 } |
| 79 return base::WrapUnique( |
| 80 new FakeBluetoothGattApplicationServiceProvider(object_path, services)); |
| 81 } |
| 82 |
| 83 } // namespace bluez |
OLD | NEW |