Chromium Code Reviews| Index: device/bluetooth/bluetooth_gatt_service_bluez.h |
| diff --git a/device/bluetooth/bluetooth_gatt_service_bluez.h b/device/bluetooth/bluetooth_gatt_service_bluez.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bd5f2268d8792107244a7a41f0778f1fdce75c20 |
| --- /dev/null |
| +++ b/device/bluetooth/bluetooth_gatt_service_bluez.h |
| @@ -0,0 +1,82 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
|
ortuno
2016/04/14 17:42:35
It's 2016!
rkc
2016/04/14 19:27:27
It sure is.
|
| +// 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_SERVICE_BLUEZ_H_ |
| +#define DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_BLUEZ_H_ |
| + |
| +#include <stdint.h> |
|
ortuno
2016/04/14 17:42:35
Not necessary.
rkc
2016/04/14 19:27:27
Done.
|
| + |
| +#include <map> |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "dbus/object_path.h" |
| +#include "device/bluetooth/bluetooth_gatt_service.h" |
| + |
| +namespace device { |
| + |
| +class BluetoothGattCharacteristic; |
| + |
| +} // namespace device |
| + |
| +namespace bluez { |
| + |
| +class BluetoothAdapterBlueZ; |
| +class BluetoothDeviceBlueZ; |
| +class BluetoothGattCharacteristicBlueZ; |
| + |
| +// The BluetoothGattServiceBlueZ class implements BluetootGattService |
| +// for GATT services on platforms that use BlueZ. |
|
ortuno
2016/04/14 17:42:35
Please mention that this class implements methods
rkc
2016/04/14 19:27:27
Please see my comment elsewhere regarding this.
|
| +class BluetoothGattServiceBlueZ : public device::BluetoothGattService { |
| + public: |
| + // device::BluetoothGattService overrides. |
| + std::string GetIdentifier() const override; |
| + std::vector<device::BluetoothGattCharacteristic*> GetCharacteristics() |
| + const override; |
| + std::vector<device::BluetoothGattService*> GetIncludedServices() |
| + const override; |
| + device::BluetoothGattCharacteristic* GetCharacteristic( |
| + const std::string& identifier) const override; |
| + |
| + // Object path of the underlying service. |
| + const dbus::ObjectPath& object_path() const { return object_path_; } |
|
ortuno
2016/04/14 17:42:35
hmm there are a lot of variables called "object_pa
rkc
2016/04/14 19:27:27
Please see my other comments about this being a re
|
| + |
| + // Parses a named D-Bus error into a service error code. |
| + static device::BluetoothGattService::GattErrorCode DBusErrorToServiceError( |
| + const std::string error_name); |
| + |
| + // Returns the adapter associated with this service. |
| + BluetoothAdapterBlueZ* GetAdapter() const; |
| + |
| + protected: |
| + BluetoothGattServiceBlueZ(BluetoothAdapterBlueZ* adapter, |
| + const dbus::ObjectPath& object_path); |
| + ~BluetoothGattServiceBlueZ() override; |
| + |
| + using CharacteristicMap = |
| + std::map<dbus::ObjectPath, BluetoothGattCharacteristicBlueZ*>; |
|
ortuno
2016/04/14 17:42:35
optional: Consider using unique_ptrs. If not then
rkc
2016/04/14 19:27:27
Please see my other comments about this being a re
ortuno
2016/04/14 21:17:38
I still think you need to document that classes th
rkc
2016/04/14 21:59:38
Done.
|
| + |
| + // Mapping from GATT characteristic object paths to characteristic objects. |
| + // owned by this service. Since the BlueZ implementation uses object |
| + // paths as unique identifiers, we also use this mapping to return |
| + // characteristics by identifier. |
| + CharacteristicMap characteristics_; |
| + |
| + private: |
| + friend class BluetoothDeviceBlueZ; |
| + |
| + // The adapter associated with this service. It's ok to store a raw pointer |
| + // here since |adapter_| indirectly owns this instance. |
| + BluetoothAdapterBlueZ* adapter_; |
| + |
| + // Object path of the GATT service. |
| + dbus::ObjectPath object_path_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(BluetoothGattServiceBlueZ); |
| +}; |
| + |
| +} // namespace bluez |
| + |
| +#endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_BLUEZ_H_ |