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