| 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/bluez/bluetooth_local_gatt_characteristic_bluez.h" | 5 #include "device/bluetooth/bluez/bluetooth_local_gatt_characteristic_bluez.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" |
| 10 #include "device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.h" | 11 #include "device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.h" |
| 11 | 12 |
| 13 namespace device { |
| 14 |
| 15 // static |
| 16 base::WeakPtr<BluetoothLocalGattCharacteristic> |
| 17 BluetoothLocalGattCharacteristic::Create(const BluetoothUUID& uuid, |
| 18 Properties properties, |
| 19 Permissions permissions, |
| 20 BluetoothLocalGattService* service) { |
| 21 return bluez::BluetoothLocalGattCharacteristicBlueZ::Create( |
| 22 uuid, properties, permissions, service); |
| 23 } |
| 24 |
| 25 } // device |
| 26 |
| 12 namespace bluez { | 27 namespace bluez { |
| 13 | 28 |
| 29 device::BluetoothUUID BluetoothLocalGattCharacteristicBlueZ::GetUUID() const { |
| 30 return uuid_; |
| 31 } |
| 32 |
| 33 device::BluetoothGattCharacteristic::Properties |
| 34 BluetoothLocalGattCharacteristicBlueZ::GetProperties() const { |
| 35 return Properties(); |
| 36 } |
| 37 |
| 38 device::BluetoothGattCharacteristic::Permissions |
| 39 BluetoothLocalGattCharacteristicBlueZ::GetPermissions() const { |
| 40 return Permissions(); |
| 41 } |
| 42 |
| 43 // static |
| 44 base::WeakPtr<device::BluetoothLocalGattCharacteristic> |
| 45 BluetoothLocalGattCharacteristicBlueZ::Create( |
| 46 const device::BluetoothUUID& uuid, |
| 47 device::BluetoothGattCharacteristic::Properties properties, |
| 48 device::BluetoothGattCharacteristic::Permissions permissions, |
| 49 device::BluetoothLocalGattService* service) { |
| 50 DCHECK(service); |
| 51 BluetoothLocalGattServiceBlueZ* service_bluez = |
| 52 static_cast<BluetoothLocalGattServiceBlueZ*>(service); |
| 53 BluetoothLocalGattCharacteristicBlueZ* characteristic = |
| 54 new BluetoothLocalGattCharacteristicBlueZ(uuid, service_bluez); |
| 55 service_bluez->AddCharacteristic(base::WrapUnique(characteristic)); |
| 56 return characteristic->weak_ptr_factory_.GetWeakPtr(); |
| 57 } |
| 58 |
| 14 BluetoothLocalGattCharacteristicBlueZ::BluetoothLocalGattCharacteristicBlueZ( | 59 BluetoothLocalGattCharacteristicBlueZ::BluetoothLocalGattCharacteristicBlueZ( |
| 15 BluetoothLocalGattServiceBlueZ* service, | 60 const device::BluetoothUUID& uuid, |
| 16 const dbus::ObjectPath& object_path) | 61 BluetoothLocalGattServiceBlueZ* service) |
| 17 : BluetoothGattCharacteristicBlueZ(object_path), weak_ptr_factory_(this) { | 62 : uuid_(uuid), service_(service), weak_ptr_factory_(this) { |
| 63 object_path_ = BluetoothLocalGattServiceBlueZ::AddGuidToObjectPath( |
| 64 service->object_path().value() + "/characteristic"); |
| 18 VLOG(1) << "Creating local GATT characteristic with identifier: " | 65 VLOG(1) << "Creating local GATT characteristic with identifier: " |
| 19 << GetIdentifier(); | 66 << GetIdentifier(); |
| 20 } | 67 } |
| 21 | 68 |
| 22 BluetoothLocalGattCharacteristicBlueZ:: | 69 BluetoothLocalGattCharacteristicBlueZ:: |
| 23 ~BluetoothLocalGattCharacteristicBlueZ() {} | 70 ~BluetoothLocalGattCharacteristicBlueZ() {} |
| 24 | 71 |
| 72 BluetoothLocalGattServiceBlueZ* |
| 73 BluetoothLocalGattCharacteristicBlueZ::GetService() { |
| 74 return service_; |
| 75 } |
| 76 |
| 77 void BluetoothLocalGattCharacteristicBlueZ::AddDescriptor( |
| 78 std::unique_ptr<BluetoothLocalGattDescriptorBlueZ> descriptor) { |
| 79 descriptors_.push_back(std::move(descriptor)); |
| 80 } |
| 81 |
| 82 const std::vector<std::unique_ptr<BluetoothLocalGattDescriptorBlueZ>>& |
| 83 BluetoothLocalGattCharacteristicBlueZ::GetDescriptors() const { |
| 84 return descriptors_; |
| 85 } |
| 86 |
| 25 } // namespace bluez | 87 } // namespace bluez |
| OLD | NEW |