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

Unified Diff: components/proximity_auth/proximity_monitor_impl.cc

Issue 1372283002: Hook up ProximityAuthSystem in EasyUnlockService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth_connection
Patch Set: remove log Created 5 years, 3 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.cc
diff --git a/components/proximity_auth/proximity_monitor_impl.cc b/components/proximity_auth/proximity_monitor_impl.cc
index 432485c906599b3230477873863d3a755ebb8f89..702ea77e2b62b84ee57f31146a462d2e124a234d 100644
--- a/components/proximity_auth/proximity_monitor_impl.cc
+++ b/components/proximity_auth/proximity_monitor_impl.cc
@@ -32,10 +32,8 @@ const int kRssiThreshold = -5;
const double kRssiSampleWeight = 0.3;
ProximityMonitorImpl::ProximityMonitorImpl(const RemoteDevice& remote_device,
- scoped_ptr<base::TickClock> clock,
- ProximityMonitorObserver* observer)
+ scoped_ptr<base::TickClock> clock)
: remote_device_(remote_device),
- observer_(observer),
strategy_(Strategy::NONE),
remote_device_is_in_proximity_(false),
is_active_(false),
@@ -112,6 +110,14 @@ void ProximityMonitorImpl::RecordProximityMetricsOnAuthSuccess() {
metrics::RecordAuthProximityRemoteDeviceModelHash(remote_device_model);
}
+void ProximityMonitorImpl::AddObserver(ProximityMonitorObserver* observer) {
+ observers_.AddObserver(observer);
+}
+
+void ProximityMonitorImpl::RemoveObserver(ProximityMonitorObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
void ProximityMonitorImpl::SetStrategy(Strategy strategy) {
if (strategy_ == strategy)
return;
@@ -212,8 +218,10 @@ void ProximityMonitorImpl::OnConnectionInfo(
}
void ProximityMonitorImpl::ClearProximityState() {
- if (is_active_ && remote_device_is_in_proximity_)
- observer_->OnProximityStateChanged();
+ if (is_active_ && remote_device_is_in_proximity_) {
+ FOR_EACH_OBSERVER(ProximityMonitorObserver, observers_,
+ OnProximityStateChanged());
+ }
remote_device_is_in_proximity_ = false;
rssi_rolling_average_.reset();
@@ -263,7 +271,8 @@ void ProximityMonitorImpl::CheckForProximityStateChange() {
PA_LOG(INFO) << "[Proximity] Updated proximity state: "
<< (is_now_in_proximity ? "proximate" : "distant");
remote_device_is_in_proximity_ = is_now_in_proximity;
- observer_->OnProximityStateChanged();
+ FOR_EACH_OBSERVER(ProximityMonitorObserver, observers_,
+ OnProximityStateChanged());
}
}
« no previous file with comments | « components/proximity_auth/proximity_monitor_impl.h ('k') | components/proximity_auth/proximity_monitor_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698