| 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 <list> | 10 #include <list> |
| 11 | 11 |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 15 #include "net/base/ip_endpoint.h" | 15 #include "net/base/ip_endpoint.h" |
| 16 #include "remoting/host/win/message_window.h" |
| 16 #include "remoting/host/win/wts_terminal_monitor.h" | 17 #include "remoting/host/win/wts_terminal_monitor.h" |
| 17 | 18 |
| 18 class CommandLine; | 19 class CommandLine; |
| 19 | 20 |
| 20 namespace base { | 21 namespace base { |
| 21 class SingleThreadTaskRunner; | 22 class SingleThreadTaskRunner; |
| 22 } // namespace base | 23 } // namespace base |
| 23 | 24 |
| 24 namespace remoting { | 25 namespace remoting { |
| 25 | 26 |
| 26 class AutoThreadTaskRunner; | 27 class AutoThreadTaskRunner; |
| 27 class Stoppable; | 28 class Stoppable; |
| 28 class WtsTerminalObserver; | 29 class WtsTerminalObserver; |
| 29 | 30 |
| 30 class HostService : public WtsTerminalMonitor { | 31 class HostService : public win::MessageWindow::Delegate, |
| 32 public WtsTerminalMonitor { |
| 31 public: | 33 public: |
| 32 static HostService* GetInstance(); | 34 static HostService* GetInstance(); |
| 33 | 35 |
| 34 // This function parses the command line and selects the action routine. | 36 // This function parses the command line and selects the action routine. |
| 35 bool InitWithCommandLine(const CommandLine* command_line); | 37 bool InitWithCommandLine(const CommandLine* command_line); |
| 36 | 38 |
| 37 // Invoke the choosen action routine. | 39 // Invoke the choosen action routine. |
| 38 int Run(); | 40 int Run(); |
| 39 | 41 |
| 40 // WtsTerminalMonitor implementation | 42 // WtsTerminalMonitor implementation |
| (...skipping 20 matching lines...) Expand all Loading... |
| 61 | 63 |
| 62 // Runs the service on the service thread. A separate routine is used to make | 64 // Runs the service on the service thread. A separate routine is used to make |
| 63 // sure all local objects are destoyed by the time |stopped_event_| is | 65 // sure all local objects are destoyed by the time |stopped_event_| is |
| 64 // signalled. | 66 // signalled. |
| 65 void RunAsServiceImpl(); | 67 void RunAsServiceImpl(); |
| 66 | 68 |
| 67 // This function starts the service in interactive mode (i.e. as a plain | 69 // This function starts the service in interactive mode (i.e. as a plain |
| 68 // console application). | 70 // console application). |
| 69 int RunInConsole(); | 71 int RunInConsole(); |
| 70 | 72 |
| 73 // win::MessageWindow::Delegate interface. |
| 74 virtual bool HandleMessage(UINT message, WPARAM wparam, LPARAM lparam, |
| 75 LRESULT* result) OVERRIDE; |
| 76 |
| 71 static BOOL WINAPI ConsoleControlHandler(DWORD event); | 77 static BOOL WINAPI ConsoleControlHandler(DWORD event); |
| 72 | 78 |
| 73 // The control handler of the service. | 79 // The control handler of the service. |
| 74 static DWORD WINAPI ServiceControlHandler(DWORD control, | 80 static DWORD WINAPI ServiceControlHandler(DWORD control, |
| 75 DWORD event_type, | 81 DWORD event_type, |
| 76 LPVOID event_data, | 82 LPVOID event_data, |
| 77 LPVOID context); | 83 LPVOID context); |
| 78 | 84 |
| 79 // The main service entry point. | 85 // The main service entry point. |
| 80 static VOID WINAPI ServiceMain(DWORD argc, WCHAR* argv[]); | 86 static VOID WINAPI ServiceMain(DWORD argc, WCHAR* argv[]); |
| 81 | 87 |
| 82 static LRESULT CALLBACK SessionChangeNotificationProc(HWND hwnd, | |
| 83 UINT message, | |
| 84 WPARAM wparam, | |
| 85 LPARAM lparam); | |
| 86 | |
| 87 struct RegisteredObserver { | 88 struct RegisteredObserver { |
| 88 // Specifies the client address of an RDP connection or IPEndPoint() for | 89 // Specifies the client address of an RDP connection or IPEndPoint() for |
| 89 // the physical console. | 90 // the physical console. |
| 90 net::IPEndPoint client_endpoint; | 91 net::IPEndPoint client_endpoint; |
| 91 | 92 |
| 92 // Specifies ID of the attached session or |kInvalidSession| if no session | 93 // Specifies ID of the attached session or |kInvalidSession| if no session |
| 93 // is attached to the WTS console. | 94 // is attached to the WTS console. |
| 94 uint32 session_id; | 95 uint32 session_id; |
| 95 | 96 |
| 96 // Points to the observer receiving notifications about the WTS console | 97 // Points to the observer receiving notifications about the WTS console |
| (...skipping 20 matching lines...) Expand all Loading... |
| 117 | 118 |
| 118 // Singleton. | 119 // Singleton. |
| 119 friend struct DefaultSingletonTraits<HostService>; | 120 friend struct DefaultSingletonTraits<HostService>; |
| 120 | 121 |
| 121 DISALLOW_COPY_AND_ASSIGN(HostService); | 122 DISALLOW_COPY_AND_ASSIGN(HostService); |
| 122 }; | 123 }; |
| 123 | 124 |
| 124 } // namespace remoting | 125 } // namespace remoting |
| 125 | 126 |
| 126 #endif // REMOTING_HOST_WIN_HOST_SERVICE_H_ | 127 #endif // REMOTING_HOST_WIN_HOST_SERVICE_H_ |
| OLD | NEW |