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_WIN_HOST_SERVICE_H_ | 5 #ifndef REMOTING_HOST_WIN_HOST_SERVICE_H_ |
6 #define REMOTING_HOST_WIN_HOST_SERVICE_H_ | 6 #define REMOTING_HOST_WIN_HOST_SERVICE_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/win/wts_console_monitor.h" | 14 #include "remoting/host/win/wts_console_monitor.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 Stoppable; | 29 class Stoppable; |
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(); | 55 void OnChildStopped(); |
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 scoped_ptr<Stoppable> child_; |
89 | 96 |
90 // Service message loop. | 97 // Service message loop. |
91 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 98 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
92 | 99 |
93 // The action routine to be executed. | 100 // The action routine to be executed. |
94 int (HostService::*run_routine_)(); | 101 int (HostService::*run_routine_)(); |
95 | 102 |
96 // The service name. | 103 // The service name. |
97 std::wstring service_name_; | 104 std::wstring service_name_; |
98 | 105 |
99 // The service status handle. | 106 // The service status handle. |
100 SERVICE_STATUS_HANDLE service_status_handle_; | 107 SERVICE_STATUS_HANDLE service_status_handle_; |
101 | 108 |
102 // A waitable event that is used to wait until the service is stopped. | 109 // A waitable event that is used to wait until the service is stopped. |
103 base::WaitableEvent stopped_event_; | 110 base::WaitableEvent stopped_event_; |
104 | 111 |
105 // Singleton. | 112 // Singleton. |
106 friend struct DefaultSingletonTraits<HostService>; | 113 friend struct DefaultSingletonTraits<HostService>; |
107 | 114 |
108 DISALLOW_COPY_AND_ASSIGN(HostService); | 115 DISALLOW_COPY_AND_ASSIGN(HostService); |
109 }; | 116 }; |
110 | 117 |
111 } // namespace remoting | 118 } // namespace remoting |
112 | 119 |
113 #endif // REMOTING_HOST_WIN_HOST_SERVICE_H_ | 120 #endif // REMOTING_HOST_WIN_HOST_SERVICE_H_ |
OLD | NEW |