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