| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 observers_.AddObserver(observer); | 76 observers_.AddObserver(observer); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void RemoteDeviceLifeCycleImpl::RemoveObserver(Observer* observer) { | 79 void RemoteDeviceLifeCycleImpl::RemoveObserver(Observer* observer) { |
| 80 observers_.RemoveObserver(observer); | 80 observers_.RemoveObserver(observer); |
| 81 } | 81 } |
| 82 | 82 |
| 83 std::unique_ptr<ConnectionFinder> | 83 std::unique_ptr<ConnectionFinder> |
| 84 RemoteDeviceLifeCycleImpl::CreateConnectionFinder() { | 84 RemoteDeviceLifeCycleImpl::CreateConnectionFinder() { |
| 85 if (remote_device_.bluetooth_type == RemoteDevice::BLUETOOTH_LE) { | 85 if (remote_device_.bluetooth_type == RemoteDevice::BLUETOOTH_LE) { |
| 86 return base::WrapUnique(new BluetoothLowEnergyConnectionFinder( | 86 return base::MakeUnique<BluetoothLowEnergyConnectionFinder>( |
| 87 remote_device_, kBLESmartLockServiceUUID, | 87 remote_device_, kBLESmartLockServiceUUID, |
| 88 BluetoothLowEnergyConnectionFinder::FinderStrategy::FIND_PAIRED_DEVICE, | 88 BluetoothLowEnergyConnectionFinder::FinderStrategy::FIND_PAIRED_DEVICE, |
| 89 nullptr, bluetooth_throttler_.get(), 3)); | 89 nullptr, bluetooth_throttler_.get(), 3); |
| 90 } else { | 90 } else { |
| 91 return base::WrapUnique(new BluetoothConnectionFinder( | 91 return base::MakeUnique<BluetoothConnectionFinder>( |
| 92 remote_device_, device::BluetoothUUID(kClassicBluetoothServiceUUID), | 92 remote_device_, device::BluetoothUUID(kClassicBluetoothServiceUUID), |
| 93 base::TimeDelta::FromSeconds(3))); | 93 base::TimeDelta::FromSeconds(3)); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 std::unique_ptr<Authenticator> | 97 std::unique_ptr<Authenticator> |
| 98 RemoteDeviceLifeCycleImpl::CreateAuthenticator() { | 98 RemoteDeviceLifeCycleImpl::CreateAuthenticator() { |
| 99 return base::WrapUnique(new DeviceToDeviceAuthenticator( | 99 return base::MakeUnique<DeviceToDeviceAuthenticator>( |
| 100 connection_.get(), remote_device_.user_id, | 100 connection_.get(), remote_device_.user_id, |
| 101 proximity_auth_client_->CreateSecureMessageDelegate())); | 101 proximity_auth_client_->CreateSecureMessageDelegate()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void RemoteDeviceLifeCycleImpl::TransitionToState( | 104 void RemoteDeviceLifeCycleImpl::TransitionToState( |
| 105 RemoteDeviceLifeCycle::State new_state) { | 105 RemoteDeviceLifeCycle::State new_state) { |
| 106 PA_LOG(INFO) << "Life cycle transition: " << static_cast<int>(state_) | 106 PA_LOG(INFO) << "Life cycle transition: " << static_cast<int>(state_) |
| 107 << " => " << static_cast<int>(new_state); | 107 << " => " << static_cast<int>(new_state); |
| 108 RemoteDeviceLifeCycle::State old_state = state_; | 108 RemoteDeviceLifeCycle::State old_state = state_; |
| 109 state_ = new_state; | 109 state_ = new_state; |
| 110 FOR_EACH_OBSERVER(Observer, observers_, | 110 FOR_EACH_OBSERVER(Observer, observers_, |
| 111 OnLifeCycleStateChanged(old_state, new_state)); | 111 OnLifeCycleStateChanged(old_state, new_state)); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); | 166 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void RemoteDeviceLifeCycleImpl::OnDisconnected() { | 169 void RemoteDeviceLifeCycleImpl::OnDisconnected() { |
| 170 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); | 170 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); |
| 171 messenger_.reset(); | 171 messenger_.reset(); |
| 172 FindConnection(); | 172 FindConnection(); |
| 173 } | 173 } |
| 174 | 174 |
| 175 } // namespace proximity_auth | 175 } // namespace proximity_auth |
| OLD | NEW |