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