| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_BLUEZ_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_GATT_DESCRIPTOR_BLUEZ_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_BLUEZ_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_GATT_DESCRIPTOR_BLUEZ_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "dbus/object_path.h" | 15 #include "dbus/object_path.h" |
| 16 #include "device/bluetooth/bluetooth_gatt_descriptor.h" | 16 #include "device/bluetooth/bluetooth_gatt_descriptor.h" |
| 17 #include "device/bluetooth/bluetooth_uuid.h" | 17 #include "device/bluetooth/bluetooth_uuid.h" |
| 18 | 18 |
| 19 namespace device { | 19 namespace device { |
| 20 | 20 |
| 21 class BluetoothGattCharacteristic; | 21 class BluetoothGattCharacteristic; |
| 22 | 22 |
| 23 } // namespace device | 23 } // namespace device |
| 24 | 24 |
| 25 namespace bluez { | 25 namespace bluez { |
| 26 | 26 |
| 27 class BluetoothRemoteGattCharacteristicBlueZ; | 27 class BluetoothGattCharacteristicBlueZ; |
| 28 | 28 |
| 29 // The BluetoothRemoteGattDescriptorBlueZ class implements | 29 // The BluetoothGattDescriptorBlueZ class implements |
| 30 // BluetoothGattDescriptor for remote GATT characteristic descriptors for | 30 // BluetoothGattDescriptor for remote and local GATT characteristic descriptors |
| 31 // platforms that use BlueZ. | 31 // for platforms that use BlueZ. |
| 32 class BluetoothRemoteGattDescriptorBlueZ | 32 class BluetoothGattDescriptorBlueZ : public device::BluetoothGattDescriptor { |
| 33 : public device::BluetoothGattDescriptor { | |
| 34 public: | 33 public: |
| 35 // device::BluetoothGattDescriptor overrides. | 34 // device::BluetoothGattDescriptor overrides. |
| 36 std::string GetIdentifier() const override; | 35 std::string GetIdentifier() const override; |
| 37 device::BluetoothUUID GetUUID() const override; | 36 device::BluetoothUUID GetUUID() const override; |
| 38 bool IsLocal() const override; | 37 bool IsLocal() const override; |
| 39 const std::vector<uint8_t>& GetValue() const override; | 38 const std::vector<uint8_t>& GetValue() const override; |
| 40 device::BluetoothGattCharacteristic* GetCharacteristic() const override; | 39 device::BluetoothGattCharacteristic* GetCharacteristic() const override; |
| 41 device::BluetoothGattCharacteristic::Permissions GetPermissions() | 40 device::BluetoothGattCharacteristic::Permissions GetPermissions() |
| 42 const override; | 41 const override; |
| 43 void ReadRemoteDescriptor(const ValueCallback& callback, | 42 void ReadRemoteDescriptor(const ValueCallback& callback, |
| 44 const ErrorCallback& error_callback) override; | 43 const ErrorCallback& error_callback) override; |
| 45 void WriteRemoteDescriptor(const std::vector<uint8_t>& new_value, | 44 void WriteRemoteDescriptor(const std::vector<uint8_t>& new_value, |
| 46 const base::Closure& callback, | 45 const base::Closure& callback, |
| 47 const ErrorCallback& error_callback) override; | 46 const ErrorCallback& error_callback) override; |
| 48 | 47 |
| 49 // Object path of the underlying D-Bus characteristic. | 48 // Object path of the underlying D-Bus characteristic. |
| 50 const dbus::ObjectPath& object_path() const { return object_path_; } | 49 const dbus::ObjectPath& object_path() const { return object_path_; } |
| 51 | 50 |
| 52 private: | 51 private: |
| 53 friend class BluetoothRemoteGattCharacteristicBlueZ; | 52 friend class BluetoothRemoteGattCharacteristicBlueZ; |
| 54 | 53 |
| 55 BluetoothRemoteGattDescriptorBlueZ( | 54 BluetoothGattDescriptorBlueZ(BluetoothGattCharacteristicBlueZ* characteristic, |
| 56 BluetoothRemoteGattCharacteristicBlueZ* characteristic, | 55 const dbus::ObjectPath& object_path, |
| 57 const dbus::ObjectPath& object_path); | 56 bool is_local); |
| 58 ~BluetoothRemoteGattDescriptorBlueZ() override; | 57 ~BluetoothGattDescriptorBlueZ() override; |
| 59 | 58 |
| 60 // Called by dbus:: on unsuccessful completion of a request to read or write | 59 // Called by dbus:: on unsuccessful completion of a request to read or write |
| 61 // the descriptor value. | 60 // the descriptor value. |
| 62 void OnError(const ErrorCallback& error_callback, | 61 void OnError(const ErrorCallback& error_callback, |
| 63 const std::string& error_name, | 62 const std::string& error_name, |
| 64 const std::string& error_message); | 63 const std::string& error_message); |
| 65 | 64 |
| 66 // Object path of the D-Bus descriptor object. | 65 // Object path of the D-Bus descriptor object. |
| 67 dbus::ObjectPath object_path_; | 66 dbus::ObjectPath object_path_; |
| 68 | 67 |
| 69 // The GATT characteristic this descriptor belongs to. | 68 // The GATT characteristic this descriptor belongs to. |
| 70 BluetoothRemoteGattCharacteristicBlueZ* characteristic_; | 69 BluetoothGattCharacteristicBlueZ* characteristic_; |
| 70 |
| 71 // Is this a remote or local descriptor. |
| 72 bool is_local_; |
| 71 | 73 |
| 72 // Note: This should remain the last member so it'll be destroyed and | 74 // Note: This should remain the last member so it'll be destroyed and |
| 73 // invalidate its weak pointers before any other members are destroyed. | 75 // invalidate its weak pointers before any other members are destroyed. |
| 74 base::WeakPtrFactory<BluetoothRemoteGattDescriptorBlueZ> weak_ptr_factory_; | 76 base::WeakPtrFactory<BluetoothGattDescriptorBlueZ> weak_ptr_factory_; |
| 75 | 77 |
| 76 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattDescriptorBlueZ); | 78 DISALLOW_COPY_AND_ASSIGN(BluetoothGattDescriptorBlueZ); |
| 77 }; | 79 }; |
| 78 | 80 |
| 79 } // namespace bluez | 81 } // namespace bluez |
| 80 | 82 |
| 81 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_BLUEZ_H_ | 83 #endif // DEVICE_BLUETOOTH_BLUETOOTH_GATT_DESCRIPTOR_BLUEZ_H_ |
| OLD | NEW |