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..3401421131a319df98246eeeeb68c57994244c9c |
| --- /dev/null |
| +++ b/device/bluetooth/bluetooth_gatt_characteristic_bluez.h |
| @@ -0,0 +1,83 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
|
ortuno
2016/04/14 17:42:34
It's 2016!
rkc
2016/04/14 19:27:26
Done.
|
| +// 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> |
|
ortuno
2016/04/14 17:42:34
Don't see any NULLs or size_ts.
rkc
2016/04/14 19:27:26
Done.
|
| +#include <stdint.h> |
|
ortuno
2016/04/14 17:42:35
Same here no ints.
rkc
2016/04/14 19:27:26
Done.
|
| + |
| +#include <map> |
|
ortuno
2016/04/14 17:42:34
Some of these are no longer needed as well. Please
rkc
2016/04/14 19:27:26
Done.
|
| +#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" |
|
ortuno
2016/04/14 17:42:34
No UUIDs.
rkc
2016/04/14 19:27:26
Done.
|
| + |
| +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. |
|
ortuno
2016/04/14 17:42:35
Could you mention that this class implements commo
rkc
2016/04/14 19:27:26
Seems like a superfluous comment. To implement com
|
| +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*>; |
|
ortuno
2016/04/14 17:42:34
optional: Any reason why you leave the deletion of
rkc
2016/04/14 19:27:26
This is a refactor. The purpose is to try to move
ortuno
2016/04/14 21:17:38
OK. I still think a comment that points out that i
rkc
2016/04/14 21:59:38
Done.
|
| + DescriptorMap descriptors_; |
| + |
| + // The GATT service this GATT characteristic belongs to. |
|
ortuno
2016/04/14 17:42:34
nit: The GATT service that owns this characteristi
rkc
2016/04/14 19:27:26
Done.
|
| + BluetoothGattServiceBlueZ* service_; |
| + |
| + private: |
| + friend class BluetoothRemoteGattServiceBlueZ; |
| + |
| + // Object path of the D-Bus characteristic object. |
| + dbus::ObjectPath object_path_; |
| + |
| + // 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_; |
|
ortuno
2016/04/14 17:42:34
Do you still need this for the general implementat
rkc
2016/04/14 19:27:27
I do not, thanks for catching this.
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicBlueZ); |
| +}; |
| + |
| +} // namespace bluez |
| + |
| +#endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_CHARACTERISTIC_BLUEZ_H_ |