| 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 #ifndef REMOTING_HOST_HOST_SERVICE_WIN_H_ | 5 #ifndef REMOTING_HOST_HOST_SERVICE_WIN_H_ |
| 6 #define REMOTING_HOST_HOST_SERVICE_WIN_H_ | 6 #define REMOTING_HOST_HOST_SERVICE_WIN_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
| 12 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 13 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 14 | |
| 15 #include "remoting/host/wts_console_monitor_win.h" | 15 #include "remoting/host/wts_console_monitor_win.h" |
| 16 | 16 |
| 17 class CommandLine; | 17 class CommandLine; |
| 18 class MessageLoop; | 18 class MessageLoop; |
| 19 | 19 |
| 20 namespace base { |
| 21 class SingleThreadTaskRunner; |
| 22 } // namespace base |
| 23 |
| 20 namespace remoting { | 24 namespace remoting { |
| 21 | 25 |
| 26 class Shutdownable; |
| 22 class WtsConsoleObserver; | 27 class WtsConsoleObserver; |
| 28 class WtsSessionProcessLauncher; |
| 23 | 29 |
| 24 class HostService : public WtsConsoleMonitor { | 30 class HostService : public WtsConsoleMonitor { |
| 25 public: | 31 public: |
| 26 static HostService* GetInstance(); | 32 static HostService* GetInstance(); |
| 27 | 33 |
| 28 // This function parses the command line and selects the action routine. | 34 // This function parses the command line and selects the action routine. |
| 29 bool InitWithCommandLine(const CommandLine* command_line); | 35 bool InitWithCommandLine(const CommandLine* command_line); |
| 30 | 36 |
| 31 // Invoke the choosen action routine. | 37 // Invoke the choosen action routine. |
| 32 int Run(); | 38 int Run(); |
| 33 | 39 |
| 34 // WtsConsoleMonitor implementation | 40 // WtsConsoleMonitor implementation |
| 35 virtual void AddWtsConsoleObserver(WtsConsoleObserver* observer) OVERRIDE; | 41 virtual void AddWtsConsoleObserver(WtsConsoleObserver* observer) OVERRIDE; |
| 36 virtual void RemoveWtsConsoleObserver( | 42 virtual void RemoveWtsConsoleObserver( |
| 37 WtsConsoleObserver* observer) OVERRIDE; | 43 WtsConsoleObserver* observer) OVERRIDE; |
| 38 | 44 |
| 39 private: | 45 private: |
| 40 HostService(); | 46 HostService(); |
| 41 ~HostService(); | 47 ~HostService(); |
| 42 | 48 |
| 49 void OnLauncherShutdown(Shutdownable* launcher); |
| 50 |
| 43 // Notifies the service of changes in session state. | 51 // Notifies the service of changes in session state. |
| 44 void OnSessionChange(); | 52 void OnSessionChange(); |
| 45 | 53 |
| 46 // This is a common entry point to the main service loop called by both | 54 // This is a common entry point to the main service loop called by both |
| 47 // RunAsService() and RunInConsole(). | 55 // RunAsService() and RunInConsole(). |
| 48 void RunMessageLoop(); | 56 void RunMessageLoop(MessageLoop* message_loop); |
| 49 | 57 |
| 50 // This function handshakes with the service control manager and starts | 58 // This function handshakes with the service control manager and starts |
| 51 // the service. | 59 // the service. |
| 52 int RunAsService(); | 60 int RunAsService(); |
| 53 | 61 |
| 54 // This function starts the service in interactive mode (i.e. as a plain | 62 // This function starts the service in interactive mode (i.e. as a plain |
| 55 // console application). | 63 // console application). |
| 56 int RunInConsole(); | 64 int RunInConsole(); |
| 57 | 65 |
| 58 static BOOL WINAPI ConsoleControlHandler(DWORD event); | 66 static BOOL WINAPI ConsoleControlHandler(DWORD event); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 71 WPARAM wparam, | 79 WPARAM wparam, |
| 72 LPARAM lparam); | 80 LPARAM lparam); |
| 73 | 81 |
| 74 // Current physical console session id. | 82 // Current physical console session id. |
| 75 uint32 console_session_id_; | 83 uint32 console_session_id_; |
| 76 | 84 |
| 77 // The list of observers receiving notifications about any session attached | 85 // The list of observers receiving notifications about any session attached |
| 78 // to the physical console. | 86 // to the physical console. |
| 79 ObserverList<WtsConsoleObserver> console_observers_; | 87 ObserverList<WtsConsoleObserver> console_observers_; |
| 80 | 88 |
| 89 scoped_ptr<WtsSessionProcessLauncher> launcher_; |
| 90 |
| 81 // The host binary name. | 91 // The host binary name. |
| 82 FilePath host_binary_; | 92 FilePath host_binary_; |
| 83 | 93 |
| 84 // Service message loop. | 94 // Service message loop. |
| 85 MessageLoop* message_loop_; | 95 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 86 | 96 |
| 87 // The action routine to be executed. | 97 // The action routine to be executed. |
| 88 int (HostService::*run_routine_)(); | 98 int (HostService::*run_routine_)(); |
| 89 | 99 |
| 90 // The service name. | 100 // The service name. |
| 91 std::wstring service_name_; | 101 std::wstring service_name_; |
| 92 | 102 |
| 93 // The service status handle. | 103 // The service status handle. |
| 94 SERVICE_STATUS_HANDLE service_status_handle_; | 104 SERVICE_STATUS_HANDLE service_status_handle_; |
| 95 | 105 |
| 96 // True if the service is being stopped. | |
| 97 bool shutting_down_; | |
| 98 | |
| 99 // A waitable event that is used to wait until the service is stopped. | 106 // A waitable event that is used to wait until the service is stopped. |
| 100 base::WaitableEvent stopped_event_; | 107 base::WaitableEvent stopped_event_; |
| 101 | 108 |
| 102 // Singleton. | 109 // Singleton. |
| 103 friend struct DefaultSingletonTraits<HostService>; | 110 friend struct DefaultSingletonTraits<HostService>; |
| 104 | 111 |
| 105 DISALLOW_COPY_AND_ASSIGN(HostService); | 112 DISALLOW_COPY_AND_ASSIGN(HostService); |
| 106 }; | 113 }; |
| 107 | 114 |
| 108 } // namespace remoting | 115 } // namespace remoting |
| 109 | 116 |
| 110 #endif // REMOTING_HOST_HOST_SERVICE_WIN_H_ | 117 #endif // REMOTING_HOST_HOST_SERVICE_WIN_H_ |
| OLD | NEW |