| 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_SERVICE_BLUEZ_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_BLUEZ_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "dbus/object_path.h" |
| 14 #include "device/bluetooth/bluetooth_gatt_service.h" |
| 15 |
| 16 namespace device { |
| 17 |
| 18 class BluetoothGattCharacteristic; |
| 19 |
| 20 } // namespace device |
| 21 |
| 22 namespace bluez { |
| 23 |
| 24 class BluetoothAdapterBlueZ; |
| 25 class BluetoothDeviceBlueZ; |
| 26 class BluetoothGattCharacteristicBlueZ; |
| 27 |
| 28 // The BluetoothGattServiceBlueZ class implements BluetootGattService |
| 29 // for GATT services on platforms that use BlueZ. |
| 30 class BluetoothGattServiceBlueZ : public device::BluetoothGattService { |
| 31 public: |
| 32 // device::BluetoothGattService overrides. |
| 33 std::string GetIdentifier() const override; |
| 34 std::vector<device::BluetoothGattCharacteristic*> GetCharacteristics() |
| 35 const override; |
| 36 std::vector<device::BluetoothGattService*> GetIncludedServices() |
| 37 const override; |
| 38 device::BluetoothGattCharacteristic* GetCharacteristic( |
| 39 const std::string& identifier) const override; |
| 40 |
| 41 // Object path of the underlying service. |
| 42 const dbus::ObjectPath& object_path() const { return object_path_; } |
| 43 |
| 44 // Parses a named D-Bus error into a service error code. |
| 45 static device::BluetoothGattService::GattErrorCode DBusErrorToServiceError( |
| 46 const std::string error_name); |
| 47 |
| 48 // Returns the adapter associated with this service. |
| 49 BluetoothAdapterBlueZ* GetAdapter() const; |
| 50 |
| 51 protected: |
| 52 BluetoothGattServiceBlueZ(BluetoothAdapterBlueZ* adapter, |
| 53 const dbus::ObjectPath& object_path); |
| 54 ~BluetoothGattServiceBlueZ() override; |
| 55 |
| 56 // Does not take ownership of the characteristic object. |
| 57 using CharacteristicMap = |
| 58 std::map<dbus::ObjectPath, BluetoothGattCharacteristicBlueZ*>; |
| 59 |
| 60 // Mapping from GATT characteristic object paths to characteristic objects. |
| 61 // owned by this service. Since the BlueZ implementation uses object |
| 62 // paths as unique identifiers, we also use this mapping to return |
| 63 // characteristics by identifier. |
| 64 CharacteristicMap characteristics_; |
| 65 |
| 66 private: |
| 67 friend class BluetoothDeviceBlueZ; |
| 68 |
| 69 // The adapter associated with this service. It's ok to store a raw pointer |
| 70 // here since |adapter_| indirectly owns this instance. |
| 71 BluetoothAdapterBlueZ* adapter_; |
| 72 |
| 73 // Object path of the GATT service. |
| 74 dbus::ObjectPath object_path_; |
| 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(BluetoothGattServiceBlueZ); |
| 77 }; |
| 78 |
| 79 } // namespace bluez |
| 80 |
| 81 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_SERVICE_BLUEZ_H_ |
| OLD | NEW |