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

Side by Side Diff: components/proximity_auth/ble/bluetooth_low_energy_connection_finder.h

Issue 1094273003: Implementing a BLE connection finder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
(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
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 08:55:15 Why this method? I think we should only have a sin
sacomoto 2015/04/22 09:44:19 I agree. This is a temporary solution while BLE co
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);
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 |adaptor_|.
msarda 2015/04/22 08:55:15 s/adaptor_/adapter_
sacomoto 2015/04/22 09:44:19 Done.
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698