| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/desktop_session_proxy.h" | 5 #include "remoting/host/desktop_session_proxy.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 IPC_END_MESSAGE_MAP() | 195 IPC_END_MESSAGE_MAP() |
| 196 | 196 |
| 197 CHECK(handled) << "Received unexpected IPC type: " << message.type(); | 197 CHECK(handled) << "Received unexpected IPC type: " << message.type(); |
| 198 return handled; | 198 return handled; |
| 199 } | 199 } |
| 200 | 200 |
| 201 void DesktopSessionProxy::OnChannelConnected(int32_t peer_pid) { | 201 void DesktopSessionProxy::OnChannelConnected(int32_t peer_pid) { |
| 202 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 202 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 203 | 203 |
| 204 VLOG(1) << "IPC: network <- desktop (" << peer_pid << ")"; | 204 VLOG(1) << "IPC: network <- desktop (" << peer_pid << ")"; |
| 205 | |
| 206 #if defined(OS_WIN) | |
| 207 if (!ProcessIdToSessionId(peer_pid, | |
| 208 reinterpret_cast<DWORD*>(&desktop_session_id_))) { | |
| 209 PLOG(ERROR) << "ProcessIdToSessionId() failed!"; | |
| 210 } | |
| 211 #endif // defined(OS_WIN) | |
| 212 } | 205 } |
| 213 | 206 |
| 214 void DesktopSessionProxy::OnChannelError() { | 207 void DesktopSessionProxy::OnChannelError() { |
| 215 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 208 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 216 | 209 |
| 217 DetachFromDesktop(); | 210 DetachFromDesktop(); |
| 218 } | 211 } |
| 219 | 212 |
| 220 bool DesktopSessionProxy::AttachToDesktop( | 213 bool DesktopSessionProxy::AttachToDesktop( |
| 221 const IPC::ChannelHandle& desktop_pipe) { | 214 const IPC::ChannelHandle& desktop_pipe, |
| 215 int session_id) { |
| 222 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 216 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 223 DCHECK(!desktop_channel_); | 217 DCHECK(!desktop_channel_); |
| 224 | 218 |
| 225 // Ignore the attach notification if the client session has been disconnected | 219 // Ignore the attach notification if the client session has been disconnected |
| 226 // already. | 220 // already. |
| 227 if (!client_session_control_.get()) | 221 if (!client_session_control_.get()) |
| 228 return false; | 222 return false; |
| 229 | 223 |
| 230 // Connect to the desktop process. | 224 // Connect to the desktop process. |
| 231 desktop_channel_ = IPC::ChannelProxy::Create(desktop_pipe, | 225 desktop_channel_ = IPC::ChannelProxy::Create(desktop_pipe, |
| 232 IPC::Channel::MODE_CLIENT, this, | 226 IPC::Channel::MODE_CLIENT, this, |
| 233 io_task_runner_.get()); | 227 io_task_runner_.get()); |
| 234 | 228 |
| 235 // Pass ID of the client (which is authenticated at this point) to the desktop | 229 // Pass ID of the client (which is authenticated at this point) to the desktop |
| 236 // session agent and start the agent. | 230 // session agent and start the agent. |
| 237 SendToDesktop(new ChromotingNetworkDesktopMsg_StartSessionAgent( | 231 SendToDesktop(new ChromotingNetworkDesktopMsg_StartSessionAgent( |
| 238 client_session_control_->client_jid(), | 232 client_session_control_->client_jid(), |
| 239 screen_resolution_, | 233 screen_resolution_, |
| 240 virtual_terminal_)); | 234 virtual_terminal_)); |
| 241 | 235 |
| 236 desktop_session_id_ = session_id; |
| 237 |
| 242 return true; | 238 return true; |
| 243 } | 239 } |
| 244 | 240 |
| 245 void DesktopSessionProxy::DetachFromDesktop() { | 241 void DesktopSessionProxy::DetachFromDesktop() { |
| 246 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 242 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 247 | 243 |
| 248 desktop_channel_.reset(); | 244 desktop_channel_.reset(); |
| 249 desktop_session_id_ = UINT32_MAX; | 245 desktop_session_id_ = UINT32_MAX; |
| 250 | 246 |
| 251 shared_buffers_.clear(); | 247 shared_buffers_.clear(); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 } | 529 } |
| 534 | 530 |
| 535 // static | 531 // static |
| 536 void DesktopSessionProxyTraits::Destruct( | 532 void DesktopSessionProxyTraits::Destruct( |
| 537 const DesktopSessionProxy* desktop_session_proxy) { | 533 const DesktopSessionProxy* desktop_session_proxy) { |
| 538 desktop_session_proxy->caller_task_runner_->DeleteSoon(FROM_HERE, | 534 desktop_session_proxy->caller_task_runner_->DeleteSoon(FROM_HERE, |
| 539 desktop_session_proxy); | 535 desktop_session_proxy); |
| 540 } | 536 } |
| 541 | 537 |
| 542 } // namespace remoting | 538 } // namespace remoting |
| OLD | NEW |