| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 DCHECK(!desktop_process_.IsValid()); | 214 DCHECK(!desktop_process_.IsValid()); |
| 215 | 215 |
| 216 // Ignore the attach notification if the client session has been disconnected | 216 // Ignore the attach notification if the client session has been disconnected |
| 217 // already. | 217 // already. |
| 218 if (!client_session_control_.get()) | 218 if (!client_session_control_.get()) |
| 219 return false; | 219 return false; |
| 220 | 220 |
| 221 desktop_process_ = std::move(desktop_process); | 221 desktop_process_ = std::move(desktop_process); |
| 222 | 222 |
| 223 #if defined(OS_WIN) | 223 #if defined(OS_WIN) |
| 224 // On Windows: |desktop_process| is a valid handle, but |desktop_pipe| needs | 224 base::win::ScopedHandle pipe(desktop_pipe.GetHandle()); |
| 225 // to be duplicated from the desktop process. | |
| 226 HANDLE temp_handle; | |
| 227 if (!DuplicateHandle(desktop_process_.Handle(), desktop_pipe, | |
| 228 GetCurrentProcess(), &temp_handle, 0, | |
| 229 FALSE, DUPLICATE_SAME_ACCESS)) { | |
| 230 PLOG(ERROR) << "Failed to duplicate the desktop-to-network pipe handle"; | |
| 231 | |
| 232 desktop_process_.Close(); | |
| 233 return false; | |
| 234 } | |
| 235 base::win::ScopedHandle pipe(temp_handle); | |
| 236 | |
| 237 IPC::ChannelHandle desktop_channel_handle(pipe.Get()); | 225 IPC::ChannelHandle desktop_channel_handle(pipe.Get()); |
| 238 | |
| 239 #elif defined(OS_POSIX) | 226 #elif defined(OS_POSIX) |
| 240 // On posix: |desktop_pipe| is a valid file descriptor. | 227 // On posix: |desktop_pipe| is a valid file descriptor. |
| 241 DCHECK(desktop_pipe.auto_close); | 228 DCHECK(desktop_pipe.auto_close); |
| 242 | 229 |
| 243 IPC::ChannelHandle desktop_channel_handle(std::string(), desktop_pipe); | 230 IPC::ChannelHandle desktop_channel_handle(std::string(), desktop_pipe); |
| 244 | |
| 245 #else | 231 #else |
| 246 #error Unsupported platform. | 232 #error Unsupported platform. |
| 247 #endif | 233 #endif |
| 248 | 234 |
| 249 // Connect to the desktop process. | 235 // Connect to the desktop process. |
| 250 desktop_channel_ = IPC::ChannelProxy::Create(desktop_channel_handle, | 236 desktop_channel_ = IPC::ChannelProxy::Create(desktop_channel_handle, |
| 251 IPC::Channel::MODE_CLIENT, this, | 237 IPC::Channel::MODE_CLIENT, this, |
| 252 io_task_runner_.get()); | 238 io_task_runner_.get()); |
| 253 | 239 |
| 254 // Pass ID of the client (which is authenticated at this point) to the desktop | 240 // Pass ID of the client (which is authenticated at this point) to the desktop |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 } | 526 } |
| 541 | 527 |
| 542 // static | 528 // static |
| 543 void DesktopSessionProxyTraits::Destruct( | 529 void DesktopSessionProxyTraits::Destruct( |
| 544 const DesktopSessionProxy* desktop_session_proxy) { | 530 const DesktopSessionProxy* desktop_session_proxy) { |
| 545 desktop_session_proxy->caller_task_runner_->DeleteSoon(FROM_HERE, | 531 desktop_session_proxy->caller_task_runner_->DeleteSoon(FROM_HERE, |
| 546 desktop_session_proxy); | 532 desktop_session_proxy); |
| 547 } | 533 } |
| 548 | 534 |
| 549 } // namespace remoting | 535 } // namespace remoting |
| OLD | NEW |