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

Unified Diff: components/proximity_auth/proximity_monitor_impl.h

Issue 2973243002: Adding pref to store the user-selected proximity threshold. (Closed)
Patch Set: Fixing tests Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: components/proximity_auth/proximity_monitor_impl.h
diff --git a/components/proximity_auth/proximity_monitor_impl.h b/components/proximity_auth/proximity_monitor_impl.h
index 1aebd2ed06ef542ae8861cf48c9df031cb50330b..8fe6c3ec2622b9d049ba8299b92631b9d0650e61 100644
--- a/components/proximity_auth/proximity_monitor_impl.h
+++ b/components/proximity_auth/proximity_monitor_impl.h
@@ -16,6 +16,8 @@
#include "components/proximity_auth/proximity_monitor.h"
#include "device/bluetooth/bluetooth_device.h"
+class PrefService;
+
namespace base {
class TickClock;
}
@@ -26,6 +28,7 @@ class BluetoothAdapter;
namespace proximity_auth {
+class ProximityAuthPrefManager;
class ProximityMonitorObserver;
// The concrete implemenation of the proximity monitor interface.
@@ -33,7 +36,8 @@ class ProximityMonitorImpl : public ProximityMonitor {
public:
// The |connection| is not owned, and must outlive |this| instance.
ProximityMonitorImpl(cryptauth::Connection* connection,
- std::unique_ptr<base::TickClock> clock);
+ std::unique_ptr<base::TickClock> clock,
+ std::unique_ptr<ProximityAuthPrefManager> pref_manager);
~ProximityMonitorImpl() override;
// ProximityMonitor:
@@ -82,6 +86,10 @@ class ProximityMonitorImpl : public ProximityMonitor {
// samples. Notifies |observers_| on a change.
void CheckForProximityStateChange();
+ // Gets the user-selected proximity threshold and converts it to a
+ // RSSI value.
+ void GetRssiThresholdFromPrefs();
+
// The current connection being monitored. Not owned and must outlive this
// instance.
cryptauth::Connection* connection_;
@@ -100,6 +108,9 @@ class ProximityMonitorImpl : public ProximityMonitor {
// for proximity to the remote device.
bool is_active_;
+ // When the RSSI is below this value the phone the unlock is not allowed.
+ int rssi_threshold_;
+
// The exponentailly weighted rolling average of the RSSI, used to smooth the
// RSSI readings. Null if the monitor is inactive, has not recently observed
// an RSSI reading, or the most recent connection info included an invalid
@@ -109,6 +120,10 @@ class ProximityMonitorImpl : public ProximityMonitor {
// Used to access non-decreasing time measurements.
std::unique_ptr<base::TickClock> clock_;
+ // Contains perferences that outlive the lifetime of this object and across
+ // process restarts. Not owned and must outlive this instance.
+ std::unique_ptr<ProximityAuthPrefManager> pref_manager_;
+
// Used to vend weak pointers for polling. Using a separate factory for these
// weak pointers allows the weak pointers to be invalidated when polling
// stops, which effectively cancels the scheduled tasks.

Powered by Google App Engine
This is Rietveld 408576698