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_win.h" | 5 #include "remoting/host/desktop_session_win.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "ipc/ipc_message_macros.h" | 10 #include "ipc/ipc_message_macros.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 | 61 |
62 void DesktopSessionWin::OnChannelConnected(int32 peer_pid) { | 62 void DesktopSessionWin::OnChannelConnected(int32 peer_pid) { |
63 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 63 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
64 | 64 |
65 // Obtain the handle of the desktop process. It will be passed to the network | 65 // Obtain the handle of the desktop process. It will be passed to the network |
66 // process so it would be able to duplicate handles of shared memory objects | 66 // process so it would be able to duplicate handles of shared memory objects |
67 // from the desktop process. | 67 // from the desktop process. |
68 desktop_process_.Set(OpenProcess(PROCESS_DUP_HANDLE, false, peer_pid)); | 68 desktop_process_.Set(OpenProcess(PROCESS_DUP_HANDLE, false, peer_pid)); |
69 if (!desktop_process_.IsValid()) { | 69 if (!desktop_process_.IsValid()) { |
70 RestartDesktopProcess(FROM_HERE); | 70 CrashDesktopProcess(FROM_HERE); |
71 return; | 71 return; |
72 } | 72 } |
73 | 73 |
74 VLOG(1) << "IPC: daemon <- desktop (" << peer_pid << ")"; | 74 VLOG(1) << "IPC: daemon <- desktop (" << peer_pid << ")"; |
75 } | 75 } |
76 | 76 |
77 bool DesktopSessionWin::OnMessageReceived(const IPC::Message& message) { | 77 bool DesktopSessionWin::OnMessageReceived(const IPC::Message& message) { |
78 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 78 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
79 | 79 |
80 bool handled = true; | 80 bool handled = true; |
81 IPC_BEGIN_MESSAGE_MAP(DesktopSessionWin, message) | 81 IPC_BEGIN_MESSAGE_MAP(DesktopSessionWin, message) |
82 IPC_MESSAGE_HANDLER(ChromotingDesktopDaemonMsg_DesktopAttached, | 82 IPC_MESSAGE_HANDLER(ChromotingDesktopDaemonMsg_DesktopAttached, |
83 OnDesktopSessionAgentAttached) | 83 OnDesktopSessionAgentAttached) |
84 IPC_MESSAGE_HANDLER(ChromotingDesktopDaemonMsg_InjectSas, | 84 IPC_MESSAGE_HANDLER(ChromotingDesktopDaemonMsg_InjectSas, |
85 OnInjectSas) | 85 OnInjectSas) |
86 IPC_MESSAGE_UNHANDLED(handled = false) | 86 IPC_MESSAGE_UNHANDLED(handled = false) |
87 IPC_END_MESSAGE_MAP() | 87 IPC_END_MESSAGE_MAP() |
88 | 88 |
89 if (!handled) { | 89 if (!handled) { |
90 LOG(ERROR) << "Received unexpected IPC type: " << message.type(); | 90 LOG(ERROR) << "Received unexpected IPC type: " << message.type(); |
91 RestartDesktopProcess(FROM_HERE); | 91 CrashDesktopProcess(FROM_HERE); |
92 } | 92 } |
93 | 93 |
94 return handled; | 94 return handled; |
95 } | 95 } |
96 | 96 |
97 void DesktopSessionWin::OnPermanentError() { | 97 void DesktopSessionWin::OnPermanentError() { |
98 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 98 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
99 | 99 |
100 launcher_.reset(); | 100 launcher_.reset(); |
101 | 101 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 DCHECK(launcher_.get() != NULL); | 136 DCHECK(launcher_.get() != NULL); |
137 | 137 |
138 launcher_.reset(); | 138 launcher_.reset(); |
139 } | 139 } |
140 | 140 |
141 void DesktopSessionWin::OnDesktopSessionAgentAttached( | 141 void DesktopSessionWin::OnDesktopSessionAgentAttached( |
142 IPC::PlatformFileForTransit desktop_pipe) { | 142 IPC::PlatformFileForTransit desktop_pipe) { |
143 if (!daemon_process()->OnDesktopSessionAgentAttached(id(), | 143 if (!daemon_process()->OnDesktopSessionAgentAttached(id(), |
144 desktop_process_, | 144 desktop_process_, |
145 desktop_pipe)) { | 145 desktop_pipe)) { |
146 RestartDesktopProcess(FROM_HERE); | 146 CrashDesktopProcess(FROM_HERE); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 void DesktopSessionWin::OnInjectSas() { | 150 void DesktopSessionWin::OnInjectSas() { |
151 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 151 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
152 | 152 |
153 // Do not try to inject SAS if the desktop process is not running. This can | 153 // Do not try to inject SAS if the desktop process is not running. This can |
154 // happen when the session has detached from the console for instance. | 154 // happen when the session has detached from the console for instance. |
155 if (!launcher_) | 155 if (!launcher_) |
156 return; | 156 return; |
157 | 157 |
158 if (!sas_injector_) | 158 if (!sas_injector_) |
159 sas_injector_ = SasInjector::Create(); | 159 sas_injector_ = SasInjector::Create(); |
160 if (!sas_injector_->InjectSas()) | 160 if (!sas_injector_->InjectSas()) |
161 LOG(ERROR) << "Failed to inject Secure Attention Sequence."; | 161 LOG(ERROR) << "Failed to inject Secure Attention Sequence."; |
162 } | 162 } |
163 | 163 |
164 void DesktopSessionWin::RestartDesktopProcess( | 164 void DesktopSessionWin::CrashDesktopProcess( |
165 const tracked_objects::Location& location) { | 165 const tracked_objects::Location& location) { |
166 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 166 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
167 | 167 |
168 launcher_->Send(new ChromotingDaemonDesktopMsg_Crash( | 168 launcher_->Crash(location); |
169 location.function_name(), location.file_name(), location.line_number())); | |
170 } | 169 } |
171 | 170 |
172 } // namespace remoting | 171 } // namespace remoting |
OLD | NEW |