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

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

Issue 1377313002: Revert of 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"
13 #include "components/proximity_auth/proximity_monitor.h" 12 #include "components/proximity_auth/proximity_monitor.h"
14 #include "components/proximity_auth/remote_device.h" 13 #include "components/proximity_auth/remote_device.h"
15 #include "device/bluetooth/bluetooth_device.h" 14 #include "device/bluetooth/bluetooth_device.h"
16 15
17 namespace base { 16 namespace base {
18 class TickClock; 17 class TickClock;
19 class TimeTicks; 18 class TimeTicks;
20 } 19 }
21 20
22 namespace device { 21 namespace device {
23 class BluetoothAdapter; 22 class BluetoothAdapter;
24 } 23 }
25 24
26 namespace proximity_auth { 25 namespace proximity_auth {
27 26
28 class ProximityMonitorObserver; 27 class ProximityMonitorObserver;
29 28
30 // The concrete implemenation of the proximity monitor interface. 29 // The concrete implemenation of the proximity monitor interface.
31 class ProximityMonitorImpl : public ProximityMonitor { 30 class ProximityMonitorImpl : public ProximityMonitor {
32 public: 31 public:
33 // The |observer| is not owned, and must outlive |this| instance. 32 // The |observer| is not owned, and must outlive |this| instance.
34 ProximityMonitorImpl(const RemoteDevice& remote_device, 33 ProximityMonitorImpl(const RemoteDevice& remote_device,
35 scoped_ptr<base::TickClock> clock); 34 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;
47 45
48 protected: 46 protected:
49 // Sets the proximity detection strategy. Exposed for testing. 47 // Sets the proximity detection strategy. Exposed for testing.
50 // TODO(isherman): Stop exposing this for testing once prefs are properly 48 // TODO(isherman): Stop exposing this for testing once prefs are properly
51 // hooked up. 49 // hooked up.
52 virtual void SetStrategy(Strategy strategy); 50 virtual void SetStrategy(Strategy strategy);
53 51
54 private: 52 private:
55 struct TransmitPowerReading { 53 struct TransmitPowerReading {
56 TransmitPowerReading(int transmit_power, int max_transmit_power); 54 TransmitPowerReading(int transmit_power, int max_transmit_power);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // Resets the proximity state to |false|, and clears all member variables 90 // Resets the proximity state to |false|, and clears all member variables
93 // tracking the proximity state. 91 // tracking the proximity state.
94 void ClearProximityState(); 92 void ClearProximityState();
95 93
96 // Updates the proximity state with a new |connection_info| sample of the 94 // Updates the proximity state with a new |connection_info| sample of the
97 // current RSSI and Tx power, and the device's maximum Tx power. 95 // current RSSI and Tx power, and the device's maximum Tx power.
98 void AddSample( 96 void AddSample(
99 const device::BluetoothDevice::ConnectionInfo& connection_info); 97 const device::BluetoothDevice::ConnectionInfo& connection_info);
100 98
101 // Checks whether the proximity state has changed based on the current 99 // Checks whether the proximity state has changed based on the current
102 // samples. Notifies |observers_| on a change. 100 // samples. Notifies the |observer_| on a change.
103 void CheckForProximityStateChange(); 101 void CheckForProximityStateChange();
104 102
105 // The remote device being monitored.
106 const RemoteDevice remote_device_; 103 const RemoteDevice remote_device_;
107 104
108 // The observers attached to the ProximityMonitor. 105 // The |observer_| is not owned, and must outlive |this| instance.
109 base::ObserverList<ProximityMonitorObserver> observers_; 106 ProximityMonitorObserver* observer_;
110 107
111 // The Bluetooth adapter that will be polled for connection info. 108 // The Bluetooth adapter that will be polled for connection info.
112 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; 109 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_;
113 110
114 // The strategy used to determine whether the remote device is in proximity. 111 // The strategy used to determine whether the remote device is in proximity.
115 Strategy strategy_; 112 Strategy strategy_;
116 113
117 // Whether the remote device is currently in close proximity to the local 114 // Whether the remote device is currently in close proximity to the local
118 // device. 115 // device.
119 bool remote_device_is_in_proximity_; 116 bool remote_device_is_in_proximity_;
(...skipping 30 matching lines...) Expand all
150 147
151 // Used to vend all other weak pointers. 148 // Used to vend all other weak pointers.
152 base::WeakPtrFactory<ProximityMonitorImpl> weak_ptr_factory_; 149 base::WeakPtrFactory<ProximityMonitorImpl> weak_ptr_factory_;
153 150
154 DISALLOW_COPY_AND_ASSIGN(ProximityMonitorImpl); 151 DISALLOW_COPY_AND_ASSIGN(ProximityMonitorImpl);
155 }; 152 };
156 153
157 } // namespace proximity_auth 154 } // namespace proximity_auth
158 155
159 #endif // COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_IMPL_H 156 #endif // COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_IMPL_H
OLDNEW
« no previous file with comments | « components/proximity_auth/proximity_monitor.h ('k') | components/proximity_auth/proximity_monitor_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698