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 // static | |
30 base::WeakPtr<device::BluetoothLocalGattCharacteristic> | |
31 BluetoothLocalGattCharacteristicBlueZ::Create( | |
scheib
2016/04/28 01:06:24
Two ::Create methods are not needed, the ___BlueZ:
rkc
2016/04/28 02:06:58
Done.
| |
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_ = BluetoothLocalGattServiceBlueZ::AddGuidToObjectPath( | |
50 service->object_path().value() + "/characteristic"); | |
18 VLOG(1) << "Creating local GATT characteristic with identifier: " | 51 VLOG(1) << "Creating local GATT characteristic with identifier: " |
19 << GetIdentifier(); | 52 << GetIdentifier(); |
20 } | 53 } |
21 | 54 |
22 BluetoothLocalGattCharacteristicBlueZ:: | 55 BluetoothLocalGattCharacteristicBlueZ:: |
23 ~BluetoothLocalGattCharacteristicBlueZ() {} | 56 ~BluetoothLocalGattCharacteristicBlueZ() {} |
24 | 57 |
58 device::BluetoothUUID BluetoothLocalGattCharacteristicBlueZ::GetUUID() const { | |
59 return uuid_; | |
60 } | |
61 | |
62 device::BluetoothGattCharacteristic::Properties | |
63 BluetoothLocalGattCharacteristicBlueZ::GetProperties() const { | |
64 NOTIMPLEMENTED(); | |
65 return Properties(); | |
66 } | |
67 | |
68 device::BluetoothGattCharacteristic::Permissions | |
69 BluetoothLocalGattCharacteristicBlueZ::GetPermissions() const { | |
70 NOTIMPLEMENTED(); | |
71 return Permissions(); | |
72 } | |
73 | |
74 BluetoothLocalGattServiceBlueZ* | |
75 BluetoothLocalGattCharacteristicBlueZ::GetService() { | |
76 return service_; | |
77 } | |
78 | |
79 void BluetoothLocalGattCharacteristicBlueZ::AddDescriptor( | |
80 std::unique_ptr<BluetoothLocalGattDescriptorBlueZ> descriptor) { | |
81 descriptors_.push_back(std::move(descriptor)); | |
82 } | |
83 | |
84 const std::vector<std::unique_ptr<BluetoothLocalGattDescriptorBlueZ>>& | |
85 BluetoothLocalGattCharacteristicBlueZ::GetDescriptors() const { | |
86 return descriptors_; | |
87 } | |
88 | |
25 } // namespace bluez | 89 } // namespace bluez |
OLD | NEW |