| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_CHARACTERISTIC_BLUEZ_H_ | |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_CHARACTERISTIC_BLUEZ_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/macros.h" | |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "dbus/object_path.h" | |
| 15 #include "device/bluetooth/bluetooth_gatt_characteristic.h" | |
| 16 | |
| 17 namespace device { | |
| 18 | |
| 19 class BluetoothGattDescriptor; | |
| 20 class BluetoothGattService; | |
| 21 | |
| 22 } // namespace device | |
| 23 | |
| 24 namespace bluez { | |
| 25 | |
| 26 class BluetoothGattDescriptorBlueZ; | |
| 27 class BluetoothGattServiceBlueZ; | |
| 28 | |
| 29 // The BluetoothGattCharacteristicBlueZ class implements | |
| 30 // BluetoothGattCharacteristic for GATT characteristics for platforms | |
| 31 // that use BlueZ. | |
| 32 class BluetoothGattCharacteristicBlueZ | |
| 33 : public device::BluetoothGattCharacteristic { | |
| 34 public: | |
| 35 // device::BluetoothGattCharacteristic overrides. | |
| 36 std::string GetIdentifier() const override; | |
| 37 device::BluetoothGattService* GetService() const override; | |
| 38 Permissions GetPermissions() const override; | |
| 39 std::vector<device::BluetoothGattDescriptor*> GetDescriptors() const override; | |
| 40 device::BluetoothGattDescriptor* GetDescriptor( | |
| 41 const std::string& identifier) const override; | |
| 42 | |
| 43 // Object path of the underlying D-Bus characteristic. | |
| 44 const dbus::ObjectPath& object_path() const { return object_path_; } | |
| 45 | |
| 46 protected: | |
| 47 BluetoothGattCharacteristicBlueZ(BluetoothGattServiceBlueZ* service, | |
| 48 const dbus::ObjectPath& object_path); | |
| 49 ~BluetoothGattCharacteristicBlueZ() override; | |
| 50 | |
| 51 // Does not take ownership of the descriptor object. | |
| 52 using DescriptorMap = | |
| 53 std::map<dbus::ObjectPath, BluetoothGattDescriptorBlueZ*>; | |
| 54 | |
| 55 // Mapping from GATT descriptor object paths to descriptor objects owned by | |
| 56 // this characteristic. Since the BlueZ implementation uses object paths | |
| 57 // as unique identifiers, we also use this mapping to return descriptors by | |
| 58 // identifier. | |
| 59 DescriptorMap descriptors_; | |
| 60 | |
| 61 // The GATT service this GATT characteristic belongs to. | |
| 62 BluetoothGattServiceBlueZ* service_; | |
| 63 | |
| 64 private: | |
| 65 friend class BluetoothRemoteGattServiceBlueZ; | |
| 66 | |
| 67 // Object path of the D-Bus characteristic object. | |
| 68 dbus::ObjectPath object_path_; | |
| 69 | |
| 70 // Note: This should remain the last member so it'll be destroyed and | |
| 71 // invalidate its weak pointers before any other members are destroyed. | |
| 72 base::WeakPtrFactory<BluetoothGattCharacteristicBlueZ> weak_ptr_factory_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicBlueZ); | |
| 75 }; | |
| 76 | |
| 77 } // namespace bluez | |
| 78 | |
| 79 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_CHARACTERISTIC_BLUEZ_H_ | |
| OLD | NEW |