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

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

Issue 2859053003: [EasyUnlock] Add beacon_seeds to RemoteDevice. (Closed)
Patch Set: [EasyUnlock] Add beacon_seeds to RemoteDevice. Created 3 years, 7 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
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_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H 5 #ifndef COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H
6 #define COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H 6 #define COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H
7 7
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 20 matching lines...) Expand all
31 // Bluetooth Low Energy remote device. We look for remote devices advertising 31 // Bluetooth Low Energy remote device. We look for remote devices advertising
32 // the expected EID for the current or nearby time intervals. 32 // the expected EID for the current or nearby time intervals.
33 class BluetoothLowEnergyConnectionFinder 33 class BluetoothLowEnergyConnectionFinder
34 : public cryptauth::ConnectionFinder, 34 : public cryptauth::ConnectionFinder,
35 public cryptauth::ConnectionObserver, 35 public cryptauth::ConnectionObserver,
36 public device::BluetoothAdapter::Observer { 36 public device::BluetoothAdapter::Observer {
37 public: 37 public:
38 // Finds (and connects) to a Bluetooth low energy device, based on the EID 38 // Finds (and connects) to a Bluetooth low energy device, based on the EID
39 // advertised by the remote device. 39 // advertised by the remote device.
40 // 40 //
41 // |remote_device|: The BLE remote device. 41 // |remote_device|: The BLE remote device.
Kyle Horimoto 2017/05/04 03:52:51 You should probably add some language here saying
Tim Song 2017/05/06 22:53:16 The DCHECK might be too harsh as there could be is
42 // |beacon_seeds|: The BeaconSeeds for the |remote_device.
43 // |bluetooth_throttler|: The reconnection throttler. 42 // |bluetooth_throttler|: The reconnection throttler.
44 BluetoothLowEnergyConnectionFinder( 43 BluetoothLowEnergyConnectionFinder(
45 const cryptauth::RemoteDevice remote_device, 44 const cryptauth::RemoteDevice remote_device,
46 const std::vector<cryptauth::BeaconSeed>& beacon_seeds,
47 cryptauth::BluetoothThrottler* bluetooth_throttler); 45 cryptauth::BluetoothThrottler* bluetooth_throttler);
48 46
49 ~BluetoothLowEnergyConnectionFinder() override; 47 ~BluetoothLowEnergyConnectionFinder() override;
50 48
51 // Finds a connection to the remote device. 49 // Finds a connection to the remote device.
52 void Find(const cryptauth::ConnectionFinder::ConnectionCallback& 50 void Find(const cryptauth::ConnectionFinder::ConnectionCallback&
53 connection_callback) override; 51 connection_callback) override;
54 52
55 // cryptauth::ConnectionObserver: 53 // cryptauth::ConnectionObserver:
56 void OnConnectionStatusChanged( 54 void OnConnectionStatusChanged(
57 cryptauth::Connection* connection, 55 cryptauth::Connection* connection,
58 cryptauth::Connection::Status old_status, 56 cryptauth::Connection::Status old_status,
59 cryptauth::Connection::Status new_status) override; 57 cryptauth::Connection::Status new_status) override;
60 58
61 // device::BluetoothAdapter::Observer: 59 // device::BluetoothAdapter::Observer:
62 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, 60 void AdapterPoweredChanged(device::BluetoothAdapter* adapter,
63 bool powered) override; 61 bool powered) override;
64 void DeviceAdded(device::BluetoothAdapter* adapter, 62 void DeviceAdded(device::BluetoothAdapter* adapter,
65 device::BluetoothDevice* device) override; 63 device::BluetoothDevice* device) override;
66 void DeviceChanged(device::BluetoothAdapter* adapter, 64 void DeviceChanged(device::BluetoothAdapter* adapter,
67 device::BluetoothDevice* device) override; 65 device::BluetoothDevice* device) override;
68 66
69 protected: 67 protected:
70 BluetoothLowEnergyConnectionFinder( 68 BluetoothLowEnergyConnectionFinder(
71 const cryptauth::RemoteDevice remote_device, 69 const cryptauth::RemoteDevice remote_device,
72 const std::string& service_uuid, 70 const std::string& service_uuid,
73 const std::vector<cryptauth::BeaconSeed>& beacon_seeds,
74 std::unique_ptr<cryptauth::BackgroundEidGenerator> eid_generator, 71 std::unique_ptr<cryptauth::BackgroundEidGenerator> eid_generator,
75 cryptauth::BluetoothThrottler* bluetooth_throttler); 72 cryptauth::BluetoothThrottler* bluetooth_throttler);
76 73
77 // Creates a proximity_auth::Connection with the device given by 74 // Creates a proximity_auth::Connection with the device given by
78 // |device_address|. Exposed for testing. 75 // |device_address|. Exposed for testing.
79 virtual std::unique_ptr<cryptauth::Connection> CreateConnection( 76 virtual std::unique_ptr<cryptauth::Connection> CreateConnection(
80 const std::string& device_address); 77 const std::string& device_address);
81 78
82 // Checks if |device| is advertising the right EID. 79 // Checks if |device| is advertising the right EID.
83 virtual bool IsRightDevice(device::BluetoothDevice* device); 80 virtual bool IsRightDevice(device::BluetoothDevice* device);
(...skipping 27 matching lines...) Expand all
111 void InvokeCallbackAsync(); 108 void InvokeCallbackAsync();
112 109
113 // The remote BLE device being searched. It maybe empty, in this case the 110 // The remote BLE device being searched. It maybe empty, in this case the
114 // remote device should advertise |remote_service_uuid_| and 111 // remote device should advertise |remote_service_uuid_| and
115 // |advertised_name_|. 112 // |advertised_name_|.
116 cryptauth::RemoteDevice remote_device_; 113 cryptauth::RemoteDevice remote_device_;
117 114
118 // The UUID of the service used by the Weave socket. 115 // The UUID of the service used by the Weave socket.
119 std::string service_uuid_; 116 std::string service_uuid_;
120 117
121 // The BeaconSeeds of the |remote_device|.
122 std::vector<cryptauth::BeaconSeed> beacon_seeds_;
123
124 // Generates the expected EIDs that may be advertised by |remote_device_|. If 118 // Generates the expected EIDs that may be advertised by |remote_device_|. If
125 // an EID matches, we know its a device we should connect to. 119 // an EID matches, we know its a device we should connect to.
126 std::unique_ptr<cryptauth::BackgroundEidGenerator> eid_generator_; 120 std::unique_ptr<cryptauth::BackgroundEidGenerator> eid_generator_;
127 121
128 // Throttles repeated connection attempts to the same device. This is a 122 // Throttles repeated connection attempts to the same device. This is a
129 // workaround for crbug.com/508919. Not owned, must outlive this instance. 123 // workaround for crbug.com/508919. Not owned, must outlive this instance.
130 cryptauth::BluetoothThrottler* bluetooth_throttler_; 124 cryptauth::BluetoothThrottler* bluetooth_throttler_;
131 125
132 // The Bluetooth adapter over which the Bluetooth connection will be made. 126 // The Bluetooth adapter over which the Bluetooth connection will be made.
133 scoped_refptr<device::BluetoothAdapter> adapter_; 127 scoped_refptr<device::BluetoothAdapter> adapter_;
134 128
135 // The discovery session associated to this object. 129 // The discovery session associated to this object.
136 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_; 130 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session_;
137 131
138 // The connection with |remote_device|. 132 // The connection with |remote_device|.
139 std::unique_ptr<cryptauth::Connection> connection_; 133 std::unique_ptr<cryptauth::Connection> connection_;
140 134
141 // Callback called when the connection is established. 135 // Callback called when the connection is established.
142 cryptauth::ConnectionFinder::ConnectionCallback connection_callback_; 136 cryptauth::ConnectionFinder::ConnectionCallback connection_callback_;
143 137
144 base::WeakPtrFactory<BluetoothLowEnergyConnectionFinder> weak_ptr_factory_; 138 base::WeakPtrFactory<BluetoothLowEnergyConnectionFinder> weak_ptr_factory_;
145 139
146 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnectionFinder); 140 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyConnectionFinder);
147 }; 141 };
148 142
149 } // namespace proximity_auth 143 } // namespace proximity_auth
150 144
151 #endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H 145 #endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_LOW_ENERGY_CONNECTION_FINDER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698