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