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_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ |
6 #define DEVICE_BLUETOOTH_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 <queue> | 11 #include <queue> |
11 #include <string> | 12 #include <string> |
12 #include <utility> | 13 #include <utility> |
13 #include <vector> | 14 #include <vector> |
14 | 15 |
15 #include "base/callback_forward.h" | 16 #include "base/callback_forward.h" |
16 #include "base/macros.h" | 17 #include "base/macros.h" |
17 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
18 #include "dbus/object_path.h" | 19 #include "dbus/object_path.h" |
19 #include "device/bluetooth/bluetooth_gatt_characteristic.h" | 20 #include "device/bluetooth/bluetooth_gatt_characteristic.h" |
20 #include "device/bluetooth/bluetooth_gatt_characteristic_bluez.h" | 21 #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
21 #include "device/bluetooth/bluetooth_uuid.h" | 22 #include "device/bluetooth/bluetooth_uuid.h" |
23 #include "device/bluetooth/bluez/bluetooth_gatt_characteristic_bluez.h" | |
22 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" | 24 #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_client.h" |
23 | 25 |
24 namespace device { | 26 namespace device { |
25 | 27 |
26 class BluetoothGattDescriptor; | 28 class BluetoothRemoteGattDescriptor; |
27 class BluetoothGattService; | 29 class BluetoothRemoteGattService; |
28 | 30 |
29 } // namespace device | 31 } // namespace device |
30 | 32 |
31 namespace bluez { | 33 namespace bluez { |
32 | 34 |
33 class BluetoothGattDescriptorBlueZ; | 35 class BluetoothRemoteGattDescriptorBlueZ; |
34 class BluetoothRemoteGattServiceBlueZ; | 36 class BluetoothRemoteGattServiceBlueZ; |
35 | 37 |
36 // The BluetoothRemoteGattCharacteristicBlueZ class implements | 38 // The BluetoothRemoteGattCharacteristicBlueZ class implements |
37 // BluetoothGattCharacteristic for remote GATT characteristics for platforms | 39 // BluetoothRemoteGattCharacteristic for remote GATT characteristics for |
40 // platforms | |
38 // that use BlueZ. | 41 // that use BlueZ. |
39 class BluetoothRemoteGattCharacteristicBlueZ | 42 class BluetoothRemoteGattCharacteristicBlueZ |
40 : public BluetoothGattCharacteristicBlueZ, | 43 : public BluetoothGattCharacteristicBlueZ, |
41 public BluetoothGattDescriptorClient::Observer { | 44 public BluetoothGattDescriptorClient::Observer, |
45 public device::BluetoothRemoteGattCharacteristic { | |
42 public: | 46 public: |
43 // device::BluetoothGattCharacteristic overrides. | 47 // device::BluetoothRemoteGattCharacteristic overrides. |
48 device::BluetoothRemoteGattService* GetService() const override; | |
scheib
2016/04/20 01:23:30
Order these to match bluetooth_remote_gatt_charact
rkc
2016/04/20 16:31:54
Done.
| |
49 Permissions GetPermissions() const override; | |
50 std::vector<device::BluetoothRemoteGattDescriptor*> GetDescriptors() | |
51 const override; | |
52 device::BluetoothRemoteGattDescriptor* GetDescriptor( | |
53 const std::string& identifier) const override; | |
44 device::BluetoothUUID GetUUID() const override; | 54 device::BluetoothUUID GetUUID() const override; |
45 bool IsLocal() const override; | |
46 const std::vector<uint8_t>& GetValue() const override; | 55 const std::vector<uint8_t>& GetValue() const override; |
47 Properties GetProperties() const override; | 56 Properties GetProperties() const override; |
48 bool IsNotifying() const override; | 57 bool IsNotifying() const override; |
49 bool AddDescriptor(device::BluetoothGattDescriptor* descriptor) override; | |
50 bool UpdateValue(const std::vector<uint8_t>& value) override; | |
51 void StartNotifySession(const NotifySessionCallback& callback, | 58 void StartNotifySession(const NotifySessionCallback& callback, |
52 const ErrorCallback& error_callback) override; | 59 const ErrorCallback& error_callback) override; |
53 void ReadRemoteCharacteristic(const ValueCallback& callback, | 60 void ReadRemoteCharacteristic(const ValueCallback& callback, |
54 const ErrorCallback& error_callback) override; | 61 const ErrorCallback& error_callback) override; |
55 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value, | 62 void WriteRemoteCharacteristic(const std::vector<uint8_t>& new_value, |
56 const base::Closure& callback, | 63 const base::Closure& callback, |
57 const ErrorCallback& error_callback) override; | 64 const ErrorCallback& error_callback) override; |
58 | 65 |
59 // Removes one value update session and invokes |callback| on completion. This | 66 // Removes one value update session and invokes |callback| on completion. This |
60 // decrements the session reference count by 1 and if the number reaches 0, | 67 // decrements the session reference count by 1 and if the number reaches 0, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 // The total number of currently active value update sessions. | 118 // The total number of currently active value update sessions. |
112 size_t num_notify_sessions_; | 119 size_t num_notify_sessions_; |
113 | 120 |
114 // Calls to StartNotifySession that are pending. This can happen during the | 121 // Calls to StartNotifySession that are pending. This can happen during the |
115 // first remote call to start notifications. | 122 // first remote call to start notifications. |
116 std::queue<PendingStartNotifyCall> pending_start_notify_calls_; | 123 std::queue<PendingStartNotifyCall> pending_start_notify_calls_; |
117 | 124 |
118 // True, if a Start or Stop notify call to bluetoothd is currently pending. | 125 // True, if a Start or Stop notify call to bluetoothd is currently pending. |
119 bool notify_call_pending_; | 126 bool notify_call_pending_; |
120 | 127 |
128 // TODO(rkc): Investigate and fix ownership of the descriptor objects in this | |
129 // map. See crbug.com/604166. | |
130 using DescriptorMap = | |
131 std::map<dbus::ObjectPath, BluetoothRemoteGattDescriptorBlueZ*>; | |
132 | |
133 // Mapping from GATT descriptor object paths to descriptor objects owned by | |
134 // this characteristic. Since the BlueZ implementation uses object paths | |
135 // as unique identifiers, we also use this mapping to return descriptors by | |
136 // identifier. | |
137 DescriptorMap descriptors_; | |
138 | |
139 // The GATT service this GATT characteristic belongs to. | |
140 BluetoothRemoteGattServiceBlueZ* service_; | |
141 | |
121 // Note: This should remain the last member so it'll be destroyed and | 142 // Note: This should remain the last member so it'll be destroyed and |
122 // invalidate its weak pointers before any other members are destroyed. | 143 // invalidate its weak pointers before any other members are destroyed. |
123 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicBlueZ> | 144 base::WeakPtrFactory<BluetoothRemoteGattCharacteristicBlueZ> |
124 weak_ptr_factory_; | 145 weak_ptr_factory_; |
125 | 146 |
126 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicBlueZ); | 147 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristicBlueZ); |
127 }; | 148 }; |
128 | 149 |
129 } // namespace bluez | 150 } // namespace bluez |
130 | 151 |
131 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ | 152 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_BLUEZ_H_ |
OLD | NEW |