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 // This file implements the Windows service controlling Me2Me host processes | 5 // This file implements the Windows service controlling Me2Me host processes |
6 // running within user sessions. | 6 // running within user sessions. |
7 | 7 |
8 #include "remoting/host/win/wts_session_process_delegate.h" | 8 #include "remoting/host/win/wts_session_process_delegate.h" |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 // base::MessagePumpForIO::IOHandler implementation. | 56 // base::MessagePumpForIO::IOHandler implementation. |
57 virtual void OnIOCompleted(base::MessagePumpForIO::IOContext* context, | 57 virtual void OnIOCompleted(base::MessagePumpForIO::IOContext* context, |
58 DWORD bytes_transferred, | 58 DWORD bytes_transferred, |
59 DWORD error) OVERRIDE; | 59 DWORD error) OVERRIDE; |
60 | 60 |
61 // IPC::Sender implementation. | 61 // IPC::Sender implementation. |
62 virtual bool Send(IPC::Message* message) OVERRIDE; | 62 virtual bool Send(IPC::Message* message) OVERRIDE; |
63 | 63 |
64 // WorkerProcessLauncher::Delegate implementation. | 64 // WorkerProcessLauncher::Delegate implementation. |
| 65 virtual void CloseChannel() OVERRIDE; |
65 virtual DWORD GetProcessId() const OVERRIDE; | 66 virtual DWORD GetProcessId() const OVERRIDE; |
66 virtual bool IsPermanentError(int failure_count) const OVERRIDE; | 67 virtual bool IsPermanentError(int failure_count) const OVERRIDE; |
67 virtual void KillProcess(DWORD exit_code) OVERRIDE; | 68 virtual void KillProcess(DWORD exit_code) OVERRIDE; |
68 virtual bool LaunchProcess( | 69 virtual bool LaunchProcess( |
69 IPC::Listener* delegate, | 70 IPC::Listener* delegate, |
70 base::win::ScopedHandle* process_exit_event_out) OVERRIDE; | 71 base::win::ScopedHandle* process_exit_event_out) OVERRIDE; |
71 | 72 |
72 // Initializes the object returning true on success. | 73 // Initializes the object returning true on success. |
73 bool Initialize(uint32 session_id); | 74 bool Initialize(uint32 session_id); |
74 | 75 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // |bytes_transferred| is used in job object notifications to supply | 167 // |bytes_transferred| is used in job object notifications to supply |
167 // the message ID; |context| carries process ID. | 168 // the message ID; |context| carries process ID. |
168 main_task_runner_->PostTask(FROM_HERE, base::Bind( | 169 main_task_runner_->PostTask(FROM_HERE, base::Bind( |
169 &Core::OnJobNotification, this, bytes_transferred, | 170 &Core::OnJobNotification, this, bytes_transferred, |
170 reinterpret_cast<DWORD>(context))); | 171 reinterpret_cast<DWORD>(context))); |
171 } | 172 } |
172 | 173 |
173 bool WtsSessionProcessDelegate::Core::Send(IPC::Message* message) { | 174 bool WtsSessionProcessDelegate::Core::Send(IPC::Message* message) { |
174 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 175 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
175 | 176 |
176 if (channel_.get()) { | 177 if (channel_) { |
177 return channel_->Send(message); | 178 return channel_->Send(message); |
178 } else { | 179 } else { |
179 delete message; | 180 delete message; |
180 return false; | 181 return false; |
181 } | 182 } |
182 } | 183 } |
183 | 184 |
| 185 void WtsSessionProcessDelegate::Core::CloseChannel() { |
| 186 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 187 |
| 188 channel_.reset(); |
| 189 pipe_.Close(); |
| 190 } |
| 191 |
184 DWORD WtsSessionProcessDelegate::Core::GetProcessId() const { | 192 DWORD WtsSessionProcessDelegate::Core::GetProcessId() const { |
185 DWORD pid = 0; | 193 DWORD pid = 0; |
186 if (launch_elevated_ && pipe_.IsValid() && | 194 if (launch_elevated_ && pipe_.IsValid() && |
187 get_named_pipe_client_pid_(pipe_, &pid)) { | 195 get_named_pipe_client_pid_(pipe_, &pid)) { |
188 return pid; | 196 return pid; |
189 } | 197 } |
190 | 198 |
191 if (worker_process_.IsValid()) | 199 if (worker_process_.IsValid()) |
192 return ::GetProcessId(worker_process_); | 200 return ::GetProcessId(worker_process_); |
193 | 201 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 if (core_) { | 497 if (core_) { |
490 core_->Stop(); | 498 core_->Stop(); |
491 core_ = NULL; | 499 core_ = NULL; |
492 } | 500 } |
493 } | 501 } |
494 | 502 |
495 bool WtsSessionProcessDelegate::Send(IPC::Message* message) { | 503 bool WtsSessionProcessDelegate::Send(IPC::Message* message) { |
496 return core_->Send(message); | 504 return core_->Send(message); |
497 } | 505 } |
498 | 506 |
| 507 void WtsSessionProcessDelegate::CloseChannel() { |
| 508 if (core_) |
| 509 core_->CloseChannel(); |
| 510 } |
| 511 |
499 DWORD WtsSessionProcessDelegate::GetProcessId() const { | 512 DWORD WtsSessionProcessDelegate::GetProcessId() const { |
500 if (!core_) | 513 if (!core_) |
501 return 0; | 514 return 0; |
502 | 515 |
503 return core_->GetProcessId(); | 516 return core_->GetProcessId(); |
504 } | 517 } |
505 | 518 |
506 bool WtsSessionProcessDelegate::IsPermanentError(int failure_count) const { | 519 bool WtsSessionProcessDelegate::IsPermanentError(int failure_count) const { |
507 if (!core_) | 520 if (!core_) |
508 return false; | 521 return false; |
509 | 522 |
510 return core_->IsPermanentError(failure_count); | 523 return core_->IsPermanentError(failure_count); |
511 } | 524 } |
512 | 525 |
513 void WtsSessionProcessDelegate::KillProcess(DWORD exit_code) { | 526 void WtsSessionProcessDelegate::KillProcess(DWORD exit_code) { |
514 if (core_) | 527 if (core_) |
515 core_->KillProcess(exit_code); | 528 core_->KillProcess(exit_code); |
516 } | 529 } |
517 | 530 |
518 bool WtsSessionProcessDelegate::LaunchProcess( | 531 bool WtsSessionProcessDelegate::LaunchProcess( |
519 IPC::Listener* delegate, | 532 IPC::Listener* delegate, |
520 base::win::ScopedHandle* process_exit_event_out) { | 533 base::win::ScopedHandle* process_exit_event_out) { |
521 if (!core_) | 534 if (!core_) |
522 return false; | 535 return false; |
523 | 536 |
524 return core_->LaunchProcess(delegate, process_exit_event_out); | 537 return core_->LaunchProcess(delegate, process_exit_event_out); |
525 } | 538 } |
526 | 539 |
527 } // namespace remoting | 540 } // namespace remoting |
OLD | NEW |