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

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

Issue 2560713002: Move RemoteDevice from //components/proximity_auth to //components/cryptauth so that it can be easi… (Closed)
Patch Set: Add cryptauth dependency. Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_CONNECTION_FINDER_H 5 #ifndef COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_FINDER_H
6 #define COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_FINDER_H 6 #define COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_FINDER_H
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "components/cryptauth/remote_device.h"
15 #include "components/proximity_auth/bluetooth_util.h" 16 #include "components/proximity_auth/bluetooth_util.h"
16 #include "components/proximity_auth/connection_finder.h" 17 #include "components/proximity_auth/connection_finder.h"
17 #include "components/proximity_auth/connection_observer.h" 18 #include "components/proximity_auth/connection_observer.h"
18 #include "components/proximity_auth/remote_device.h"
19 #include "device/bluetooth/bluetooth_adapter.h" 19 #include "device/bluetooth/bluetooth_adapter.h"
20 #include "device/bluetooth/bluetooth_uuid.h" 20 #include "device/bluetooth/bluetooth_uuid.h"
21 21
22 namespace proximity_auth { 22 namespace proximity_auth {
23 23
24 // This ConnectionFinder implementation tries to find a Bluetooth connection to 24 // This ConnectionFinder implementation tries to find a Bluetooth connection to
25 // the remote device by polling at a fixed interval. 25 // the remote device by polling at a fixed interval.
26 class BluetoothConnectionFinder : public ConnectionFinder, 26 class BluetoothConnectionFinder : public ConnectionFinder,
27 public ConnectionObserver, 27 public ConnectionObserver,
28 public device::BluetoothAdapter::Observer { 28 public device::BluetoothAdapter::Observer {
29 public: 29 public:
30 BluetoothConnectionFinder(const RemoteDevice& remote_device, 30 BluetoothConnectionFinder(const cryptauth::RemoteDevice& remote_device,
31 const device::BluetoothUUID& uuid, 31 const device::BluetoothUUID& uuid,
32 const base::TimeDelta& polling_interval); 32 const base::TimeDelta& polling_interval);
33 ~BluetoothConnectionFinder() override; 33 ~BluetoothConnectionFinder() override;
34 34
35 // ConnectionFinder: 35 // ConnectionFinder:
36 void Find(const ConnectionCallback& connection_callback) override; 36 void Find(const ConnectionCallback& connection_callback) override;
37 37
38 protected: 38 protected:
39 // Exposed for mocking out the connection in tests. 39 // Exposed for mocking out the connection in tests.
40 virtual std::unique_ptr<Connection> CreateConnection(); 40 virtual std::unique_ptr<Connection> CreateConnection();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // ConnectionObserver: 79 // ConnectionObserver:
80 void OnConnectionStatusChanged(Connection* connection, 80 void OnConnectionStatusChanged(Connection* connection,
81 Connection::Status old_status, 81 Connection::Status old_status,
82 Connection::Status new_status) override; 82 Connection::Status new_status) override;
83 83
84 // Used to invoke |connection_callback_| asynchronously, decoupling the 84 // Used to invoke |connection_callback_| asynchronously, decoupling the
85 // callback invocation from the ConnectionObserver callstack. 85 // callback invocation from the ConnectionObserver callstack.
86 void InvokeCallbackAsync(); 86 void InvokeCallbackAsync();
87 87
88 // The remote device to connect to. 88 // The remote device to connect to.
89 const RemoteDevice remote_device_; 89 const cryptauth::RemoteDevice remote_device_;
90 90
91 // The UUID of the service on the remote device. 91 // The UUID of the service on the remote device.
92 const device::BluetoothUUID uuid_; 92 const device::BluetoothUUID uuid_;
93 93
94 // The time to wait between polling attempts. 94 // The time to wait between polling attempts.
95 const base::TimeDelta polling_interval_; 95 const base::TimeDelta polling_interval_;
96 96
97 // Records the time at which the finder began searching for connections. 97 // Records the time at which the finder began searching for connections.
98 base::TimeTicks start_time_; 98 base::TimeTicks start_time_;
99 99
(...skipping 15 matching lines...) Expand all
115 DISALLOW_COPY_AND_ASSIGN(BluetoothConnectionFinder); 115 DISALLOW_COPY_AND_ASSIGN(BluetoothConnectionFinder);
116 }; 116 };
117 117
118 // TODO(isherman): Make sure to wire up the controller to listen for screen lock 118 // TODO(isherman): Make sure to wire up the controller to listen for screen lock
119 // state change events, and create or destroy the connection finder as 119 // state change events, and create or destroy the connection finder as
120 // appropriate. 120 // appropriate.
121 121
122 } // namespace proximity_auth 122 } // namespace proximity_auth
123 123
124 #endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_FINDER_H 124 #endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_FINDER_H
OLDNEW
« no previous file with comments | « components/proximity_auth/bluetooth_connection.cc ('k') | components/proximity_auth/bluetooth_connection_finder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698