Chromium Code Reviews| 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/wts_session_process_launcher_win.h" | 8 #include "remoting/host/wts_session_process_launcher_win.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/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
| 16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/message_loop_proxy.h" | 18 #include "base/message_loop_proxy.h" |
| 19 #include "base/process_util.h" | 19 #include "base/process_util.h" |
| 20 #include "base/rand_util.h" | 20 #include "base/rand_util.h" |
| 21 #include "base/string16.h" | 21 #include "base/string16.h" |
| 22 #include "base/stringize_macros.h" | 22 #include "base/stringize_macros.h" |
| 23 #include "base/stringprintf.h" | 23 #include "base/stringprintf.h" |
| 24 #include "base/win/scoped_handle.h" | 24 #include "base/win/scoped_handle.h" |
| 25 #include "base/win/scoped_process_information.h" | 25 #include "base/win/scoped_process_information.h" |
| 26 #include "ipc/ipc_channel_proxy.h" | 26 #include "ipc/ipc_channel_proxy.h" |
| 27 #include "ipc/ipc_message.h" | 27 #include "ipc/ipc_message.h" |
| 28 #include "ipc/ipc_message_macros.h" | 28 #include "ipc/ipc_message_macros.h" |
| 29 | 29 #include "remoting/host/constants.h" |
| 30 #include "remoting/host/chromoting_messages.h" | 30 #include "remoting/host/chromoting_messages.h" |
| 31 #include "remoting/host/sas_injector.h" | 31 #include "remoting/host/sas_injector.h" |
| 32 #include "remoting/host/wts_console_monitor_win.h" | 32 #include "remoting/host/wts_console_monitor_win.h" |
| 33 | 33 |
| 34 using base::win::ScopedHandle; | 34 using base::win::ScopedHandle; |
| 35 using base::TimeDelta; | 35 using base::TimeDelta; |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 // The exit code returned by the host process when its configuration is not | |
| 40 // valid. | |
| 41 const int kInvalidHostConfigurationExitCode = 1; | |
| 42 | |
| 43 // The minimum and maximum delays between attempts to inject host process into | 39 // The minimum and maximum delays between attempts to inject host process into |
| 44 // a session. | 40 // a session. |
| 45 const int kMaxLaunchDelaySeconds = 60; | 41 const int kMaxLaunchDelaySeconds = 60; |
| 46 const int kMinLaunchDelaySeconds = 1; | 42 const int kMinLaunchDelaySeconds = 1; |
| 47 | 43 |
| 48 // Name of the default session desktop. | 44 // Name of the default session desktop. |
| 49 char16 kDefaultDesktopName[] = TO_L_STRING("winsta0\\default"); | 45 char16 kDefaultDesktopName[] = TO_L_STRING("winsta0\\default"); |
| 50 | 46 |
| 51 // Match the pipe name prefix used by Chrome IPC channels. | 47 // Match the pipe name prefix used by Chrome IPC channels. |
| 52 const char16 kChromePipeNamePrefix[] = TO_L_STRING("\\\\.\\pipe\\chrome."); | 48 const char16 kChromePipeNamePrefix[] = TO_L_STRING("\\\\.\\pipe\\chrome."); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 } | 340 } |
| 345 | 341 |
| 346 DCHECK(!timer_.IsRunning()); | 342 DCHECK(!timer_.IsRunning()); |
| 347 DCHECK(process_.handle() != NULL); | 343 DCHECK(process_.handle() != NULL); |
| 348 DCHECK(process_watcher_.GetWatchedObject() == NULL); | 344 DCHECK(process_watcher_.GetWatchedObject() == NULL); |
| 349 DCHECK(chromoting_channel_.get() != NULL); | 345 DCHECK(chromoting_channel_.get() != NULL); |
| 350 | 346 |
| 351 // Stop trying to restart the host if its process exited due to | 347 // Stop trying to restart the host if its process exited due to |
| 352 // misconfiguration. | 348 // misconfiguration. |
| 353 DWORD exit_code; | 349 DWORD exit_code; |
| 354 bool stop_trying = GetExitCodeProcess(process_.handle(), &exit_code) && | 350 bool stop_trying = GetExitCodeProcess(process_.handle(), &exit_code) && ( |
|
simonmorris
2012/04/17 00:46:43
It would be safer to put this logic in cross-platf
alexeypa (please no reviews)
2012/04/17 18:35:53
Done.
| |
| 355 exit_code == kInvalidHostConfigurationExitCode; | 351 exit_code == kInvalidHostConfigurationExitCode || |
| 352 exit_code == kInvalidHostIdExitCode); | |
| 356 | 353 |
| 357 // The host process has been terminated for some reason. The handle can now be | 354 // The host process has been terminated for some reason. The handle can now be |
| 358 // closed. | 355 // closed. |
| 359 process_.Close(); | 356 process_.Close(); |
| 360 chromoting_channel_.reset(); | 357 chromoting_channel_.reset(); |
| 361 state_ = StateStarting; | 358 state_ = StateStarting; |
| 362 | 359 |
| 363 if (stop_trying) { | 360 if (stop_trying) { |
| 364 OnSessionDetached(); | 361 OnSessionDetached(); |
| 365 | 362 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 488 process_watcher_.StopWatching(); | 485 process_watcher_.StopWatching(); |
| 489 process_.Terminate(0); | 486 process_.Terminate(0); |
| 490 process_.Close(); | 487 process_.Close(); |
| 491 chromoting_channel_.reset(); | 488 chromoting_channel_.reset(); |
| 492 state_ = StateDetached; | 489 state_ = StateDetached; |
| 493 break; | 490 break; |
| 494 } | 491 } |
| 495 } | 492 } |
| 496 | 493 |
| 497 } // namespace remoting | 494 } // namespace remoting |
| OLD | NEW |