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