| 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 #include "components/proximity_auth/proximity_monitor_impl.h" | 5 #include "components/proximity_auth/proximity_monitor_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 << connection_info.transmit_power << " " | 214 << connection_info.transmit_power << " " |
| 215 << connection_info.max_transmit_power; | 215 << connection_info.max_transmit_power; |
| 216 rssi_rolling_average_.reset(); | 216 rssi_rolling_average_.reset(); |
| 217 last_transmit_power_reading_.reset(); | 217 last_transmit_power_reading_.reset(); |
| 218 CheckForProximityStateChange(); | 218 CheckForProximityStateChange(); |
| 219 } | 219 } |
| 220 } | 220 } |
| 221 | 221 |
| 222 void ProximityMonitorImpl::ClearProximityState() { | 222 void ProximityMonitorImpl::ClearProximityState() { |
| 223 if (is_active_ && remote_device_is_in_proximity_) { | 223 if (is_active_ && remote_device_is_in_proximity_) { |
| 224 FOR_EACH_OBSERVER(ProximityMonitorObserver, observers_, | 224 for (auto& observer : observers_) |
| 225 OnProximityStateChanged()); | 225 observer.OnProximityStateChanged(); |
| 226 } | 226 } |
| 227 | 227 |
| 228 remote_device_is_in_proximity_ = false; | 228 remote_device_is_in_proximity_ = false; |
| 229 rssi_rolling_average_.reset(); | 229 rssi_rolling_average_.reset(); |
| 230 last_transmit_power_reading_.reset(); | 230 last_transmit_power_reading_.reset(); |
| 231 last_zero_rssi_timestamp_.reset(); | 231 last_zero_rssi_timestamp_.reset(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void ProximityMonitorImpl::AddSample( | 234 void ProximityMonitorImpl::AddSample( |
| 235 const BluetoothDevice::ConnectionInfo& connection_info) { | 235 const BluetoothDevice::ConnectionInfo& connection_info) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 266 case Strategy::CHECK_TRANSMIT_POWER: | 266 case Strategy::CHECK_TRANSMIT_POWER: |
| 267 is_now_in_proximity = (last_transmit_power_reading_ && | 267 is_now_in_proximity = (last_transmit_power_reading_ && |
| 268 last_transmit_power_reading_->IsInProximity()); | 268 last_transmit_power_reading_->IsInProximity()); |
| 269 break; | 269 break; |
| 270 } | 270 } |
| 271 | 271 |
| 272 if (remote_device_is_in_proximity_ != is_now_in_proximity) { | 272 if (remote_device_is_in_proximity_ != is_now_in_proximity) { |
| 273 PA_LOG(INFO) << "[Proximity] Updated proximity state: " | 273 PA_LOG(INFO) << "[Proximity] Updated proximity state: " |
| 274 << (is_now_in_proximity ? "proximate" : "distant"); | 274 << (is_now_in_proximity ? "proximate" : "distant"); |
| 275 remote_device_is_in_proximity_ = is_now_in_proximity; | 275 remote_device_is_in_proximity_ = is_now_in_proximity; |
| 276 FOR_EACH_OBSERVER(ProximityMonitorObserver, observers_, | 276 for (auto& observer : observers_) |
| 277 OnProximityStateChanged()); | 277 observer.OnProximityStateChanged(); |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 | 280 |
| 281 } // namespace proximity_auth | 281 } // namespace proximity_auth |
| OLD | NEW |