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

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

Issue 1372283002: Hook up ProximityAuthSystem in EasyUnlockService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth_connection
Patch Set: Created 5 years, 2 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_PROXIMITY_MONITOR_IMPL_H 5 #ifndef COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_IMPL_H
6 #define COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_IMPL_H 6 #define COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_IMPL_H
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/observer_list.h"
12 #include "components/proximity_auth/proximity_monitor.h" 13 #include "components/proximity_auth/proximity_monitor.h"
13 #include "components/proximity_auth/remote_device.h" 14 #include "components/proximity_auth/remote_device.h"
14 #include "device/bluetooth/bluetooth_device.h" 15 #include "device/bluetooth/bluetooth_device.h"
15 16
16 namespace base { 17 namespace base {
17 class TickClock; 18 class TickClock;
18 class TimeTicks; 19 class TimeTicks;
19 } 20 }
20 21
21 namespace device { 22 namespace device {
22 class BluetoothAdapter; 23 class BluetoothAdapter;
23 } 24 }
24 25
25 namespace proximity_auth { 26 namespace proximity_auth {
26 27
27 class ProximityMonitorObserver; 28 class ProximityMonitorObserver;
28 29
29 // The concrete implemenation of the proximity monitor interface. 30 // The concrete implemenation of the proximity monitor interface.
30 class ProximityMonitorImpl : public ProximityMonitor { 31 class ProximityMonitorImpl : public ProximityMonitor {
31 public: 32 public:
32 // The |observer| is not owned, and must outlive |this| instance. 33 // The |observer| is not owned, and must outlive |this| instance.
33 ProximityMonitorImpl(const RemoteDevice& remote_device, 34 ProximityMonitorImpl(const RemoteDevice& remote_device,
34 scoped_ptr<base::TickClock> clock, 35 scoped_ptr<base::TickClock> clock);
35 ProximityMonitorObserver* observer);
36 ~ProximityMonitorImpl() override; 36 ~ProximityMonitorImpl() override;
37 37
38 // ProximityMonitor: 38 // ProximityMonitor:
39 void Start() override; 39 void Start() override;
40 void Stop() override; 40 void Stop() override;
41 Strategy GetStrategy() const override; 41 Strategy GetStrategy() const override;
42 bool IsUnlockAllowed() const override; 42 bool IsUnlockAllowed() const override;
43 bool IsInRssiRange() const override; 43 bool IsInRssiRange() const override;
44 void RecordProximityMetricsOnAuthSuccess() override; 44 void RecordProximityMetricsOnAuthSuccess() override;
45 void AddObserver(ProximityMonitorObserver* observer) override;
46 void RemoveObserver(ProximityMonitorObserver* observer) override;
45 47
46 protected: 48 protected:
47 // Sets the proximity detection strategy. Exposed for testing. 49 // Sets the proximity detection strategy. Exposed for testing.
48 // TODO(isherman): Stop exposing this for testing once prefs are properly 50 // TODO(isherman): Stop exposing this for testing once prefs are properly
49 // hooked up. 51 // hooked up.
50 virtual void SetStrategy(Strategy strategy); 52 virtual void SetStrategy(Strategy strategy);
51 53
52 private: 54 private:
53 struct TransmitPowerReading { 55 struct TransmitPowerReading {
54 TransmitPowerReading(int transmit_power, int max_transmit_power); 56 TransmitPowerReading(int transmit_power, int max_transmit_power);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // Resets the proximity state to |false|, and clears all member variables 92 // Resets the proximity state to |false|, and clears all member variables
91 // tracking the proximity state. 93 // tracking the proximity state.
92 void ClearProximityState(); 94 void ClearProximityState();
93 95
94 // Updates the proximity state with a new |connection_info| sample of the 96 // Updates the proximity state with a new |connection_info| sample of the
95 // current RSSI and Tx power, and the device's maximum Tx power. 97 // current RSSI and Tx power, and the device's maximum Tx power.
96 void AddSample( 98 void AddSample(
97 const device::BluetoothDevice::ConnectionInfo& connection_info); 99 const device::BluetoothDevice::ConnectionInfo& connection_info);
98 100
99 // Checks whether the proximity state has changed based on the current 101 // Checks whether the proximity state has changed based on the current
100 // samples. Notifies the |observer_| on a change. 102 // samples. Notifies |observers_| on a change.
101 void CheckForProximityStateChange(); 103 void CheckForProximityStateChange();
102 104
105 // The remote device being monitored.
103 const RemoteDevice remote_device_; 106 const RemoteDevice remote_device_;
104 107
105 // The |observer_| is not owned, and must outlive |this| instance. 108 // The observers attached to the ProximityMonitor.
106 ProximityMonitorObserver* observer_; 109 base::ObserverList<ProximityMonitorObserver> observers_;
107 110
108 // The Bluetooth adapter that will be polled for connection info. 111 // The Bluetooth adapter that will be polled for connection info.
109 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; 112 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_;
110 113
111 // The strategy used to determine whether the remote device is in proximity. 114 // The strategy used to determine whether the remote device is in proximity.
112 Strategy strategy_; 115 Strategy strategy_;
113 116
114 // Whether the remote device is currently in close proximity to the local 117 // Whether the remote device is currently in close proximity to the local
115 // device. 118 // device.
116 bool remote_device_is_in_proximity_; 119 bool remote_device_is_in_proximity_;
(...skipping 30 matching lines...) Expand all
147 150
148 // Used to vend all other weak pointers. 151 // Used to vend all other weak pointers.
149 base::WeakPtrFactory<ProximityMonitorImpl> weak_ptr_factory_; 152 base::WeakPtrFactory<ProximityMonitorImpl> weak_ptr_factory_;
150 153
151 DISALLOW_COPY_AND_ASSIGN(ProximityMonitorImpl); 154 DISALLOW_COPY_AND_ASSIGN(ProximityMonitorImpl);
152 }; 155 };
153 156
154 } // namespace proximity_auth 157 } // namespace proximity_auth
155 158
156 #endif // COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_IMPL_H 159 #endif // COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_IMPL_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698