| OLD | NEW |
| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "components/cryptauth/remote_device.h" |
| 14 #include "components/proximity_auth/proximity_monitor.h" | 15 #include "components/proximity_auth/proximity_monitor.h" |
| 15 #include "components/proximity_auth/remote_device.h" | |
| 16 #include "device/bluetooth/bluetooth_device.h" | 16 #include "device/bluetooth/bluetooth_device.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 class TickClock; | 19 class TickClock; |
| 20 class TimeTicks; | 20 class TimeTicks; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace device { | 23 namespace device { |
| 24 class BluetoothAdapter; | 24 class BluetoothAdapter; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace proximity_auth { | 27 namespace proximity_auth { |
| 28 | 28 |
| 29 class ProximityMonitorObserver; | 29 class ProximityMonitorObserver; |
| 30 | 30 |
| 31 // The concrete implemenation of the proximity monitor interface. | 31 // The concrete implemenation of the proximity monitor interface. |
| 32 class ProximityMonitorImpl : public ProximityMonitor { | 32 class ProximityMonitorImpl : public ProximityMonitor { |
| 33 public: | 33 public: |
| 34 // The |observer| is not owned, and must outlive |this| instance. | 34 // The |observer| is not owned, and must outlive |this| instance. |
| 35 ProximityMonitorImpl(const RemoteDevice& remote_device, | 35 ProximityMonitorImpl(const cryptauth::RemoteDevice& remote_device, |
| 36 std::unique_ptr<base::TickClock> clock); | 36 std::unique_ptr<base::TickClock> clock); |
| 37 ~ProximityMonitorImpl() override; | 37 ~ProximityMonitorImpl() override; |
| 38 | 38 |
| 39 // ProximityMonitor: | 39 // ProximityMonitor: |
| 40 void Start() override; | 40 void Start() override; |
| 41 void Stop() override; | 41 void Stop() override; |
| 42 Strategy GetStrategy() const override; | 42 Strategy GetStrategy() const override; |
| 43 bool IsUnlockAllowed() const override; | 43 bool IsUnlockAllowed() const override; |
| 44 bool IsInRssiRange() const override; | 44 bool IsInRssiRange() const override; |
| 45 void RecordProximityMetricsOnAuthSuccess() override; | 45 void RecordProximityMetricsOnAuthSuccess() override; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // Updates the proximity state with a new |connection_info| sample of the | 97 // Updates the proximity state with a new |connection_info| sample of the |
| 98 // current RSSI and Tx power, and the device's maximum Tx power. | 98 // current RSSI and Tx power, and the device's maximum Tx power. |
| 99 void AddSample( | 99 void AddSample( |
| 100 const device::BluetoothDevice::ConnectionInfo& connection_info); | 100 const device::BluetoothDevice::ConnectionInfo& connection_info); |
| 101 | 101 |
| 102 // Checks whether the proximity state has changed based on the current | 102 // Checks whether the proximity state has changed based on the current |
| 103 // samples. Notifies |observers_| on a change. | 103 // samples. Notifies |observers_| on a change. |
| 104 void CheckForProximityStateChange(); | 104 void CheckForProximityStateChange(); |
| 105 | 105 |
| 106 // The remote device being monitored. | 106 // The remote device being monitored. |
| 107 const RemoteDevice remote_device_; | 107 const cryptauth::RemoteDevice remote_device_; |
| 108 | 108 |
| 109 // The observers attached to the ProximityMonitor. | 109 // The observers attached to the ProximityMonitor. |
| 110 base::ObserverList<ProximityMonitorObserver> observers_; | 110 base::ObserverList<ProximityMonitorObserver> observers_; |
| 111 | 111 |
| 112 // The Bluetooth adapter that will be polled for connection info. | 112 // The Bluetooth adapter that will be polled for connection info. |
| 113 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; | 113 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; |
| 114 | 114 |
| 115 // The strategy used to determine whether the remote device is in proximity. | 115 // The strategy used to determine whether the remote device is in proximity. |
| 116 Strategy strategy_; | 116 Strategy strategy_; |
| 117 | 117 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 // Used to vend all other weak pointers. | 152 // Used to vend all other weak pointers. |
| 153 base::WeakPtrFactory<ProximityMonitorImpl> weak_ptr_factory_; | 153 base::WeakPtrFactory<ProximityMonitorImpl> weak_ptr_factory_; |
| 154 | 154 |
| 155 DISALLOW_COPY_AND_ASSIGN(ProximityMonitorImpl); | 155 DISALLOW_COPY_AND_ASSIGN(ProximityMonitorImpl); |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 } // namespace proximity_auth | 158 } // namespace proximity_auth |
| 159 | 159 |
| 160 #endif // COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_IMPL_H | 160 #endif // COMPONENTS_PROXIMITY_AUTH_PROXIMITY_MONITOR_IMPL_H |
| OLD | NEW |