| 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/host_service_win.h" | 8 #include "remoting/host/host_service_win.h" |
| 9 | 9 |
| 10 #include <windows.h> | 10 #include <windows.h> |
| 11 #include <wtsapi32.h> | 11 #include <wtsapi32.h> |
| 12 #include <stdio.h> | 12 #include <stdio.h> |
| 13 | 13 |
| 14 #include "base/at_exit.h" | 14 #include "base/at_exit.h" |
| 15 #include "base/base_paths.h" | 15 #include "base/base_paths.h" |
| 16 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 19 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "base/message_loop.h" | 20 #include "base/message_loop.h" |
| 21 #include "base/path_service.h" | 21 #include "base/path_service.h" |
| 22 #include "base/stringize_macros.h" | |
| 23 #include "base/stringprintf.h" | 22 #include "base/stringprintf.h" |
| 24 #include "base/threading/thread.h" | 23 #include "base/threading/thread.h" |
| 24 #include "base/utf_string_conversions.h" |
| 25 #include "base/win/wrapped_window_proc.h" | 25 #include "base/win/wrapped_window_proc.h" |
| 26 #include "remoting/base/breakpad.h" | 26 #include "remoting/base/breakpad.h" |
| 27 #include "remoting/base/scoped_sc_handle_win.h" | 27 #include "remoting/base/scoped_sc_handle_win.h" |
| 28 #include "remoting/host/branding.h" | 28 #include "remoting/host/branding.h" |
| 29 #include "remoting/host/host_service_resource.h" | 29 #include "remoting/host/host_service_resource.h" |
| 30 #include "remoting/host/usage_stats_consent.h" | 30 #include "remoting/host/usage_stats_consent.h" |
| 31 #include "remoting/host/wts_console_observer_win.h" | 31 #include "remoting/host/wts_console_observer_win.h" |
| 32 #include "remoting/host/wts_session_process_launcher_win.h" | 32 #include "remoting/host/wts_session_process_launcher_win.h" |
| 33 | 33 |
| 34 using base::StringPrintf; | 34 using base::StringPrintf; |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 // Session id that does not represent any session. | 38 // Session id that does not represent any session. |
| 39 const uint32 kInvalidSession = 0xffffffff; | 39 const uint32 kInvalidSession = 0xffffffff; |
| 40 | 40 |
| 41 const char kIoThreadName[] = "I/O thread"; | 41 const char kIoThreadName[] = "I/O thread"; |
| 42 | 42 |
| 43 // A window class for the session change notifications window. | 43 // A window class for the session change notifications window. |
| 44 const char16 kSessionNotificationWindowClass[] = | 44 const wchar_t kSessionNotificationWindowClass[] = |
| 45 TO_L_STRING("Chromoting_SessionNotificationWindow"); | 45 L"Chromoting_SessionNotificationWindow"; |
| 46 | 46 |
| 47 // Command line actions and switches: | 47 // Command line actions and switches: |
| 48 // "run" sumply runs the service as usual. | 48 // "run" sumply runs the service as usual. |
| 49 const char16 kRunActionName[] = TO_L_STRING("run"); | 49 const wchar_t kRunActionName[] = L"run"; |
| 50 | 50 |
| 51 // "--console" runs the service interactively for debugging purposes. | 51 // "--console" runs the service interactively for debugging purposes. |
| 52 const char kConsoleSwitchName[] = "console"; | 52 const char kConsoleSwitchName[] = "console"; |
| 53 | 53 |
| 54 // "--host-binary" specifies the host binary to run in console session. | 54 // "--host-binary" specifies the host binary to run in console session. |
| 55 const char kHostBinarySwitchName[] = "host-binary"; | 55 const char kHostBinarySwitchName[] = "host-binary"; |
| 56 | 56 |
| 57 // "--help" or "--?" prints the usage message. | 57 // "--help" or "--?" prints the usage message. |
| 58 const char kHelpSwitchName[] = "help"; | 58 const char kHelpSwitchName[] = "help"; |
| 59 const char kQuestionSwitchName[] = "?"; | 59 const char kQuestionSwitchName[] = "?"; |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 if (!SetConsoleCtrlHandler(&HostService::ConsoleControlHandler, TRUE)) { | 251 if (!SetConsoleCtrlHandler(&HostService::ConsoleControlHandler, TRUE)) { |
| 252 LOG_GETLASTERROR(ERROR) | 252 LOG_GETLASTERROR(ERROR) |
| 253 << "Failed to set console control handler"; | 253 << "Failed to set console control handler"; |
| 254 return result; | 254 return result; |
| 255 } | 255 } |
| 256 | 256 |
| 257 // Create a window for receiving session change notifications. | 257 // Create a window for receiving session change notifications. |
| 258 HWND window = NULL; | 258 HWND window = NULL; |
| 259 WNDCLASSEX window_class; | 259 WNDCLASSEX window_class; |
| 260 base::win::InitializeWindowClass( | 260 base::win::InitializeWindowClass( |
| 261 kSessionNotificationWindowClass, | 261 WideToUTF16(kSessionNotificationWindowClass).c_str(), |
| 262 &base::win::WrappedWindowProc<SessionChangeNotificationProc>, | 262 &base::win::WrappedWindowProc<SessionChangeNotificationProc>, |
| 263 0, 0, 0, NULL, NULL, NULL, NULL, NULL, | 263 0, 0, 0, NULL, NULL, NULL, NULL, NULL, |
| 264 &window_class); | 264 &window_class); |
| 265 HINSTANCE instance = window_class.hInstance; | 265 HINSTANCE instance = window_class.hInstance; |
| 266 ATOM atom = RegisterClassExW(&window_class); | 266 ATOM atom = RegisterClassExW(&window_class); |
| 267 if (atom == 0) { | 267 if (atom == 0) { |
| 268 LOG_GETLASTERROR(ERROR) | 268 LOG_GETLASTERROR(ERROR) |
| 269 << "Failed to register the window class '" | 269 << "Failed to register the window class '" |
| 270 << kSessionNotificationWindowClass << "'"; | 270 << kSessionNotificationWindowClass << "'"; |
| 271 goto cleanup; | 271 goto cleanup; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 } | 439 } |
| 440 | 440 |
| 441 remoting::HostService* service = remoting::HostService::GetInstance(); | 441 remoting::HostService* service = remoting::HostService::GetInstance(); |
| 442 if (!service->InitWithCommandLine(command_line)) { | 442 if (!service->InitWithCommandLine(command_line)) { |
| 443 usage(argv[0]); | 443 usage(argv[0]); |
| 444 return kUsageExitCode; | 444 return kUsageExitCode; |
| 445 } | 445 } |
| 446 | 446 |
| 447 return service->Run(); | 447 return service->Run(); |
| 448 } | 448 } |
| OLD | NEW |