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

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

Issue 11040065: [Chromoting] Reimplemented the worker process launcher to take into account the encountered issues: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. Created 8 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4 //
5 // This file implements the Windows service controlling Me2Me host processes
6 // running within user sessions.
Wez 2012/10/09 03:40:39 nit: Remove this comment.
alexeypa (please no reviews) 2012/10/09 19:42:04 Done.
7
8 #include "remoting/host/win/wts_console_session_process_driver.h"
9
10 #include <sddl.h>
11 #include <limits>
12
13 #include "base/base_switches.h"
14 #include "base/bind.h"
15 #include "base/bind_helpers.h"
16 #include "base/file_path.h"
17 #include "base/logging.h"
18 #include "base/single_thread_task_runner.h"
19 #include "base/path_service.h"
20 #include "ipc/ipc_message.h"
21 #include "remoting/host/win/worker_process_launcher.h"
22 #include "remoting/host/win/wts_console_monitor.h"
23 #include "remoting/host/win/wts_session_process_delegate.h"
24
25 namespace {
26
27 const FilePath::CharType kMe2meHostBinaryName[] =
28 FILE_PATH_LITERAL("remoting_host.exe");
29
30 // The security descriptor of the daemon IPC endpoint. It gives full access
31 // to LocalSystem and denies access by anyone else.
32 const char kDaemonIpcSecurityDescriptor[] = "O:SYG:SYD:(A;;GA;;;SY)";
33
34 } // namespace
35
36 namespace remoting {
37
38 WtsConsoleSessionProcessDriver::WtsConsoleSessionProcessDriver(
39 const base::Closure& stopped_callback,
40 WtsConsoleMonitor* monitor,
41 scoped_refptr<base::SingleThreadTaskRunner> main_message_loop,
42 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner)
43 : Stoppable(main_message_loop, stopped_callback),
44 main_task_runner_(main_message_loop),
45 io_task_runner_(io_task_runner),
46 monitor_(monitor) {
47 monitor_->AddWtsConsoleObserver(this);
48 }
49
50 WtsConsoleSessionProcessDriver::~WtsConsoleSessionProcessDriver() {
Wez 2012/10/09 03:40:39 nit: Thread check
alexeypa (please no reviews) 2012/10/09 19:42:04 Done.
51 // Make sure that the object is completely stopped. The same check exists
52 // in Stoppable::~Stoppable() but this one helps us to fail early and
53 // predictably.
54 CHECK_EQ(stoppable_state(), Stoppable::kStopped);
55
56 monitor_->RemoveWtsConsoleObserver(this);
57
58 CHECK(launcher_.get() == NULL);
59 }
60
61 void WtsConsoleSessionProcessDriver::OnChannelConnected() {
62 DCHECK(main_task_runner_->BelongsToCurrentThread());
63 }
64
65 bool WtsConsoleSessionProcessDriver::OnMessageReceived(
66 const IPC::Message& message) {
67 DCHECK(main_task_runner_->BelongsToCurrentThread());
68
69 return false;
70 }
71
72 void WtsConsoleSessionProcessDriver::OnPermanentError() {
73 DCHECK(main_task_runner_->BelongsToCurrentThread());
74
75 Stop();
76 }
77
78 void WtsConsoleSessionProcessDriver::OnSessionAttached(uint32 session_id) {
79 DCHECK(main_task_runner_->BelongsToCurrentThread());
80
81 if (stoppable_state() != Stoppable::kRunning) {
82 return;
83 }
84
85 DCHECK(launcher_.get() == NULL);
86
87 // Construct the host binary name.
88 FilePath dir_path;
89 if (!PathService::Get(base::DIR_EXE, &dir_path)) {
90 LOG(ERROR) << "Failed to get the executable file name.";
91 Stop();
92 return;
93 }
94 FilePath host_binary = dir_path.Append(kMe2meHostBinaryName);
95
96 // Create the delegate knowing how to launch a process in a session.
Wez 2012/10/09 03:40:39 nit: Create a Delegate capable of launching an ele
alexeypa (please no reviews) 2012/10/09 19:42:04 Done.
97 scoped_ptr<WtsSessionProcessDelegate> delegate(
98 new WtsSessionProcessDelegate(main_task_runner_,
99 io_task_runner_,
100 host_binary,
101 session_id,
102 true));
103
104 // Create a per-session launcher that will start the host process.
Wez 2012/10/09 03:40:39 nit: Use the Delegate to launch the host process.
alexeypa (please no reviews) 2012/10/09 19:42:04 Done.
105 launcher_ = new WorkerProcessLauncher(main_task_runner_,
106 io_task_runner_,
107 delegate.Pass(),
108 this,
109 kDaemonIpcSecurityDescriptor);
110 launcher_->Start();
111 }
112
113 void WtsConsoleSessionProcessDriver::OnSessionDetached() {
114 DCHECK(main_task_runner_->BelongsToCurrentThread());
115 DCHECK(launcher_.get() != NULL);
116
117 launcher_->Stop();
118 launcher_ = NULL;
119 }
120
121 void WtsConsoleSessionProcessDriver::DoStop() {
122 DCHECK(main_task_runner_->BelongsToCurrentThread());
123
124 if (launcher_.get() != NULL) {
125 launcher_->Stop();
126 launcher_ = NULL;
127 }
128
129 CompleteStopping();
130 }
131
132 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698