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_descriptor_bluez.h" | 5 #include "device/bluetooth/bluez/bluetooth_local_gatt_descriptor_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" |
| 11 #include "device/bluetooth/bluez/bluetooth_local_gatt_characteristic_bluez.h" |
| 12 #include "device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.h" |
10 | 13 |
11 namespace bluez { | 14 namespace bluez { |
12 | 15 |
| 16 device::BluetoothUUID BluetoothLocalGattDescriptorBlueZ::GetUUID() const { |
| 17 return uuid_; |
| 18 } |
| 19 |
| 20 device::BluetoothGattCharacteristic::Permissions |
| 21 BluetoothLocalGattDescriptorBlueZ::GetPermissions() const { |
| 22 return device::BluetoothGattCharacteristic::Permissions(); |
| 23 } |
| 24 |
| 25 // static |
| 26 base::WeakPtr<device::BluetoothLocalGattDescriptor> |
| 27 BluetoothLocalGattDescriptorBlueZ::Create( |
| 28 const device::BluetoothUUID& uuid, |
| 29 device::BluetoothGattCharacteristic::Permissions permissions, |
| 30 device::BluetoothLocalGattCharacteristic* characteristic) { |
| 31 DCHECK(characteristic); |
| 32 BluetoothLocalGattCharacteristicBlueZ* characteristic_bluez = |
| 33 static_cast<BluetoothLocalGattCharacteristicBlueZ*>(characteristic); |
| 34 BluetoothLocalGattDescriptorBlueZ* descriptor = |
| 35 new BluetoothLocalGattDescriptorBlueZ(uuid, characteristic_bluez); |
| 36 characteristic_bluez->AddDescriptor(base::WrapUnique(descriptor)); |
| 37 return descriptor->weak_ptr_factory_.GetWeakPtr(); |
| 38 } |
| 39 |
13 BluetoothLocalGattDescriptorBlueZ::BluetoothLocalGattDescriptorBlueZ( | 40 BluetoothLocalGattDescriptorBlueZ::BluetoothLocalGattDescriptorBlueZ( |
14 const dbus::ObjectPath& object_path) | 41 const device::BluetoothUUID& uuid, |
15 : BluetoothGattDescriptorBlueZ(object_path), weak_ptr_factory_(this) { | 42 BluetoothLocalGattCharacteristicBlueZ* characteristic) |
| 43 : uuid_(uuid), characteristic_(characteristic), weak_ptr_factory_(this) { |
| 44 DCHECK(characteristic->GetService()); |
| 45 object_path_ = |
| 46 characteristic->GetService()->GenerateAttributeObjectPath("descriptor"); |
16 VLOG(1) << "Creating local GATT descriptor with identifier: " | 47 VLOG(1) << "Creating local GATT descriptor with identifier: " |
17 << GetIdentifier(); | 48 << GetIdentifier(); |
18 } | 49 } |
19 | 50 |
20 BluetoothLocalGattDescriptorBlueZ::~BluetoothLocalGattDescriptorBlueZ() {} | 51 BluetoothLocalGattDescriptorBlueZ::~BluetoothLocalGattDescriptorBlueZ() {} |
21 | 52 |
| 53 BluetoothLocalGattCharacteristicBlueZ* |
| 54 BluetoothLocalGattDescriptorBlueZ::GetCharacteristic() const { |
| 55 return characteristic_; |
| 56 } |
| 57 |
22 } // namespace bluez | 58 } // namespace bluez |
OLD | NEW |