diff options
author | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-17 21:06:24 +0000 |
---|---|---|
committer | alexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-17 21:06:24 +0000 |
commit | 60ccc243dfbfc86001cf1c0a4b44131a39d7d28d (patch) | |
tree | 8834337b7ad8eec985fd783d382734c5d9388eed /remoting/host/desktop_session_win.cc | |
parent | f05d582b7e213b15138697c01abf48c652ff271a (diff) | |
download | chromium_src-60ccc243dfbfc86001cf1c0a4b44131a39d7d28d.zip chromium_src-60ccc243dfbfc86001cf1c0a4b44131a39d7d28d.tar.gz chromium_src-60ccc243dfbfc86001cf1c0a4b44131a39d7d28d.tar.bz2 |
[Chromoting] Added support of a list of desktop sessions on the daemon side.
DaemonProcess object keeps a list of active desktop sessions, each representing the screen, input devices, etc to be remoted to another machine. The network process is expected to request a desktop session to be opened once a connection has been accepted and closed when the client session is destroyed. This CL includes changes on the daemon side only.
BUG=134694
Review URL: https://chromiumcodereview.appspot.com/11017065
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162520 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/desktop_session_win.cc')
-rw-r--r-- | remoting/host/desktop_session_win.cc | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/remoting/host/desktop_session_win.cc b/remoting/host/desktop_session_win.cc new file mode 100644 index 0000000..6224c3d --- /dev/null +++ b/remoting/host/desktop_session_win.cc @@ -0,0 +1,103 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "remoting/host/desktop_session_win.h" + +#include "base/path_service.h" +#include "base/single_thread_task_runner.h" +#include "remoting/host/daemon_process.h" +#include "remoting/host/win/worker_process_launcher.h" +#include "remoting/host/win/wts_console_monitor.h" +#include "remoting/host/win/wts_session_process_delegate.h" + +namespace { + +const FilePath::CharType kDesktopBinaryName[] = + FILE_PATH_LITERAL("remoting_desktop.exe"); + +// The security descriptor of the daemon IPC endpoint. It gives full access +// to LocalSystem and denies access by anyone else. +const char kDaemonIpcSecurityDescriptor[] = "O:SYG:SYD:(A;;GA;;;SY)"; + +} // namespace + +namespace remoting { + +DesktopSessionWin::DesktopSessionWin( + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, + scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, + DaemonProcess* daemon_process, + int id, + WtsConsoleMonitor* monitor) + : DesktopSession(daemon_process, id), + main_task_runner_(main_task_runner), + io_task_runner_(io_task_runner), + monitor_(monitor) { + DCHECK(main_task_runner_->BelongsToCurrentThread()); + + monitor_->AddWtsConsoleObserver(this); +} + +DesktopSessionWin::~DesktopSessionWin() { + DCHECK(main_task_runner_->BelongsToCurrentThread()); + + launcher_.reset(); + monitor_->RemoveWtsConsoleObserver(this); +} + +void DesktopSessionWin::OnChannelConnected() { + DCHECK(main_task_runner_->BelongsToCurrentThread()); +} + +bool DesktopSessionWin::OnMessageReceived(const IPC::Message& message) { + DCHECK(main_task_runner_->BelongsToCurrentThread()); + + // TODO(alexeypa): Process ChromotingDesktopHostMsg_Initialized messages here. + // See http://crbug.com/134694. + return false; +} + +void DesktopSessionWin::OnPermanentError() { + DCHECK(main_task_runner_->BelongsToCurrentThread()); + + launcher_.reset(); + + // This call will delete |this| so it should be at the very end of the method. + daemon_process()->CloseDesktopSession(id()); +} + +void DesktopSessionWin::OnSessionAttached(uint32 session_id) { + DCHECK(main_task_runner_->BelongsToCurrentThread()); + DCHECK(launcher_.get() == NULL); + + // Construct the host binary name. + if (desktop_binary_.empty()) { + FilePath dir_path; + if (!PathService::Get(base::DIR_EXE, &dir_path)) { + LOG(ERROR) << "Failed to get the executable file name."; + OnPermanentError(); + return; + } + desktop_binary_ = dir_path.Append(kDesktopBinaryName); + } + + // Create a delegate to launch a process into the session. + scoped_ptr<WtsSessionProcessDelegate> delegate( + new WtsSessionProcessDelegate(main_task_runner_, io_task_runner_, + desktop_binary_, session_id, + true, kDaemonIpcSecurityDescriptor)); + + // Create a launcher for the desktop process, using the per-session delegate. + launcher_.reset(new WorkerProcessLauncher( + main_task_runner_, delegate.Pass(), this)); +} + +void DesktopSessionWin::OnSessionDetached() { + DCHECK(main_task_runner_->BelongsToCurrentThread()); + DCHECK(launcher_.get() != NULL); + + launcher_.reset(); +} + +} // namespace remoting |