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_BLUEZ_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_BLUEZ_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_BLUEZ_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/callback_forward.h" |
| 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 15 #include "dbus/object_path.h" |
| 16 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
| 17 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h" |
| 18 #include "device/bluetooth/bluetooth_uuid.h" |
| 19 #include "device/bluetooth/bluez/bluetooth_gatt_descriptor_bluez.h" |
| 20 #include "device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.h" |
| 21 |
| 22 namespace bluez { |
| 23 |
| 24 // The BluetoothGattDescriptorBlueZ class implements |
| 25 // BluetoothRemoteGattDescriptor for remote GATT characteristic descriptors for |
| 26 // platforms that use BlueZ. |
| 27 class BluetoothRemoteGattDescriptorBlueZ |
| 28 : public BluetoothGattDescriptorBlueZ, |
| 29 public device::BluetoothRemoteGattDescriptor { |
| 30 public: |
| 31 // device::BluetoothRemoteGattDescriptor overrides. |
| 32 device::BluetoothUUID GetUUID() const override; |
| 33 const std::vector<uint8_t>& GetValue() const override; |
| 34 device::BluetoothRemoteGattCharacteristic* GetCharacteristic() const override; |
| 35 device::BluetoothRemoteGattCharacteristic::Permissions GetPermissions() |
| 36 const override; |
| 37 void ReadRemoteDescriptor(const ValueCallback& callback, |
| 38 const ErrorCallback& error_callback) override; |
| 39 void WriteRemoteDescriptor(const std::vector<uint8_t>& new_value, |
| 40 const base::Closure& callback, |
| 41 const ErrorCallback& error_callback) override; |
| 42 |
| 43 private: |
| 44 friend class BluetoothRemoteGattCharacteristicBlueZ; |
| 45 |
| 46 BluetoothRemoteGattDescriptorBlueZ( |
| 47 BluetoothRemoteGattCharacteristicBlueZ* characteristic, |
| 48 const dbus::ObjectPath& object_path); |
| 49 ~BluetoothRemoteGattDescriptorBlueZ() override; |
| 50 |
| 51 // Called by dbus:: on unsuccessful completion of a request to read or write |
| 52 // the descriptor value. |
| 53 void OnError(const ErrorCallback& error_callback, |
| 54 const std::string& error_name, |
| 55 const std::string& error_message); |
| 56 |
| 57 // The GATT characteristic this descriptor belongs to. |
| 58 BluetoothRemoteGattCharacteristicBlueZ* characteristic_; |
| 59 |
| 60 // Note: This should remain the last member so it'll be destroyed and |
| 61 // invalidate its weak pointers before any other members are destroyed. |
| 62 base::WeakPtrFactory<BluetoothRemoteGattDescriptorBlueZ> weak_ptr_factory_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattDescriptorBlueZ); |
| 65 }; |
| 66 |
| 67 } // namespace bluez |
| 68 |
| 69 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_BLUEZ_H_ |
OLD | NEW |