Chromium Code Reviews| Index: device/bluetooth/bluetooth_gatt_characteristic_bluez.h |
| diff --git a/device/bluetooth/bluetooth_gatt_characteristic_bluez.h b/device/bluetooth/bluetooth_gatt_characteristic_bluez.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..249ebcd14505e22b6e002a6309292039537b0de2 |
| --- /dev/null |
| +++ b/device/bluetooth/bluetooth_gatt_characteristic_bluez.h |
| @@ -0,0 +1,85 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_CHARACTERISTIC_BLUEZ_H_ |
| +#define DEVICE_BLUETOOTH_BLUETOOTH_GATT_CHARACTERISTIC_BLUEZ_H_ |
| + |
| +#include <stddef.h> |
| +#include <stdint.h> |
| + |
| +#include <map> |
| +#include <queue> |
| +#include <string> |
| +#include <utility> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "dbus/object_path.h" |
| +#include "device/bluetooth/bluetooth_gatt_characteristic.h" |
| +#include "device/bluetooth/bluetooth_uuid.h" |
| + |
| +namespace device { |
| + |
| +class BluetoothGattDescriptor; |
| +class BluetoothGattService; |
| + |
| +} // namespace device |
| + |
| +namespace bluez { |
| + |
| +class BluetoothGattDescriptorBlueZ; |
| +class BluetoothGattServiceBlueZ; |
| + |
| +// The BluetoothGattCharacteristicBlueZ class implements |
| +// BluetoothGattCharacteristic for GATT characteristics for platforms |
| +// that use BlueZ. |
| +class BluetoothGattCharacteristicBlueZ |
| + : public device::BluetoothGattCharacteristic { |
| + public: |
| + // device::BluetoothGattCharacteristic overrides. |
| + std::string GetIdentifier() const override; |
| + device::BluetoothGattService* GetService() const override; |
| + Permissions GetPermissions() const override; |
| + std::vector<device::BluetoothGattDescriptor*> GetDescriptors() const override; |
| + device::BluetoothGattDescriptor* GetDescriptor( |
| + const std::string& identifier) const override; |
| + |
| + // Object path of the underlying D-Bus characteristic. |
| + const dbus::ObjectPath& object_path() const { return object_path_; } |
| + |
| + protected: |
| + BluetoothGattCharacteristicBlueZ(BluetoothGattServiceBlueZ* service, |
| + const dbus::ObjectPath& object_path); |
| + ~BluetoothGattCharacteristicBlueZ() override; |
| + |
| + // Mapping from GATT descriptor object paths to descriptor objects owned by |
| + // this characteristic. Since the BlueZ implementation uses object paths |
| + // as unique identifiers, we also use this mapping to return descriptors by |
| + // identifier. |
| + using DescriptorMap = |
| + std::map<dbus::ObjectPath, BluetoothGattDescriptorBlueZ*>; |
| + DescriptorMap descriptors_; |
| + |
| + private: |
| + friend class BluetoothGattServiceBlueZ; |
| + friend class BluetoothRemoteGattServiceBlueZ; |
|
scheib
2016/04/13 23:06:28
Instead of friending, just make the members protec
rkc
2016/04/14 00:23:48
The classes aren't in this class's hierarchy.
I di
|
| + friend class BluetoothLocalGattServiceBlueZ; |
| + |
| + // Object path of the D-Bus characteristic object. |
| + dbus::ObjectPath object_path_; |
| + |
| + // The GATT service this GATT characteristic belongs to. |
| + BluetoothGattServiceBlueZ* service_; |
| + |
| + // Note: This should remain the last member so it'll be destroyed and |
| + // invalidate its weak pointers before any other members are destroyed. |
| + base::WeakPtrFactory<BluetoothGattCharacteristicBlueZ> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicBlueZ); |
| +}; |
| + |
| +} // namespace bluez |
| + |
| +#endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_CHARACTERISTIC_BLUEZ_H_ |