| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "base/time/default_tick_clock.h" | 10 #include "base/time/default_tick_clock.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 } | 88 } |
| 89 | 89 |
| 90 scoped_ptr<Authenticator> RemoteDeviceLifeCycleImpl::CreateAuthenticator() { | 90 scoped_ptr<Authenticator> RemoteDeviceLifeCycleImpl::CreateAuthenticator() { |
| 91 return make_scoped_ptr(new DeviceToDeviceAuthenticator( | 91 return make_scoped_ptr(new DeviceToDeviceAuthenticator( |
| 92 connection_.get(), proximity_auth_client_->GetAccountId(), | 92 connection_.get(), proximity_auth_client_->GetAccountId(), |
| 93 proximity_auth_client_->CreateSecureMessageDelegate())); | 93 proximity_auth_client_->CreateSecureMessageDelegate())); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void RemoteDeviceLifeCycleImpl::TransitionToState( | 96 void RemoteDeviceLifeCycleImpl::TransitionToState( |
| 97 RemoteDeviceLifeCycle::State new_state) { | 97 RemoteDeviceLifeCycle::State new_state) { |
| 98 PA_LOG(INFO) << "Life cycle transition: " << static_cast<int>(state_) |
| 99 << " => " << static_cast<int>(new_state); |
| 98 RemoteDeviceLifeCycle::State old_state = state_; | 100 RemoteDeviceLifeCycle::State old_state = state_; |
| 99 state_ = new_state; | 101 state_ = new_state; |
| 100 FOR_EACH_OBSERVER(Observer, observers_, | 102 FOR_EACH_OBSERVER(Observer, observers_, |
| 101 OnLifeCycleStateChanged(old_state, new_state)); | 103 OnLifeCycleStateChanged(old_state, new_state)); |
| 102 } | 104 } |
| 103 | 105 |
| 104 void RemoteDeviceLifeCycleImpl::FindConnection() { | 106 void RemoteDeviceLifeCycleImpl::FindConnection() { |
| 105 connection_finder_ = CreateConnectionFinder(); | 107 connection_finder_ = CreateConnectionFinder(); |
| 106 connection_finder_->Find( | 108 connection_finder_->Find( |
| 107 base::Bind(&RemoteDeviceLifeCycleImpl::OnConnectionFound, | 109 base::Bind(&RemoteDeviceLifeCycleImpl::OnConnectionFound, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 157 |
| 156 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); | 158 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); |
| 157 } | 159 } |
| 158 | 160 |
| 159 void RemoteDeviceLifeCycleImpl::OnDisconnected() { | 161 void RemoteDeviceLifeCycleImpl::OnDisconnected() { |
| 160 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); | 162 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); |
| 161 FindConnection(); | 163 FindConnection(); |
| 162 } | 164 } |
| 163 | 165 |
| 164 } // namespace proximity_auth | 166 } // namespace proximity_auth |
| OLD | NEW |