OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H |
6 #define COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H | 6 #define COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 // This ConnectionFinder implementation is specialized in finding a Bluetooth | 24 // This ConnectionFinder implementation is specialized in finding a Bluetooth |
25 // Low Energy remote device. | 25 // Low Energy remote device. |
26 class BluetoothLowEnergyConnectionFinder | 26 class BluetoothLowEnergyConnectionFinder |
27 : public ConnectionFinder, | 27 : public ConnectionFinder, |
28 public device::BluetoothAdapter::Observer { | 28 public device::BluetoothAdapter::Observer { |
29 public: | 29 public: |
30 BluetoothLowEnergyConnectionFinder(const std::string& remote_service_uuid); | 30 BluetoothLowEnergyConnectionFinder(const std::string& remote_service_uuid); |
31 ~BluetoothLowEnergyConnectionFinder() override; | 31 ~BluetoothLowEnergyConnectionFinder() override; |
32 | 32 |
33 // Finds a connection to the remote device. Only the first one is functional. | 33 // Finds a connection to the remote device. Only the first one is functional. |
34 void Find(const device::BluetoothDevice::GattConnectionCallback& | |
35 connection_callback); | |
36 void Find(const ConnectionCallback& connection_callback) override; | 34 void Find(const ConnectionCallback& connection_callback) override; |
37 | 35 |
38 // Closes the connection and forgets the device. | 36 // Closes the connection and forgets the device. |
39 void CloseConnection(scoped_ptr<device::BluetoothGattConnection> connection); | 37 void CloseConnection(scoped_ptr<device::BluetoothGattConnection> connection); |
40 | 38 |
41 protected: | 39 protected: |
42 // device::BluetoothAdapter::Observer: | 40 // device::BluetoothAdapter::Observer: |
43 void DeviceAdded(device::BluetoothAdapter* adapter, | 41 void DeviceAdded(device::BluetoothAdapter* adapter, |
44 device::BluetoothDevice* device) override; | 42 device::BluetoothDevice* device) override; |
45 void DeviceChanged(device::BluetoothAdapter* adapter, | 43 void DeviceChanged(device::BluetoothAdapter* adapter, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 scoped_refptr<device::BluetoothAdapter> adapter_; | 95 scoped_refptr<device::BluetoothAdapter> adapter_; |
98 | 96 |
99 // The discovery session associated to this object. | 97 // The discovery session associated to this object. |
100 scoped_ptr<device::BluetoothDiscoverySession> discovery_session_; | 98 scoped_ptr<device::BluetoothDiscoverySession> discovery_session_; |
101 | 99 |
102 // True if a connection was established to a remote device that has the | 100 // True if a connection was established to a remote device that has the |
103 // service |remote_service_uuid|. | 101 // service |remote_service_uuid|. |
104 bool connected_; | 102 bool connected_; |
105 | 103 |
106 // Callback called when the connection is established. | 104 // Callback called when the connection is established. |
107 device::BluetoothDevice::GattConnectionCallback connection_callback_; | 105 // device::BluetoothDevice::GattConnectionCallback connection_callback_; |
| 106 ConnectionCallback connection_callback_; |
108 | 107 |
109 // The set of devices this connection finder has tried to connect to. | 108 // The set of devices this connection finder has tried to connect to. |
110 std::set<device::BluetoothDevice*> pending_connections_; | 109 std::set<device::BluetoothDevice*> pending_connections_; |
111 | 110 |
112 base::WeakPtrFactory<BluetoothLowEnergyConnectionFinder> weak_ptr_factory_; | 111 base::WeakPtrFactory<BluetoothLowEnergyConnectionFinder> weak_ptr_factory_; |
113 | 112 |
114 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnectionFinder); | 113 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnectionFinder); |
115 }; | 114 }; |
116 | 115 |
117 } // namespace proximity_auth | 116 } // namespace proximity_auth |
118 | 117 |
119 #endif // COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_CONNECTION_FINDER_H | 118 #endif // COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_CONNECTION_FINDER_H |
OLD | NEW |