Chromium Code Reviews| 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 conditionally by the constructor and |DevicePropertyChanged()| to | |
|
scheib
2016/05/16 20:22:26
Currently this is only called by constructor. See
Miao
2016/05/17 18:08:27
Done.
| |
| 137 // initialize the map of GATT services associated with this device. | |
| 138 void InitializeGattServiceMap(); | |
| 139 | |
| 131 // Called by dbus:: on completion of the D-Bus method call to get the | 140 // Called by dbus:: on completion of the D-Bus method call to get the |
| 132 // connection attributes of the current connection to the device. | 141 // connection attributes of the current connection to the device. |
| 133 void OnGetConnInfo(const ConnectionInfoCallback& callback, | 142 void OnGetConnInfo(const ConnectionInfoCallback& callback, |
| 134 int16_t rssi, | 143 int16_t rssi, |
| 135 int16_t transmit_power, | 144 int16_t transmit_power, |
| 136 int16_t max_transmit_power); | 145 int16_t max_transmit_power); |
| 137 void OnGetConnInfoError(const ConnectionInfoCallback& callback, | 146 void OnGetConnInfoError(const ConnectionInfoCallback& callback, |
| 138 const std::string& error_name, | 147 const std::string& error_name, |
| 139 const std::string& error_message); | 148 const std::string& error_message); |
| 140 | 149 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 int num_connecting_calls_; | 208 int num_connecting_calls_; |
| 200 | 209 |
| 201 // True if the connection monitor has been started, tracking the connection | 210 // True if the connection monitor has been started, tracking the connection |
| 202 // RSSI and TX power. | 211 // RSSI and TX power. |
| 203 bool connection_monitor_started_; | 212 bool connection_monitor_started_; |
| 204 | 213 |
| 205 // UI thread task runner and socket thread object used to create sockets. | 214 // UI thread task runner and socket thread object used to create sockets. |
| 206 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; | 215 scoped_refptr<base::SequencedTaskRunner> ui_task_runner_; |
| 207 scoped_refptr<device::BluetoothSocketThread> socket_thread_; | 216 scoped_refptr<device::BluetoothSocketThread> socket_thread_; |
| 208 | 217 |
| 218 // This vector temporarily cached the newly added services until | |
|
rkc
2016/05/16 16:25:23
nit: s/cached/caches
Miao
2016/05/17 00:22:47
Done.
| |
| 219 // ServicesResolved property becomes true. | |
| 220 std::vector<device::BluetoothRemoteGattService*> | |
| 221 newly_discovered_gatt_services_; | |
| 222 | |
| 209 // During pairing this is set to an object that we don't own, but on which | 223 // 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 | 224 // we can make method calls to request, display or confirm PIN Codes and |
| 211 // Passkeys. Generally it is the object that owns this one. | 225 // Passkeys. Generally it is the object that owns this one. |
| 212 std::unique_ptr<BluetoothPairingBlueZ> pairing_; | 226 std::unique_ptr<BluetoothPairingBlueZ> pairing_; |
| 213 | 227 |
| 214 // Note: This should remain the last member so it'll be destroyed and | 228 // Note: This should remain the last member so it'll be destroyed and |
| 215 // invalidate its weak pointers before any other members are destroyed. | 229 // invalidate its weak pointers before any other members are destroyed. |
| 216 base::WeakPtrFactory<BluetoothDeviceBlueZ> weak_ptr_factory_; | 230 base::WeakPtrFactory<BluetoothDeviceBlueZ> weak_ptr_factory_; |
| 217 | 231 |
| 218 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceBlueZ); | 232 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceBlueZ); |
| 219 }; | 233 }; |
| 220 | 234 |
| 221 } // namespace bluez | 235 } // namespace bluez |
| 222 | 236 |
| 223 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_DEVICE_BLUEZ_H_ | 237 #endif // DEVICE_BLUETOOTH_BLUEZ_BLUETOOTH_DEVICE_BLUEZ_H_ |
| OLD | NEW |