Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: device/bluetooth/bluez/bluetooth_device_bluez.h

Issue 2105423003: bluetooth: Update the map of GATT services when services resolve (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Address Luiz's and scheib's comments Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_DEVICE_BLUEZ_H_ 5 #ifndef DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_DEVICE_BLUEZ_H_
6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_DEVICE_BLUEZ_H_ 6 #define DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_DEVICE_BLUEZ_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/sequenced_task_runner.h" 16 #include "base/sequenced_task_runner.h"
17 #include "dbus/object_path.h" 17 #include "dbus/object_path.h"
18 #include "device/bluetooth/bluetooth_common.h" 18 #include "device/bluetooth/bluetooth_common.h"
19 #include "device/bluetooth/bluetooth_device.h" 19 #include "device/bluetooth/bluetooth_device.h"
20 #include "device/bluetooth/bluetooth_export.h" 20 #include "device/bluetooth/bluetooth_export.h"
21 #include "device/bluetooth/dbus/bluetooth_device_client.h"
22 #include "device/bluetooth/dbus/bluetooth_gatt_service_client.h" 21 #include "device/bluetooth/dbus/bluetooth_gatt_service_client.h"
23 22
24 namespace device { 23 namespace device {
25 class BluetoothSocketThread; 24 class BluetoothSocketThread;
26 } // namespace device 25 } // namespace device
27 26
28 namespace bluez { 27 namespace bluez {
29 28
30 class BluetoothAdapterBlueZ; 29 class BluetoothAdapterBlueZ;
31 class BluetoothPairingBlueZ; 30 class BluetoothPairingBlueZ;
32 class BluetoothServiceRecordBlueZ; 31 class BluetoothServiceRecordBlueZ;
33 32
34 // The BluetoothDeviceBlueZ class implements BluetoothDevice for platforms using 33 // The BluetoothDeviceBlueZ class implements BluetoothDevice for platforms using
35 // BlueZ. 34 // BlueZ.
36 // 35 //
37 // This class is not thread-safe, but is only called from the UI thread. 36 // This class is not thread-safe, but is only called from the UI thread.
38 // 37 //
39 // A socket thread is used to create sockets but posts all callbacks on the UI 38 // A socket thread is used to create sockets but posts all callbacks on the UI
40 // thread. 39 // thread.
41 class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceBlueZ 40 class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceBlueZ
42 : public device::BluetoothDevice, 41 : public device::BluetoothDevice,
43 public bluez::BluetoothDeviceClient::Observer,
44 public bluez::BluetoothGattServiceClient::Observer { 42 public bluez::BluetoothGattServiceClient::Observer {
45 public: 43 public:
46 // BluetoothDevice override 44 // BluetoothDevice override
47 uint32_t GetBluetoothClass() const override; 45 uint32_t GetBluetoothClass() const override;
48 device::BluetoothTransport GetType() const override; 46 device::BluetoothTransport GetType() const override;
49 std::string GetAddress() const override; 47 std::string GetAddress() const override;
50 VendorIDSource GetVendorIDSource() const override; 48 VendorIDSource GetVendorIDSource() const override;
51 uint16_t GetVendorID() const override; 49 uint16_t GetVendorID() const override;
52 uint16_t GetProductID() const override; 50 uint16_t GetProductID() const override;
53 uint16_t GetDeviceID() const override; 51 uint16_t GetDeviceID() const override;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 private: 124 private:
127 friend class BluetoothAdapterBlueZ; 125 friend class BluetoothAdapterBlueZ;
128 126
129 BluetoothDeviceBlueZ( 127 BluetoothDeviceBlueZ(
130 BluetoothAdapterBlueZ* adapter, 128 BluetoothAdapterBlueZ* adapter,
131 const dbus::ObjectPath& object_path, 129 const dbus::ObjectPath& object_path,
132 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, 130 scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
133 scoped_refptr<device::BluetoothSocketThread> socket_thread); 131 scoped_refptr<device::BluetoothSocketThread> socket_thread);
134 ~BluetoothDeviceBlueZ() override; 132 ~BluetoothDeviceBlueZ() override;
135 133
136 // bluez::BluetoothDeviceClient::Observer overrides
137 void DevicePropertyChanged(const dbus::ObjectPath& object_path,
138 const std::string& property_name) override;
139
140 // bluez::BluetoothGattServiceClient::Observer overrides 134 // bluez::BluetoothGattServiceClient::Observer overrides
141 void GattServiceAdded(const dbus::ObjectPath& object_path) override; 135 void GattServiceAdded(const dbus::ObjectPath& object_path) override;
142 void GattServiceRemoved(const dbus::ObjectPath& object_path) override; 136 void GattServiceRemoved(const dbus::ObjectPath& object_path) override;
143 137
144 // Called by the constructor to initialize the map of GATT services associated 138 // Called by the constructor to initialize the map of GATT services associated
145 // with this device and to invoke NotifyGattDiscoveryComplete() with each 139 // with this device and to invoke NotifyGattDiscoveryComplete() with each
146 // cached service. 140 // cached service.
147 void InitializeGattServiceMap(); 141 void InitializeGattServicesMap();
142
143 // Called once all services have been discovered. Invokes
144 // NotifyGattDiscoveryComplete() for services for which we haven't notified
145 // before e.g. if a services is exposed during construction but services
146 // haven't been resolved yet..
147 void UpdateGattServices(const dbus::ObjectPath& object_path);
vudentz 2016/07/04 11:04:03 Looks like I missed the introduction of this metho
ortuno 2016/07/06 21:31:46 Good catch. Done.
148 148
149 // Called by dbus:: on completion of the D-Bus method call to get the 149 // Called by dbus:: on completion of the D-Bus method call to get the
150 // connection attributes of the current connection to the device. 150 // connection attributes of the current connection to the device.
151 void OnGetConnInfo(const ConnectionInfoCallback& callback, 151 void OnGetConnInfo(const ConnectionInfoCallback& callback,
152 int16_t rssi, 152 int16_t rssi,
153 int16_t transmit_power, 153 int16_t transmit_power,
154 int16_t max_transmit_power); 154 int16_t max_transmit_power);
155 void OnGetConnInfoError(const ConnectionInfoCallback& callback, 155 void OnGetConnInfoError(const ConnectionInfoCallback& callback,
156 const std::string& error_name, 156 const std::string& error_name,
157 const std::string& error_message); 157 const std::string& error_message);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // The dbus object path of the device object. 213 // The dbus object path of the device object.
214 dbus::ObjectPath object_path_; 214 dbus::ObjectPath object_path_;
215 215
216 // Number of ongoing calls to Connect(). 216 // Number of ongoing calls to Connect().
217 int num_connecting_calls_; 217 int num_connecting_calls_;
218 218
219 // True if the connection monitor has been started, tracking the connection 219 // True if the connection monitor has been started, tracking the connection
220 // RSSI and TX power. 220 // RSSI and TX power.
221 bool connection_monitor_started_; 221 bool connection_monitor_started_;
222 222
223 // Keeps track of all services for which we've called
224 // NotifyGattDiscoveryComplete().
225 std::unordered_set<device::BluetoothRemoteGattService*>
226 discovery_complete_notified_;
227
223 // UI thread task runner and socket thread object used to create sockets. 228 // UI thread task runner and socket thread object used to create sockets.
224 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; 229 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_;
225 scoped_refptr<device::BluetoothSocketThread> socket_thread_; 230 scoped_refptr<device::BluetoothSocketThread> socket_thread_;
226 231
227 // This vector temporarily caches the newly added services for later
228 // notification of discovery complete. Once DevicePropertyChange is invoked
229 // with a toggle of ServicesResolved property, the
230 // NotifyGattDiscoveryComplete() will be called with each service once.
231 std::vector<device::BluetoothRemoteGattService*>
232 newly_discovered_gatt_services_;
233 232
234 // During pairing this is set to an object that we don't own, but on which 233 // During pairing this is set to an object that we don't own, but on which
235 // we can make method calls to request, display or confirm PIN Codes and 234 // we can make method calls to request, display or confirm PIN Codes and
236 // Passkeys. Generally it is the object that owns this one. 235 // Passkeys. Generally it is the object that owns this one.
237 std::unique_ptr<BluetoothPairingBlueZ> pairing_; 236 std::unique_ptr<BluetoothPairingBlueZ> pairing_;
238 237
239 // Note: This should remain the last member so it'll be destroyed and 238 // Note: This should remain the last member so it'll be destroyed and
240 // invalidate its weak pointers before any other members are destroyed. 239 // invalidate its weak pointers before any other members are destroyed.
241 base::WeakPtrFactory<BluetoothDeviceBlueZ> weak_ptr_factory_; 240 base::WeakPtrFactory<BluetoothDeviceBlueZ> weak_ptr_factory_;
242 241
243 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceBlueZ); 242 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceBlueZ);
244 }; 243 };
245 244
246 } // namespace bluez 245 } // namespace bluez
247 246
248 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_DEVICE_BLUEZ_H_ 247 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_DEVICE_BLUEZ_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluez/bluetooth_adapter_bluez.cc ('k') | device/bluetooth/bluez/bluetooth_device_bluez.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698