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

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

Issue 12545006: The worker process launcher can now ask the worker to crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months 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
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/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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 58
59 void DesktopSessionWin::OnChannelConnected(int32 peer_pid) { 59 void DesktopSessionWin::OnChannelConnected(int32 peer_pid) {
60 DCHECK(main_task_runner_->BelongsToCurrentThread()); 60 DCHECK(main_task_runner_->BelongsToCurrentThread());
61 61
62 // Obtain the handle of the desktop process. It will be passed to the network 62 // Obtain the handle of the desktop process. It will be passed to the network
63 // process so it would be able to duplicate handles of shared memory objects 63 // process so it would be able to duplicate handles of shared memory objects
64 // from the desktop process. 64 // from the desktop process.
65 desktop_process_.Set(OpenProcess(PROCESS_DUP_HANDLE, false, peer_pid)); 65 desktop_process_.Set(OpenProcess(PROCESS_DUP_HANDLE, false, peer_pid));
66 if (!desktop_process_.IsValid()) { 66 if (!desktop_process_.IsValid()) {
67 RestartDesktopProcess(FROM_HERE); 67 CrashDesktopProcess(FROM_HERE);
68 return; 68 return;
69 } 69 }
70 70
71 VLOG(1) << "IPC: daemon <- desktop (" << peer_pid << ")"; 71 VLOG(1) << "IPC: daemon <- desktop (" << peer_pid << ")";
72 } 72 }
73 73
74 bool DesktopSessionWin::OnMessageReceived(const IPC::Message& message) { 74 bool DesktopSessionWin::OnMessageReceived(const IPC::Message& message) {
75 DCHECK(main_task_runner_->BelongsToCurrentThread()); 75 DCHECK(main_task_runner_->BelongsToCurrentThread());
76 76
77 bool handled = true; 77 bool handled = true;
78 IPC_BEGIN_MESSAGE_MAP(DesktopSessionWin, message) 78 IPC_BEGIN_MESSAGE_MAP(DesktopSessionWin, message)
79 IPC_MESSAGE_HANDLER(ChromotingDesktopDaemonMsg_DesktopAttached, 79 IPC_MESSAGE_HANDLER(ChromotingDesktopDaemonMsg_DesktopAttached,
80 OnDesktopSessionAgentAttached) 80 OnDesktopSessionAgentAttached)
81 IPC_MESSAGE_HANDLER(ChromotingDesktopDaemonMsg_InjectSas, 81 IPC_MESSAGE_HANDLER(ChromotingDesktopDaemonMsg_InjectSas,
82 OnInjectSas) 82 OnInjectSas)
83 IPC_MESSAGE_UNHANDLED(handled = false) 83 IPC_MESSAGE_UNHANDLED(handled = false)
84 IPC_END_MESSAGE_MAP() 84 IPC_END_MESSAGE_MAP()
85 85
86 if (!handled) { 86 if (!handled) {
87 LOG(ERROR) << "Received unexpected IPC type: " << message.type(); 87 LOG(ERROR) << "Received unexpected IPC type: " << message.type();
88 RestartDesktopProcess(FROM_HERE); 88 CrashDesktopProcess(FROM_HERE);
89 } 89 }
90 90
91 return handled; 91 return handled;
92 } 92 }
93 93
94 void DesktopSessionWin::OnPermanentError() { 94 void DesktopSessionWin::OnPermanentError() {
95 DCHECK(main_task_runner_->BelongsToCurrentThread()); 95 DCHECK(main_task_runner_->BelongsToCurrentThread());
96 96
97 launcher_.reset(); 97 launcher_.reset();
98 98
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 DCHECK(launcher_.get() != NULL); 133 DCHECK(launcher_.get() != NULL);
134 134
135 launcher_.reset(); 135 launcher_.reset();
136 } 136 }
137 137
138 void DesktopSessionWin::OnDesktopSessionAgentAttached( 138 void DesktopSessionWin::OnDesktopSessionAgentAttached(
139 IPC::PlatformFileForTransit desktop_pipe) { 139 IPC::PlatformFileForTransit desktop_pipe) {
140 if (!daemon_process()->OnDesktopSessionAgentAttached(id(), 140 if (!daemon_process()->OnDesktopSessionAgentAttached(id(),
141 desktop_process_, 141 desktop_process_,
142 desktop_pipe)) { 142 desktop_pipe)) {
143 RestartDesktopProcess(FROM_HERE); 143 CrashDesktopProcess(FROM_HERE);
144 } 144 }
145 } 145 }
146 146
147 void DesktopSessionWin::OnInjectSas() { 147 void DesktopSessionWin::OnInjectSas() {
148 DCHECK(main_task_runner_->BelongsToCurrentThread()); 148 DCHECK(main_task_runner_->BelongsToCurrentThread());
149 149
150 // Do not try to inject SAS if the desktop process is not running. This can 150 // Do not try to inject SAS if the desktop process is not running. This can
151 // happen when the session has detached from the console for instance. 151 // happen when the session has detached from the console for instance.
152 if (!launcher_) 152 if (!launcher_)
153 return; 153 return;
154 154
155 if (!sas_injector_) 155 if (!sas_injector_)
156 sas_injector_ = SasInjector::Create(); 156 sas_injector_ = SasInjector::Create();
157 if (!sas_injector_->InjectSas()) 157 if (!sas_injector_->InjectSas())
158 LOG(ERROR) << "Failed to inject Secure Attention Sequence."; 158 LOG(ERROR) << "Failed to inject Secure Attention Sequence.";
159 } 159 }
160 160
161 void DesktopSessionWin::RestartDesktopProcess( 161 void DesktopSessionWin::CrashDesktopProcess(
162 const tracked_objects::Location& location) { 162 const tracked_objects::Location& location) {
163 DCHECK(main_task_runner_->BelongsToCurrentThread()); 163 DCHECK(main_task_runner_->BelongsToCurrentThread());
164 164
165 launcher_->Send(new ChromotingDaemonDesktopMsg_Crash( 165 launcher_->Crash(location);
166 location.function_name(), location.file_name(), location.line_number()));
167 } 166 }
168 167
169 } // namespace remoting 168 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698