| 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/remote_device_life_cycle_impl.h" | 5 #include "components/proximity_auth/remote_device_life_cycle_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 RemoteDeviceLifeCycleImpl::RemoteDeviceLifeCycleImpl( | 44 RemoteDeviceLifeCycleImpl::RemoteDeviceLifeCycleImpl( |
| 45 const cryptauth::RemoteDevice& remote_device, | 45 const cryptauth::RemoteDevice& remote_device, |
| 46 ProximityAuthClient* proximity_auth_client) | 46 ProximityAuthClient* proximity_auth_client) |
| 47 : remote_device_(remote_device), | 47 : remote_device_(remote_device), |
| 48 proximity_auth_client_(proximity_auth_client), | 48 proximity_auth_client_(proximity_auth_client), |
| 49 state_(RemoteDeviceLifeCycle::State::STOPPED), | 49 state_(RemoteDeviceLifeCycle::State::STOPPED), |
| 50 observers_(base::ObserverList<Observer>::NOTIFY_EXISTING_ONLY), | 50 observers_(base::ObserverList<Observer>::NOTIFY_EXISTING_ONLY), |
| 51 bluetooth_throttler_(new cryptauth::BluetoothThrottlerImpl( | 51 bluetooth_throttler_(cryptauth::BluetoothThrottlerImpl::GetInstance()), |
| 52 base::WrapUnique(new base::DefaultTickClock()))), | |
| 53 weak_ptr_factory_(this) {} | 52 weak_ptr_factory_(this) {} |
| 54 | 53 |
| 55 RemoteDeviceLifeCycleImpl::~RemoteDeviceLifeCycleImpl() {} | 54 RemoteDeviceLifeCycleImpl::~RemoteDeviceLifeCycleImpl() {} |
| 56 | 55 |
| 57 void RemoteDeviceLifeCycleImpl::Start() { | 56 void RemoteDeviceLifeCycleImpl::Start() { |
| 58 PA_LOG(INFO) << "Life cycle for " << remote_device_.bluetooth_address | 57 PA_LOG(INFO) << "Life cycle for " << remote_device_.bluetooth_address |
| 59 << " started."; | 58 << " started."; |
| 60 DCHECK(state_ == RemoteDeviceLifeCycle::State::STOPPED); | 59 DCHECK(state_ == RemoteDeviceLifeCycle::State::STOPPED); |
| 61 FindConnection(); | 60 FindConnection(); |
| 62 } | 61 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 80 void RemoteDeviceLifeCycleImpl::RemoveObserver(Observer* observer) { | 79 void RemoteDeviceLifeCycleImpl::RemoveObserver(Observer* observer) { |
| 81 observers_.RemoveObserver(observer); | 80 observers_.RemoveObserver(observer); |
| 82 } | 81 } |
| 83 | 82 |
| 84 std::unique_ptr<cryptauth::ConnectionFinder> | 83 std::unique_ptr<cryptauth::ConnectionFinder> |
| 85 RemoteDeviceLifeCycleImpl::CreateConnectionFinder() { | 84 RemoteDeviceLifeCycleImpl::CreateConnectionFinder() { |
| 86 if (remote_device_.bluetooth_address.empty()) { | 85 if (remote_device_.bluetooth_address.empty()) { |
| 87 return base::MakeUnique<BluetoothLowEnergyConnectionFinder>( | 86 return base::MakeUnique<BluetoothLowEnergyConnectionFinder>( |
| 88 remote_device_, kBLESmartLockServiceUUID, | 87 remote_device_, kBLESmartLockServiceUUID, |
| 89 BluetoothLowEnergyConnectionFinder::FinderStrategy::FIND_PAIRED_DEVICE, | 88 BluetoothLowEnergyConnectionFinder::FinderStrategy::FIND_PAIRED_DEVICE, |
| 90 nullptr, bluetooth_throttler_.get(), 3); | 89 nullptr, bluetooth_throttler_, 3); |
| 91 } else { | 90 } else { |
| 92 return base::MakeUnique<BluetoothConnectionFinder>( | 91 return base::MakeUnique<BluetoothConnectionFinder>( |
| 93 remote_device_, device::BluetoothUUID(kClassicBluetoothServiceUUID), | 92 remote_device_, device::BluetoothUUID(kClassicBluetoothServiceUUID), |
| 94 base::TimeDelta::FromSeconds(3)); | 93 base::TimeDelta::FromSeconds(3)); |
| 95 } | 94 } |
| 96 } | 95 } |
| 97 | 96 |
| 98 std::unique_ptr<cryptauth::Authenticator> | 97 std::unique_ptr<cryptauth::Authenticator> |
| 99 RemoteDeviceLifeCycleImpl::CreateAuthenticator() { | 98 RemoteDeviceLifeCycleImpl::CreateAuthenticator() { |
| 100 return base::MakeUnique<cryptauth::DeviceToDeviceAuthenticator>( | 99 return base::MakeUnique<cryptauth::DeviceToDeviceAuthenticator>( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); | 166 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); |
| 168 } | 167 } |
| 169 | 168 |
| 170 void RemoteDeviceLifeCycleImpl::OnDisconnected() { | 169 void RemoteDeviceLifeCycleImpl::OnDisconnected() { |
| 171 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); | 170 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); |
| 172 messenger_.reset(); | 171 messenger_.reset(); |
| 173 FindConnection(); | 172 FindConnection(); |
| 174 } | 173 } |
| 175 | 174 |
| 176 } // namespace proximity_auth | 175 } // namespace proximity_auth |
| OLD | NEW |