| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "remoting/host/security_key/security_key_ipc_server_impl.h" | 5 #include "remoting/host/security_key/security_key_ipc_server_impl.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 #if defined(OS_WIN) | 154 #if defined(OS_WIN) |
| 155 DWORD peer_session_id; | 155 DWORD peer_session_id; |
| 156 if (!ProcessIdToSessionId(peer_pid, &peer_session_id)) { | 156 if (!ProcessIdToSessionId(peer_pid, &peer_session_id)) { |
| 157 PLOG(ERROR) << "ProcessIdToSessionId() failed"; | 157 PLOG(ERROR) << "ProcessIdToSessionId() failed"; |
| 158 connection_close_pending_ = true; | 158 connection_close_pending_ = true; |
| 159 } else if (peer_session_id != client_session_details_->desktop_session_id()) { | 159 } else if (peer_session_id != client_session_details_->desktop_session_id()) { |
| 160 LOG(ERROR) << "Ignoring connection attempt from outside remoted session."; | 160 LOG(ERROR) << "Ignoring connection attempt from outside remoted session."; |
| 161 connection_close_pending_ = true; | 161 connection_close_pending_ = true; |
| 162 } | 162 } |
| 163 if (connection_close_pending_) { | 163 if (connection_close_pending_) { |
| 164 ipc_channel_->Send( |
| 165 new ChromotingNetworkToRemoteSecurityKeyMsg_InvalidSession()); |
| 166 |
| 164 base::ThreadTaskRunnerHandle::Get()->PostTask( | 167 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 165 FROM_HERE, base::Bind(&SecurityKeyIpcServerImpl::OnChannelError, | 168 FROM_HERE, base::Bind(&SecurityKeyIpcServerImpl::OnChannelError, |
| 166 weak_factory_.GetWeakPtr())); | 169 weak_factory_.GetWeakPtr())); |
| 167 return; | 170 return; |
| 168 } | 171 } |
| 169 #else // !defined(OS_WIN) | 172 #else // !defined(OS_WIN) |
| 170 CHECK_EQ(client_session_details_->desktop_session_id(), UINT32_MAX); | 173 CHECK_EQ(client_session_details_->desktop_session_id(), UINT32_MAX); |
| 171 #endif // !defined(OS_WIN) | 174 #endif // !defined(OS_WIN) |
| 172 | 175 |
| 173 // Reset the timer to give the client a chance to send the request. | 176 // Reset the timer to give the client a chance to send the request. |
| 174 timer_.Start(FROM_HERE, initial_connect_timeout_, | 177 timer_.Start(FROM_HERE, initial_connect_timeout_, |
| 175 base::Bind(&SecurityKeyIpcServerImpl::OnChannelError, | 178 base::Bind(&SecurityKeyIpcServerImpl::OnChannelError, |
| 176 base::Unretained(this))); | 179 base::Unretained(this))); |
| 180 |
| 181 ipc_channel_->Send( |
| 182 new ChromotingNetworkToRemoteSecurityKeyMsg_ConnectionReady()); |
| 177 } | 183 } |
| 178 | 184 |
| 179 void SecurityKeyIpcServerImpl::OnChannelError() { | 185 void SecurityKeyIpcServerImpl::OnChannelError() { |
| 180 DCHECK(thread_checker_.CalledOnValidThread()); | 186 DCHECK(thread_checker_.CalledOnValidThread()); |
| 181 CloseChannel(); | 187 CloseChannel(); |
| 182 | 188 |
| 183 if (!connect_callback_.is_null()) { | 189 if (!connect_callback_.is_null()) { |
| 184 base::ResetAndReturn(&connect_callback_).Run(); | 190 base::ResetAndReturn(&connect_callback_).Run(); |
| 185 } | 191 } |
| 186 if (!done_callback_.is_null()) { | 192 if (!done_callback_.is_null()) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 208 connection_close_pending_ = false; | 214 connection_close_pending_ = false; |
| 209 } | 215 } |
| 210 // Close the underlying mojo connection. | 216 // Close the underlying mojo connection. |
| 211 if (!mojo_peer_token_.empty()) { | 217 if (!mojo_peer_token_.empty()) { |
| 212 mojo::edk::ClosePeerConnection(mojo_peer_token_); | 218 mojo::edk::ClosePeerConnection(mojo_peer_token_); |
| 213 mojo_peer_token_.clear(); | 219 mojo_peer_token_.clear(); |
| 214 } | 220 } |
| 215 } | 221 } |
| 216 | 222 |
| 217 } // namespace remoting | 223 } // namespace remoting |
| OLD | NEW |