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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 PA_LOG(INFO) << "Life cycle for " << remote_device_.bluetooth_address | 55 PA_LOG(INFO) << "Life cycle for " << remote_device_.bluetooth_address |
56 << " started."; | 56 << " started."; |
57 DCHECK(state_ == RemoteDeviceLifeCycle::State::STOPPED); | 57 DCHECK(state_ == RemoteDeviceLifeCycle::State::STOPPED); |
58 FindConnection(); | 58 FindConnection(); |
59 } | 59 } |
60 | 60 |
61 cryptauth::RemoteDevice RemoteDeviceLifeCycleImpl::GetRemoteDevice() const { | 61 cryptauth::RemoteDevice RemoteDeviceLifeCycleImpl::GetRemoteDevice() const { |
62 return remote_device_; | 62 return remote_device_; |
63 } | 63 } |
64 | 64 |
| 65 cryptauth::Connection* RemoteDeviceLifeCycleImpl::GetConnection() const { |
| 66 if (connection_) |
| 67 return connection_.get(); |
| 68 if (messenger_) |
| 69 return messenger_->GetConnection(); |
| 70 return nullptr; |
| 71 } |
| 72 |
65 RemoteDeviceLifeCycle::State RemoteDeviceLifeCycleImpl::GetState() const { | 73 RemoteDeviceLifeCycle::State RemoteDeviceLifeCycleImpl::GetState() const { |
66 return state_; | 74 return state_; |
67 } | 75 } |
68 | 76 |
69 Messenger* RemoteDeviceLifeCycleImpl::GetMessenger() { | 77 Messenger* RemoteDeviceLifeCycleImpl::GetMessenger() { |
70 return messenger_.get(); | 78 return messenger_.get(); |
71 } | 79 } |
72 | 80 |
73 void RemoteDeviceLifeCycleImpl::AddObserver(Observer* observer) { | 81 void RemoteDeviceLifeCycleImpl::AddObserver(Observer* observer) { |
74 observers_.AddObserver(observer); | 82 observers_.AddObserver(observer); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); | 187 TransitionToState(RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); |
180 } | 188 } |
181 | 189 |
182 void RemoteDeviceLifeCycleImpl::OnDisconnected() { | 190 void RemoteDeviceLifeCycleImpl::OnDisconnected() { |
183 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); | 191 DCHECK(state_ == RemoteDeviceLifeCycle::State::SECURE_CHANNEL_ESTABLISHED); |
184 messenger_.reset(); | 192 messenger_.reset(); |
185 FindConnection(); | 193 FindConnection(); |
186 } | 194 } |
187 | 195 |
188 } // namespace proximity_auth | 196 } // namespace proximity_auth |
OLD | NEW |