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 #ifndef DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_BLUEZ_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_BLUEZ_H_ |
6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_BLUEZ_H_ | 6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_BLUEZ_H_ |
7 | 7 |
| 8 #include <vector> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
10 #include "dbus/object_path.h" | |
11 #include "device/bluetooth/bluetooth_local_gatt_characteristic.h" | 12 #include "device/bluetooth/bluetooth_local_gatt_characteristic.h" |
| 13 #include "device/bluetooth/bluetooth_local_gatt_service.h" |
| 14 #include "device/bluetooth/bluetooth_uuid.h" |
12 #include "device/bluetooth/bluez/bluetooth_gatt_characteristic_bluez.h" | 15 #include "device/bluetooth/bluez/bluetooth_gatt_characteristic_bluez.h" |
| 16 #include "device/bluetooth/bluez/bluetooth_local_gatt_descriptor_bluez.h" |
13 | 17 |
14 namespace bluez { | 18 namespace bluez { |
15 | 19 |
16 class BluetoothLocalGattServiceBlueZ; | 20 class BluetoothLocalGattServiceBlueZ; |
17 | 21 |
18 // The BluetoothLocalGattCharacteristicBlueZ class implements | 22 // The BluetoothLocalGattCharacteristicBlueZ class implements |
19 // BluetoothLocalGattCharacteristic for local GATT characteristics for | 23 // BluetoothLocalGattCharacteristic for local GATT characteristics for |
20 // platforms that use BlueZ. | 24 // platforms that use BlueZ. |
21 class BluetoothLocalGattCharacteristicBlueZ | 25 class BluetoothLocalGattCharacteristicBlueZ |
22 : public BluetoothGattCharacteristicBlueZ, | 26 : public BluetoothGattCharacteristicBlueZ, |
23 public device::BluetoothLocalGattCharacteristic { | 27 public device::BluetoothLocalGattCharacteristic { |
24 public: | 28 public: |
| 29 static base::WeakPtr<device::BluetoothLocalGattCharacteristic> Create( |
| 30 const device::BluetoothUUID& uuid, |
| 31 BluetoothGattCharacteristic::Properties properties, |
| 32 BluetoothGattCharacteristic::Permissions permissions, |
| 33 device::BluetoothLocalGattService* service); |
| 34 |
| 35 BluetoothLocalGattCharacteristicBlueZ( |
| 36 const device::BluetoothUUID& uuid, |
| 37 BluetoothLocalGattServiceBlueZ* service); |
| 38 ~BluetoothLocalGattCharacteristicBlueZ() override; |
| 39 |
| 40 // device::BluetoothLocalGattCharacteristic overrides. |
| 41 device::BluetoothUUID GetUUID() const override; |
| 42 Properties GetProperties() const override; |
| 43 Permissions GetPermissions() const override; |
| 44 |
| 45 BluetoothLocalGattServiceBlueZ* GetService(); |
| 46 |
| 47 const std::vector<std::unique_ptr<BluetoothLocalGattDescriptorBlueZ>>& |
| 48 GetDescriptors() const; |
| 49 |
25 private: | 50 private: |
26 friend class BluetoothLocalGattServiceBlueZ; | 51 friend class BluetoothLocalGattDescriptorBlueZ; |
| 52 // Needs access to weak_ptr_factory_. |
| 53 friend device::BluetoothLocalGattCharacteristic; |
27 | 54 |
28 BluetoothLocalGattCharacteristicBlueZ(BluetoothLocalGattServiceBlueZ* service, | 55 // Adds a descriptor to this characteristic. |
29 const dbus::ObjectPath& object_path); | 56 void AddDescriptor( |
30 ~BluetoothLocalGattCharacteristicBlueZ() override; | 57 std::unique_ptr<BluetoothLocalGattDescriptorBlueZ> descriptor); |
| 58 |
| 59 // UUID of this characteristic. |
| 60 device::BluetoothUUID uuid_; |
| 61 |
| 62 // Service that contains this characteristic. |
| 63 BluetoothLocalGattServiceBlueZ* service_; |
| 64 |
| 65 // Descriptors contained by this characteristic. |
| 66 std::vector<std::unique_ptr<BluetoothLocalGattDescriptorBlueZ>> descriptors_; |
31 | 67 |
32 // Note: This should remain the last member so it'll be destroyed and | 68 // Note: This should remain the last member so it'll be destroyed and |
33 // invalidate its weak pointers before any other members are destroyed. | 69 // invalidate its weak pointers before any other members are destroyed. |
34 base::WeakPtrFactory<BluetoothLocalGattCharacteristicBlueZ> weak_ptr_factory_; | 70 base::WeakPtrFactory<BluetoothLocalGattCharacteristicBlueZ> weak_ptr_factory_; |
35 | 71 |
36 DISALLOW_COPY_AND_ASSIGN(BluetoothLocalGattCharacteristicBlueZ); | 72 DISALLOW_COPY_AND_ASSIGN(BluetoothLocalGattCharacteristicBlueZ); |
37 }; | 73 }; |
38 | 74 |
39 } // namespace bluez | 75 } // namespace bluez |
40 | 76 |
41 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_BLUEZ_H_ | 77 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_LOCAL_GATT_CHARACTERISTIC_BLUEZ_H_ |
OLD | NEW |