OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H | |
6 #define COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/macros.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/memory/weak_ptr.h" | |
15 #include "components/proximity_auth/connection_finder.h" | |
16 #include "device/bluetooth/bluetooth_adapter.h" | |
17 #include "device/bluetooth/bluetooth_device.h" | |
18 #include "device/bluetooth/bluetooth_discovery_session.h" | |
19 #include "device/bluetooth/bluetooth_gatt_connection.h" | |
20 | |
21 namespace proximity_auth { | |
22 | |
23 // This ConnectionFinder implementation tries to find a Bluetooth connection to | |
msarda
2015/04/22 15:58:13
This comment must be explicit about the fact that
sacomoto
2015/04/24 14:04:56
Done.
| |
24 // a remote device. | |
25 class BluetoothLowEnergyConnectionFinder | |
26 : public ConnectionFinder, | |
27 public device::BluetoothAdapter::Observer { | |
28 public: | |
29 BluetoothLowEnergyConnectionFinder(const std::string& remote_service_uuid); | |
30 ~BluetoothLowEnergyConnectionFinder() override; | |
31 | |
32 // Finds a connection the remote device, only the first one is functional. | |
33 void Find(const device::BluetoothDevice::GattConnectionCallback& | |
msarda
2015/04/22 15:58:13
Please add a comment explaining that this method c
msarda
2015/04/22 15:58:13
I somehow feel we need to add an empty implementat
sacomoto
2015/04/24 14:04:56
Yes.
Actually, I think it would be better to hav
sacomoto
2015/04/24 14:04:57
My next CL already implements proximity_auth::Conn
msarda
2015/04/24 14:12:16
Ok.
| |
34 connection_callback); | |
35 void Find(const ConnectionCallback& connection_callback) override; | |
36 | |
37 protected: | |
38 // Observer for device::BluetoothAdapter::Observer | |
39 void DeviceAdded(device::BluetoothAdapter* adapter, | |
40 device::BluetoothDevice* device) override; | |
41 | |
42 private: | |
43 // Callback to be called when the Bluetooth adapter is initialized. | |
44 void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); | |
msarda
2015/04/22 15:58:13
Why is this private and DeviceAdded is protected?
sacomoto
2015/04/24 14:04:57
DeviceAdded is part of the BluetoothAdapter::Obser
| |
45 | |
46 // Callback to be called when a new discovery session is started. | |
47 void OnDiscoverySessionStarted( | |
48 scoped_ptr<device::BluetoothDiscoverySession> discovery_session); | |
49 | |
50 // Starts a discovery session for |adapter_|. | |
51 void StartDiscoverySession(); | |
52 | |
53 // Stops the discovery session given by |discovery_session_|. | |
54 void StopDiscoverySession(); | |
55 | |
56 // Checks if a service with |service_uuid| is offered by |remote_device|. | |
57 bool HasService(device::BluetoothDevice* remote_device); | |
58 | |
59 // Creates a connection with |remote_device|, the |connection_callback_| will | |
msarda
2015/04/22 15:58:13
s/a connection/a GATT connection
s/, the |coonnect
sacomoto
2015/04/24 14:04:57
Done.
| |
60 // be called once the connection is established. | |
61 void CreateConnection(device::BluetoothDevice* remote_device); | |
62 | |
63 // The uuid of the service it looks for to establish a GattConnection. | |
64 device::BluetoothUUID remote_service_uuid_; | |
65 | |
66 // The Bluetooth adapter over which the Bluetooth connection will be made. | |
67 scoped_refptr<device::BluetoothAdapter> adapter_; | |
68 | |
69 // The discovery session associated to this object. | |
70 scoped_ptr<device::BluetoothDiscoverySession> discovery_session_; | |
71 | |
72 // Callback called when the connection is established. | |
73 device::BluetoothDevice::GattConnectionCallback connection_callback_; | |
74 | |
75 base::WeakPtrFactory<BluetoothLowEnergyConnectionFinder> weak_ptr_factory_; | |
76 | |
77 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnectionFinder); | |
78 }; | |
79 | |
80 } // namespace proximity_auth | |
81 | |
82 #endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_FINDER_H | |
OLD | NEW |