| OLD | NEW |
| 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> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 // The BluetoothDeviceBlueZ class implements BluetoothDevice for platforms using | 32 // The BluetoothDeviceBlueZ class implements BluetoothDevice for platforms using |
| 33 // BlueZ. | 33 // BlueZ. |
| 34 // | 34 // |
| 35 // This class is not thread-safe, but is only called from the UI thread. | 35 // This class is not thread-safe, but is only called from the UI thread. |
| 36 // | 36 // |
| 37 // A socket thread is used to create sockets but posts all callbacks on the UI | 37 // A socket thread is used to create sockets but posts all callbacks on the UI |
| 38 // thread. | 38 // thread. |
| 39 class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceBlueZ | 39 class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceBlueZ |
| 40 : public device::BluetoothDevice, | 40 : public device::BluetoothDevice, |
| 41 public bluez::BluetoothDeviceClient::Observer, |
| 41 public bluez::BluetoothGattServiceClient::Observer { | 42 public bluez::BluetoothGattServiceClient::Observer { |
| 42 public: | 43 public: |
| 43 // BluetoothDevice override | 44 // BluetoothDevice override |
| 44 uint32_t GetBluetoothClass() const override; | 45 uint32_t GetBluetoothClass() const override; |
| 45 std::string GetAddress() const override; | 46 std::string GetAddress() const override; |
| 46 VendorIDSource GetVendorIDSource() const override; | 47 VendorIDSource GetVendorIDSource() const override; |
| 47 uint16_t GetVendorID() const override; | 48 uint16_t GetVendorID() const override; |
| 48 uint16_t GetProductID() const override; | 49 uint16_t GetProductID() const override; |
| 49 uint16_t GetDeviceID() const override; | 50 uint16_t GetDeviceID() const override; |
| 50 uint16_t GetAppearance() const override; | 51 uint16_t GetAppearance() const override; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 private: | 118 private: |
| 118 friend class BluetoothAdapterBlueZ; | 119 friend class BluetoothAdapterBlueZ; |
| 119 | 120 |
| 120 BluetoothDeviceBlueZ( | 121 BluetoothDeviceBlueZ( |
| 121 BluetoothAdapterBlueZ* adapter, | 122 BluetoothAdapterBlueZ* adapter, |
| 122 const dbus::ObjectPath& object_path, | 123 const dbus::ObjectPath& object_path, |
| 123 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, | 124 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, |
| 124 scoped_refptr<device::BluetoothSocketThread> socket_thread); | 125 scoped_refptr<device::BluetoothSocketThread> socket_thread); |
| 125 ~BluetoothDeviceBlueZ() override; | 126 ~BluetoothDeviceBlueZ() override; |
| 126 | 127 |
| 127 // bluez::BluetoothGattServiceClient::Observer overrides. | 128 // bluez::BluetoothDeviceClient::Observer overrides |
| 129 void DevicePropertyChanged(const dbus::ObjectPath& object_path, |
| 130 const std::string& property_name) override; |
| 131 |
| 132 // bluez::BluetoothGattServiceClient::Observer overrides |
| 128 void GattServiceAdded(const dbus::ObjectPath& object_path) override; | 133 void GattServiceAdded(const dbus::ObjectPath& object_path) override; |
| 129 void GattServiceRemoved(const dbus::ObjectPath& object_path) override; | 134 void GattServiceRemoved(const dbus::ObjectPath& object_path) override; |
| 130 | 135 |
| 136 // Called by the constructor to initialize the map of GATT services associated |
| 137 // with this device and to invoke NotifyGattDiscoveryComplete() with each |
| 138 // cached service. |
| 139 void InitializeGattServiceMap(); |
| 140 |
| 131 // Called by dbus:: on completion of the D-Bus method call to get the | 141 // Called by dbus:: on completion of the D-Bus method call to get the |
| 132 // connection attributes of the current connection to the device. | 142 // connection attributes of the current connection to the device. |
| 133 void OnGetConnInfo(const ConnectionInfoCallback& callback, | 143 void OnGetConnInfo(const ConnectionInfoCallback& callback, |
| 134 int16_t rssi, | 144 int16_t rssi, |
| 135 int16_t transmit_power, | 145 int16_t transmit_power, |
| 136 int16_t max_transmit_power); | 146 int16_t max_transmit_power); |
| 137 void OnGetConnInfoError(const ConnectionInfoCallback& callback, | 147 void OnGetConnInfoError(const ConnectionInfoCallback& callback, |
| 138 const std::string& error_name, | 148 const std::string& error_name, |
| 139 const std::string& error_message); | 149 const std::string& error_message); |
| 140 | 150 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 int num_connecting_calls_; | 209 int num_connecting_calls_; |
| 200 | 210 |
| 201 // True if the connection monitor has been started, tracking the connection | 211 // True if the connection monitor has been started, tracking the connection |
| 202 // RSSI and TX power. | 212 // RSSI and TX power. |
| 203 bool connection_monitor_started_; | 213 bool connection_monitor_started_; |
| 204 | 214 |
| 205 // UI thread task runner and socket thread object used to create sockets. | 215 // UI thread task runner and socket thread object used to create sockets. |
| 206 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | 216 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
| 207 scoped_refptr<device::BluetoothSocketThread> socket_thread_; | 217 scoped_refptr<device::BluetoothSocketThread> socket_thread_; |
| 208 | 218 |
| 219 // This vector temporarily caches the newly added services for later |
| 220 // notification of discovery complete. Once DevicePropertyChange is invoked |
| 221 // with a toggle of ServicesResolved property, the |
| 222 // NotifyGattDiscoveryComplete() will be called with each service once. |
| 223 std::vector<device::BluetoothRemoteGattService*> |
| 224 newly_discovered_gatt_services_; |
| 225 |
| 209 // During pairing this is set to an object that we don't own, but on which | 226 // During pairing this is set to an object that we don't own, but on which |
| 210 // we can make method calls to request, display or confirm PIN Codes and | 227 // we can make method calls to request, display or confirm PIN Codes and |
| 211 // Passkeys. Generally it is the object that owns this one. | 228 // Passkeys. Generally it is the object that owns this one. |
| 212 std::unique_ptr<BluetoothPairingBlueZ> pairing_; | 229 std::unique_ptr<BluetoothPairingBlueZ> pairing_; |
| 213 | 230 |
| 214 // Note: This should remain the last member so it'll be destroyed and | 231 // Note: This should remain the last member so it'll be destroyed and |
| 215 // invalidate its weak pointers before any other members are destroyed. | 232 // invalidate its weak pointers before any other members are destroyed. |
| 216 base::WeakPtrFactory<BluetoothDeviceBlueZ> weak_ptr_factory_; | 233 base::WeakPtrFactory<BluetoothDeviceBlueZ> weak_ptr_factory_; |
| 217 | 234 |
| 218 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceBlueZ); | 235 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceBlueZ); |
| 219 }; | 236 }; |
| 220 | 237 |
| 221 } // namespace bluez | 238 } // namespace bluez |
| 222 | 239 |
| 223 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_DEVICE_BLUEZ_H_ | 240 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_DEVICE_BLUEZ_H_ |
| OLD | NEW |