Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: remoting/host/desktop_session_win.cc

Issue 11231060: [Chromoting] The desktop process now creates a pre-connected pipe and passes (with some help of the… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/host/desktop_session_win.h ('k') | remoting/host/ipc_desktop_environment.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_win.h" 5 #include "remoting/host/desktop_session_win.h"
6 6
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/single_thread_task_runner.h" 8 #include "ipc/ipc_message_macros.h"
9 #include "remoting/base/auto_thread_task_runner.h"
10 #include "remoting/host/chromoting_messages.h"
9 #include "remoting/host/daemon_process.h" 11 #include "remoting/host/daemon_process.h"
10 #include "remoting/host/win/worker_process_launcher.h" 12 #include "remoting/host/win/worker_process_launcher.h"
11 #include "remoting/host/win/wts_console_monitor.h" 13 #include "remoting/host/win/wts_console_monitor.h"
12 #include "remoting/host/win/wts_session_process_delegate.h" 14 #include "remoting/host/win/wts_session_process_delegate.h"
13 15
16 using base::win::ScopedHandle;
17
14 namespace { 18 namespace {
15 19
16 const FilePath::CharType kDesktopBinaryName[] = 20 const FilePath::CharType kDesktopBinaryName[] =
17 FILE_PATH_LITERAL("remoting_desktop.exe"); 21 FILE_PATH_LITERAL("remoting_desktop.exe");
18 22
19 // The security descriptor of the daemon IPC endpoint. It gives full access 23 // The security descriptor of the daemon IPC endpoint. It gives full access
20 // to LocalSystem and denies access by anyone else. 24 // to LocalSystem and denies access by anyone else.
21 const char kDaemonIpcSecurityDescriptor[] = "O:SYG:SYD:(A;;GA;;;SY)"; 25 const char kDaemonIpcSecurityDescriptor[] = "O:SYG:SYD:(A;;GA;;;SY)";
22 26
23 } // namespace 27 } // namespace
24 28
25 namespace remoting { 29 namespace remoting {
26 30
27 DesktopSessionWin::DesktopSessionWin( 31 DesktopSessionWin::DesktopSessionWin(
28 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 32 scoped_refptr<AutoThreadTaskRunner> main_task_runner,
29 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, 33 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
30 DaemonProcess* daemon_process, 34 DaemonProcess* daemon_process,
31 int id, 35 int id,
32 WtsConsoleMonitor* monitor) 36 WtsConsoleMonitor* monitor)
33 : DesktopSession(daemon_process, id), 37 : DesktopSession(daemon_process, id),
34 main_task_runner_(main_task_runner), 38 main_task_runner_(main_task_runner),
35 io_task_runner_(io_task_runner), 39 io_task_runner_(io_task_runner),
36 monitor_(monitor) { 40 monitor_(monitor) {
37 DCHECK(main_task_runner_->BelongsToCurrentThread()); 41 DCHECK(main_task_runner_->BelongsToCurrentThread());
38 42
39 monitor_->AddWtsConsoleObserver(this); 43 monitor_->AddWtsConsoleObserver(this);
40 } 44 }
41 45
42 DesktopSessionWin::~DesktopSessionWin() { 46 DesktopSessionWin::~DesktopSessionWin() {
43 DCHECK(main_task_runner_->BelongsToCurrentThread()); 47 DCHECK(main_task_runner_->BelongsToCurrentThread());
44 48
45 launcher_.reset(); 49 launcher_.reset();
46 monitor_->RemoveWtsConsoleObserver(this); 50 monitor_->RemoveWtsConsoleObserver(this);
47 } 51 }
48 52
49 void DesktopSessionWin::OnChannelConnected(int32 peer_pid) { 53 void DesktopSessionWin::OnChannelConnected(int32 peer_pid) {
50 DCHECK(main_task_runner_->BelongsToCurrentThread()); 54 DCHECK(main_task_runner_->BelongsToCurrentThread());
55
56 // Obtain the handle of the desktop process. It will be passed to the network
57 // process so it would be able to duplicate handles of shared memory objects
58 // from the desktop process.
59 desktop_process_.Set(OpenProcess(PROCESS_DUP_HANDLE, false, peer_pid));
60 if (!desktop_process_.IsValid()) {
61 RestartDesktopProcess(FROM_HERE);
62 return;
63 }
64
65 VLOG(1) << "IPC: daemon <- desktop (" << peer_pid << ")";
51 } 66 }
52 67
53 bool DesktopSessionWin::OnMessageReceived(const IPC::Message& message) { 68 bool DesktopSessionWin::OnMessageReceived(const IPC::Message& message) {
54 DCHECK(main_task_runner_->BelongsToCurrentThread()); 69 DCHECK(main_task_runner_->BelongsToCurrentThread());
55 70
56 // TODO(alexeypa): Process ChromotingDesktopHostMsg_Initialized messages here. 71 bool handled = true;
57 // See http://crbug.com/134694. 72 IPC_BEGIN_MESSAGE_MAP(DesktopSessionWin, message)
58 return false; 73 IPC_MESSAGE_HANDLER(ChromotingDesktopDaemonMsg_DesktopAttached,
74 OnDesktopSessionAgentAttached)
75 IPC_MESSAGE_UNHANDLED(handled = false)
76 IPC_END_MESSAGE_MAP()
77 return handled;
59 } 78 }
60 79
61 void DesktopSessionWin::OnPermanentError() { 80 void DesktopSessionWin::OnPermanentError() {
62 DCHECK(main_task_runner_->BelongsToCurrentThread()); 81 DCHECK(main_task_runner_->BelongsToCurrentThread());
63 82
64 launcher_.reset(); 83 launcher_.reset();
65 84
66 // This call will delete |this| so it should be at the very end of the method. 85 // This call will delete |this| so it should be at the very end of the method.
67 daemon_process()->CloseDesktopSession(id()); 86 daemon_process()->CloseDesktopSession(id());
68 } 87 }
(...skipping 24 matching lines...) Expand all
93 main_task_runner_, delegate.Pass(), this)); 112 main_task_runner_, delegate.Pass(), this));
94 } 113 }
95 114
96 void DesktopSessionWin::OnSessionDetached() { 115 void DesktopSessionWin::OnSessionDetached() {
97 DCHECK(main_task_runner_->BelongsToCurrentThread()); 116 DCHECK(main_task_runner_->BelongsToCurrentThread());
98 DCHECK(launcher_.get() != NULL); 117 DCHECK(launcher_.get() != NULL);
99 118
100 launcher_.reset(); 119 launcher_.reset();
101 } 120 }
102 121
122 void DesktopSessionWin::OnDesktopSessionAgentAttached(
123 IPC::PlatformFileForTransit desktop_pipe) {
124 if (!daemon_process()->OnDesktopSessionAgentAttached(id(),
125 desktop_process_,
126 desktop_pipe)) {
127 RestartDesktopProcess(FROM_HERE);
128 }
129 }
130
131 void DesktopSessionWin::RestartDesktopProcess(
132 const tracked_objects::Location& location) {
133 DCHECK(main_task_runner_->BelongsToCurrentThread());
134
135 launcher_->Send(new ChromotingDaemonDesktopMsg_Crash(
136 location.function_name(), location.file_name(), location.line_number()));
137 }
138
103 } // namespace remoting 139 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/desktop_session_win.h ('k') | remoting/host/ipc_desktop_environment.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698