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

Side by Side Diff: remoting/host/win/wts_session_process_delegate.cc

Issue 1634933007: remoting: Add AttachmentBroker for daemon and desktop processes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « remoting/host/win/unprivileged_process_delegate.cc ('k') | no next file » | 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 // 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 <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "base/thread_task_runner_handle.h" 20 #include "base/thread_task_runner_handle.h"
21 #include "base/win/scoped_handle.h" 21 #include "base/win/scoped_handle.h"
22 #include "base/win/windows_version.h" 22 #include "base/win/windows_version.h"
23 #include "ipc/attachment_broker.h"
23 #include "ipc/ipc_channel.h" 24 #include "ipc/ipc_channel.h"
24 #include "ipc/ipc_channel_proxy.h" 25 #include "ipc/ipc_channel_proxy.h"
25 #include "ipc/ipc_listener.h" 26 #include "ipc/ipc_listener.h"
26 #include "ipc/ipc_message.h" 27 #include "ipc/ipc_message.h"
27 #include "remoting/host/host_main.h" 28 #include "remoting/host/host_main.h"
28 #include "remoting/host/ipc_constants.h" 29 #include "remoting/host/ipc_constants.h"
29 #include "remoting/host/ipc_util.h" 30 #include "remoting/host/ipc_util.h"
30 #include "remoting/host/switches.h" 31 #include "remoting/host/switches.h"
31 #include "remoting/host/win/launch_process_with_token.h" 32 #include "remoting/host/win/launch_process_with_token.h"
32 #include "remoting/host/win/worker_process_launcher.h" 33 #include "remoting/host/win/worker_process_launcher.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 if (channel_) { 238 if (channel_) {
238 channel_->Send(message); 239 channel_->Send(message);
239 } else { 240 } else {
240 delete message; 241 delete message;
241 } 242 }
242 } 243 }
243 244
244 void WtsSessionProcessDelegate::Core::CloseChannel() { 245 void WtsSessionProcessDelegate::Core::CloseChannel() {
245 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 246 DCHECK(caller_task_runner_->BelongsToCurrentThread());
246 247
248 if (!channel_)
249 return;
250
251 IPC::AttachmentBroker::GetGlobal()->DeregisterCommunicationChannel(
252 channel_.get());
247 channel_.reset(); 253 channel_.reset();
248 pipe_.Close(); 254 pipe_.Close();
249 } 255 }
250 256
251 void WtsSessionProcessDelegate::Core::KillProcess() { 257 void WtsSessionProcessDelegate::Core::KillProcess() {
252 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 258 DCHECK(caller_task_runner_->BelongsToCurrentThread());
253 259
254 channel_.reset(); 260 CloseChannel();
261
255 event_handler_ = nullptr; 262 event_handler_ = nullptr;
256 launch_pending_ = false; 263 launch_pending_ = false;
257 pipe_.Close();
258 264
259 if (launch_elevated_) { 265 if (launch_elevated_) {
260 if (job_.IsValid()) 266 if (job_.IsValid())
261 TerminateJobObject(job_.Get(), CONTROL_C_EXIT); 267 TerminateJobObject(job_.Get(), CONTROL_C_EXIT);
262 } else { 268 } else {
263 if (worker_process_.IsValid()) 269 if (worker_process_.IsValid())
264 TerminateProcess(worker_process_.Get(), CONTROL_C_EXIT); 270 TerminateProcess(worker_process_.Get(), CONTROL_C_EXIT);
265 } 271 }
266 272
267 worker_process_.Close(); 273 worker_process_.Close();
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 419
414 if (!ResumeThread(worker_thread.Get())) { 420 if (!ResumeThread(worker_thread.Get())) {
415 PLOG(ERROR) << "Failed to resume the worker thread"; 421 PLOG(ERROR) << "Failed to resume the worker thread";
416 ReportFatalError(); 422 ReportFatalError();
417 return; 423 return;
418 } 424 }
419 425
420 channel_ = std::move(channel); 426 channel_ = std::move(channel);
421 pipe_ = std::move(pipe); 427 pipe_ = std::move(pipe);
422 428
429 IPC::AttachmentBroker::GetGlobal()->RegisterCommunicationChannel(
430 channel_.get());
431
423 // Report success if the worker process is lauched directly. Otherwise, PID of 432 // Report success if the worker process is lauched directly. Otherwise, PID of
424 // the client connected to the pipe will be used later. See 433 // the client connected to the pipe will be used later. See
425 // OnChannelConnected(). 434 // OnChannelConnected().
426 if (!launch_elevated_) 435 if (!launch_elevated_)
427 ReportProcessLaunched(std::move(worker_process)); 436 ReportProcessLaunched(std::move(worker_process));
428 } 437 }
429 438
430 void WtsSessionProcessDelegate::Core::DrainJobNotifications() { 439 void WtsSessionProcessDelegate::Core::DrainJobNotifications() {
431 DCHECK(io_task_runner_->BelongsToCurrentThread()); 440 DCHECK(io_task_runner_->BelongsToCurrentThread());
432 441
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 if (launch_pending_) { 489 if (launch_pending_) {
481 LOG(ERROR) << "The worker process exited before connecting via IPC."; 490 LOG(ERROR) << "The worker process exited before connecting via IPC.";
482 launch_pending_ = false; 491 launch_pending_ = false;
483 ReportFatalError(); 492 ReportFatalError();
484 } 493 }
485 } 494 }
486 495
487 void WtsSessionProcessDelegate::Core::ReportFatalError() { 496 void WtsSessionProcessDelegate::Core::ReportFatalError() {
488 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 497 DCHECK(caller_task_runner_->BelongsToCurrentThread());
489 498
490 channel_.reset(); 499 CloseChannel();
491 pipe_.Close();
492 500
493 WorkerProcessLauncher* event_handler = event_handler_; 501 WorkerProcessLauncher* event_handler = event_handler_;
494 event_handler_ = nullptr; 502 event_handler_ = nullptr;
495 event_handler->OnFatalError(); 503 event_handler->OnFatalError();
496 } 504 }
497 505
498 void WtsSessionProcessDelegate::Core::ReportProcessLaunched( 506 void WtsSessionProcessDelegate::Core::ReportProcessLaunched(
499 base::win::ScopedHandle worker_process) { 507 base::win::ScopedHandle worker_process) {
500 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 508 DCHECK(caller_task_runner_->BelongsToCurrentThread());
501 DCHECK(!worker_process_.IsValid()); 509 DCHECK(!worker_process_.IsValid());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 555
548 void WtsSessionProcessDelegate::CloseChannel() { 556 void WtsSessionProcessDelegate::CloseChannel() {
549 core_->CloseChannel(); 557 core_->CloseChannel();
550 } 558 }
551 559
552 void WtsSessionProcessDelegate::KillProcess() { 560 void WtsSessionProcessDelegate::KillProcess() {
553 core_->KillProcess(); 561 core_->KillProcess();
554 } 562 }
555 563
556 } // namespace remoting 564 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/win/unprivileged_process_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698