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