| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 (auto& observer : observers_) |
| 111 OnLifeCycleStateChanged(old_state, new_state)); | 111 observer.OnLifeCycleStateChanged(old_state, new_state); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void RemoteDeviceLifeCycleImpl::FindConnection() { | 114 void RemoteDeviceLifeCycleImpl::FindConnection() { |
| 115 connection_finder_ = CreateConnectionFinder(); | 115 connection_finder_ = CreateConnectionFinder(); |
| 116 connection_finder_->Find( | 116 connection_finder_->Find( |
| 117 base::Bind(&RemoteDeviceLifeCycleImpl::OnConnectionFound, | 117 base::Bind(&RemoteDeviceLifeCycleImpl::OnConnectionFound, |
| 118 weak_ptr_factory_.GetWeakPtr())); | 118 weak_ptr_factory_.GetWeakPtr())); |
| 119 TransitionToState(RemoteDeviceLifeCycle::State::FINDING_CONNECTION); | 119 TransitionToState(RemoteDeviceLifeCycle::State::FINDING_CONNECTION); |
| 120 } | 120 } |
| 121 | 121 |
| (...skipping 44 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 |