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

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

Issue 10832054: Removing --host-binary parameter in preparation to the coming me2me host refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 4 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
« no previous file with comments | « remoting/host/win/wts_session_process_launcher.h ('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_launcher.h" 8 #include "remoting/host/win/wts_session_process_launcher.h"
9 9
10 #include <windows.h> 10 #include <windows.h>
11 #include <sddl.h> 11 #include <sddl.h>
12 #include <limits> 12 #include <limits>
13 13
14 #include "base/base_switches.h" 14 #include "base/base_switches.h"
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/bind_helpers.h" 16 #include "base/bind_helpers.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/file_path.h"
19 #include "base/file_util.h"
18 #include "base/logging.h" 20 #include "base/logging.h"
19 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
22 #include "base/path_service.h"
20 #include "base/process_util.h" 23 #include "base/process_util.h"
21 #include "base/rand_util.h" 24 #include "base/rand_util.h"
22 #include "base/stringprintf.h" 25 #include "base/stringprintf.h"
23 #include "base/win/scoped_handle.h" 26 #include "base/win/scoped_handle.h"
24 #include "ipc/ipc_channel_proxy.h" 27 #include "ipc/ipc_channel_proxy.h"
25 #include "ipc/ipc_message.h" 28 #include "ipc/ipc_message.h"
26 #include "ipc/ipc_message_macros.h" 29 #include "ipc/ipc_message_macros.h"
27 #include "remoting/host/constants.h" 30 #include "remoting/host/constants.h"
28 #include "remoting/host/chromoting_messages.h" 31 #include "remoting/host/chromoting_messages.h"
29 #include "remoting/host/sas_injector.h" 32 #include "remoting/host/sas_injector.h"
30 #include "remoting/host/win/launch_process_with_token.h" 33 #include "remoting/host/win/launch_process_with_token.h"
31 #include "remoting/host/win/wts_console_monitor.h" 34 #include "remoting/host/win/wts_console_monitor.h"
32 35
33 using base::win::ScopedHandle; 36 using base::win::ScopedHandle;
34 using base::TimeDelta; 37 using base::TimeDelta;
35 38
36 namespace { 39 namespace {
37 40
38 // The minimum and maximum delays between attempts to inject host process into 41 // The minimum and maximum delays between attempts to inject host process into
39 // a session. 42 // a session.
40 const int kMaxLaunchDelaySeconds = 60; 43 const int kMaxLaunchDelaySeconds = 60;
41 const int kMinLaunchDelaySeconds = 1; 44 const int kMinLaunchDelaySeconds = 1;
42 45
46 const FilePath::CharType kMe2meHostBinaryName[] =
47 FILE_PATH_LITERAL("remoting_me2me_host.exe");
48
43 // Match the pipe name prefix used by Chrome IPC channels. 49 // Match the pipe name prefix used by Chrome IPC channels.
44 const wchar_t kChromePipeNamePrefix[] = L"\\\\.\\pipe\\chrome."; 50 const wchar_t kChromePipeNamePrefix[] = L"\\\\.\\pipe\\chrome.";
45 51
46 // The IPC channel name is passed to the host in the command line. 52 // The IPC channel name is passed to the host in the command line.
47 const char kChromotingIpcSwitchName[] = "chromoting-ipc"; 53 const char kChromotingIpcSwitchName[] = "chromoting-ipc";
48 54
49 // The command line parameters that should be copied from the service's command 55 // The command line parameters that should be copied from the service's command
50 // line to the host process. 56 // line to the host process.
51 const char* kCopiedSwitchNames[] = { 57 const char* kCopiedSwitchNames[] = {
52 "auth-config", "host-config", switches::kV, switches::kVModule }; 58 "auth-config", "host-config", switches::kV, switches::kVModule };
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } // namespace 213 } // namespace
208 214
209 namespace remoting { 215 namespace remoting {
210 216
211 // Session id that does not represent any session. 217 // Session id that does not represent any session.
212 const uint32 kInvalidSessionId = 0xffffffff; 218 const uint32 kInvalidSessionId = 0xffffffff;
213 219
214 WtsSessionProcessLauncher::WtsSessionProcessLauncher( 220 WtsSessionProcessLauncher::WtsSessionProcessLauncher(
215 const base::Closure& stopped_callback, 221 const base::Closure& stopped_callback,
216 WtsConsoleMonitor* monitor, 222 WtsConsoleMonitor* monitor,
217 const FilePath& host_binary,
218 scoped_refptr<base::SingleThreadTaskRunner> main_message_loop, 223 scoped_refptr<base::SingleThreadTaskRunner> main_message_loop,
219 scoped_refptr<base::SingleThreadTaskRunner> ipc_message_loop) 224 scoped_refptr<base::SingleThreadTaskRunner> ipc_message_loop)
220 : Stoppable(main_message_loop, stopped_callback), 225 : Stoppable(main_message_loop, stopped_callback),
221 host_binary_(host_binary),
222 main_message_loop_(main_message_loop), 226 main_message_loop_(main_message_loop),
223 ipc_message_loop_(ipc_message_loop), 227 ipc_message_loop_(ipc_message_loop),
224 monitor_(monitor), 228 monitor_(monitor),
225 state_(StateDetached) { 229 state_(StateDetached) {
226 monitor_->AddWtsConsoleObserver(this); 230 monitor_->AddWtsConsoleObserver(this);
227 } 231 }
228 232
229 WtsSessionProcessLauncher::~WtsSessionProcessLauncher() { 233 WtsSessionProcessLauncher::~WtsSessionProcessLauncher() {
230 monitor_->RemoveWtsConsoleObserver(this); 234 monitor_->RemoveWtsConsoleObserver(this);
231 if (state_ != StateDetached) { 235 if (state_ != StateDetached) {
(...skipping 10 matching lines...) Expand all
242 void WtsSessionProcessLauncher::LaunchProcess() { 246 void WtsSessionProcessLauncher::LaunchProcess() {
243 DCHECK(main_message_loop_->BelongsToCurrentThread()); 247 DCHECK(main_message_loop_->BelongsToCurrentThread());
244 DCHECK(state_ == StateStarting); 248 DCHECK(state_ == StateStarting);
245 DCHECK(!timer_.IsRunning()); 249 DCHECK(!timer_.IsRunning());
246 DCHECK(process_.handle() == NULL); 250 DCHECK(process_.handle() == NULL);
247 DCHECK(process_watcher_.GetWatchedObject() == NULL); 251 DCHECK(process_watcher_.GetWatchedObject() == NULL);
248 DCHECK(chromoting_channel_.get() == NULL); 252 DCHECK(chromoting_channel_.get() == NULL);
249 253
250 launch_time_ = base::Time::Now(); 254 launch_time_ = base::Time::Now();
251 255
256 // Construct the host binary name.
257 FilePath dir_path;
258 if (!PathService::Get(base::DIR_EXE, &dir_path)) {
259 LOG(ERROR) << "Failed to get the executable file name.";
260 Stop();
261 return;
262 }
263 FilePath host_binary = dir_path.Append(kMe2meHostBinaryName);
264
252 std::wstring channel_name; 265 std::wstring channel_name;
253 ScopedHandle pipe; 266 ScopedHandle pipe;
254 if (CreatePipeForIpcChannel(this, &channel_name, &pipe)) { 267 if (CreatePipeForIpcChannel(this, &channel_name, &pipe)) {
255 // Wrap the pipe into an IPC channel. 268 // Wrap the pipe into an IPC channel.
256 chromoting_channel_.reset(new IPC::ChannelProxy( 269 chromoting_channel_.reset(new IPC::ChannelProxy(
257 IPC::ChannelHandle(pipe.Get()), 270 IPC::ChannelHandle(pipe.Get()),
258 IPC::Channel::MODE_SERVER, 271 IPC::Channel::MODE_SERVER,
259 this, 272 this,
260 ipc_message_loop_)); 273 ipc_message_loop_));
261 274
262 // Create the host process command line passing the name of the IPC channel 275 // Create the host process command line passing the name of the IPC channel
263 // to use and copying known switches from the service's command line. 276 // to use and copying known switches from the service's command line.
264 CommandLine command_line(host_binary_); 277 CommandLine command_line(host_binary);
265 command_line.AppendSwitchNative(kChromotingIpcSwitchName, channel_name); 278 command_line.AppendSwitchNative(kChromotingIpcSwitchName, channel_name);
266 command_line.CopySwitchesFrom(*CommandLine::ForCurrentProcess(), 279 command_line.CopySwitchesFrom(*CommandLine::ForCurrentProcess(),
267 kCopiedSwitchNames, 280 kCopiedSwitchNames,
268 _countof(kCopiedSwitchNames)); 281 _countof(kCopiedSwitchNames));
269 282
270 // Try to launch the process and attach an object watcher to the returned 283 // Try to launch the process and attach an object watcher to the returned
271 // handle so that we get notified when the process terminates. 284 // handle so that we get notified when the process terminates.
272 if (LaunchProcessWithToken(host_binary_, 285 if (LaunchProcessWithToken(host_binary,
273 command_line.GetCommandLineString(), 286 command_line.GetCommandLineString(),
274 session_token_, 287 session_token_,
275 &process_)) { 288 &process_)) {
276 if (process_watcher_.StartWatching(process_.handle(), this)) { 289 if (process_watcher_.StartWatching(process_.handle(), this)) {
277 state_ = StateAttached; 290 state_ = StateAttached;
278 return; 291 return;
279 } else { 292 } else {
280 LOG(ERROR) << "Failed to arm the process watcher."; 293 LOG(ERROR) << "Failed to arm the process watcher.";
281 process_.Terminate(0); 294 process_.Terminate(0);
282 process_.Close(); 295 process_.Close();
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 482
470 void WtsSessionProcessLauncher::DoStop() { 483 void WtsSessionProcessLauncher::DoStop() {
471 if (state_ != StateDetached) { 484 if (state_ != StateDetached) {
472 OnSessionDetached(); 485 OnSessionDetached();
473 } 486 }
474 487
475 CompleteStopping(); 488 CompleteStopping();
476 } 489 }
477 490
478 } // namespace remoting 491 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/win/wts_session_process_launcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698