OLD | NEW |
1 // Copyright 2016 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_BLUEZ_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ |
6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ | 6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <map> | 10 #include <map> |
11 #include <queue> | 11 #include <queue> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/callback_forward.h" | 16 #include "base/callback_forward.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "dbus/object_path.h" | 19 #include "dbus/object_path.h" |
20 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" | 20 #include "device/bluetooth/bluetooth_gatt_characteristic.h" |
21 #include "device/bluetooth/bluetooth_remote_gatt_service.h" | 21 #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
22 #include "device/bluetooth/bluetooth_uuid.h" | 22 #include "device/bluetooth/bluetooth_uuid.h" |
23 #include "device/bluetooth/bluez/bluetooth_gatt_characteristic_bluez.h" | 23 #include "device/bluetooth/bluez/bluetooth_gatt_characteristic_bluez.h" |
24 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" | 24 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" |
25 | 25 |
26 namespace device { | 26 namespace device { |
27 | 27 |
28 class BluetoothRemoteGattDescriptor; | 28 class BluetoothRemoteGattDescriptor; |
29 class BluetoothRemoteGattService; | 29 class BluetoothRemoteGattService; |
30 | 30 |
(...skipping 21 matching lines...) Expand all Loading... |
52 // device::BluetoothRemoteGattCharacteristic overrides. | 52 // device::BluetoothRemoteGattCharacteristic overrides. |
53 const std::vector<uint8_t>& GetValue() const override; | 53 const std::vector<uint8_t>& GetValue() const override; |
54 device::BluetoothRemoteGattService* GetService() const override; | 54 device::BluetoothRemoteGattService* GetService() const override; |
55 bool IsNotifying() const override; | 55 bool IsNotifying() const override; |
56 std::vector<device::BluetoothRemoteGattDescriptor*> GetDescriptors() | 56 std::vector<device::BluetoothRemoteGattDescriptor*> GetDescriptors() |
57 const override; | 57 const override; |
58 device::BluetoothRemoteGattDescriptor* GetDescriptor( | 58 device::BluetoothRemoteGattDescriptor* GetDescriptor( |
59 const std::string& identifier) const override; | 59 const std::string& identifier) const override; |
60 void StartNotifySession(const NotifySessionCallback& callback, | 60 void StartNotifySession(const NotifySessionCallback& callback, |
61 const ErrorCallback& error_callback) override; | 61 const ErrorCallback& error_callback) override; |
62 // Removes one value update session and invokes |callback| on completion. This | |
63 // decrements the session reference count by 1 and if the number reaches 0, | |
64 // makes a call to the subsystem to stop notifications from this | |
65 // characteristic. | |
66 void StopNotifySession(device::BluetoothGattNotifySession* session, | |
67 const base::Closure& callback) override; | |
68 void ReadRemoteCharacteristic(const ValueCallback& callback, | 62 void ReadRemoteCharacteristic(const ValueCallback& callback, |
69 const ErrorCallback& error_callback) override; | 63 const ErrorCallback& error_callback) override; |
70 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value, | 64 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value, |
71 const base::Closure& callback, | 65 const base::Closure& callback, |
72 const ErrorCallback& error_callback) override; | 66 const ErrorCallback& error_callback) override; |
73 | 67 |
74 protected: | 68 // Removes one value update session and invokes |callback| on completion. This |
75 void SubscribeToNotifications( | 69 // decrements the session reference count by 1 and if the number reaches 0, |
76 device::BluetoothRemoteGattDescriptor* ccc_descriptor, | 70 // makes a call to the subsystem to stop notifications from this |
77 const base::Closure& callback, | 71 // characteristic. |
78 const ErrorCallback& error_callback) override; | 72 void RemoveNotifySession(const base::Closure& callback); |
79 void UnsubscribeFromNotifications( | |
80 device::BluetoothRemoteGattDescriptor* ccc_descriptor, | |
81 const base::Closure& callback, | |
82 const ErrorCallback& error_callback) override; | |
83 | 73 |
84 private: | 74 private: |
85 friend class BluetoothRemoteGattServiceBlueZ; | 75 friend class BluetoothRemoteGattServiceBlueZ; |
86 | 76 |
87 using PendingStartNotifyCall = | 77 using PendingStartNotifyCall = |
88 std::pair<NotifySessionCallback, ErrorCallback>; | 78 std::pair<NotifySessionCallback, ErrorCallback>; |
89 | 79 |
90 BluetoothRemoteGattCharacteristicBlueZ( | 80 BluetoothRemoteGattCharacteristicBlueZ( |
91 BluetoothRemoteGattServiceBlueZ* service, | 81 BluetoothRemoteGattServiceBlueZ* service, |
92 const dbus::ObjectPath& object_path); | 82 const dbus::ObjectPath& object_path); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 // invalidate its weak pointers before any other members are destroyed. | 145 // invalidate its weak pointers before any other members are destroyed. |
156 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicBlueZ> | 146 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicBlueZ> |
157 weak_ptr_factory_; | 147 weak_ptr_factory_; |
158 | 148 |
159 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicBlueZ); | 149 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicBlueZ); |
160 }; | 150 }; |
161 | 151 |
162 } // namespace bluez | 152 } // namespace bluez |
163 | 153 |
164 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ | 154 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ |
OLD | NEW |