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_DESKTOP_SESSION_WIN_H_ | 5 #ifndef REMOTING_HOST_DESKTOP_SESSION_WIN_H_ |
6 #define REMOTING_HOST_DESKTOP_SESSION_WIN_H_ | 6 #define REMOTING_HOST_DESKTOP_SESSION_WIN_H_ |
7 | 7 |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/win/scoped_handle.h" |
| 12 #include "ipc/ipc_platform_file.h" |
11 #include "remoting/host/desktop_session.h" | 13 #include "remoting/host/desktop_session.h" |
12 #include "remoting/host/win/wts_console_observer.h" | 14 #include "remoting/host/win/wts_console_observer.h" |
13 #include "remoting/host/worker_process_ipc_delegate.h" | 15 #include "remoting/host/worker_process_ipc_delegate.h" |
14 | 16 |
15 namespace base { | 17 namespace tracked_objects { |
16 class SingleThreadTaskRunner; | 18 class Location; |
17 } // namespace base | 19 } // namespace tracked_objects |
18 | 20 |
19 namespace remoting { | 21 namespace remoting { |
20 | 22 |
| 23 class AutoThreadTaskRunner; |
21 class DaemonProcess; | 24 class DaemonProcess; |
22 class WorkerProcessLauncher; | 25 class WorkerProcessLauncher; |
23 class WtsConsoleMonitor; | 26 class WtsConsoleMonitor; |
24 | 27 |
25 // DesktopSession implementation which attaches to the host's physical console. | 28 // DesktopSession implementation which attaches to the host's physical console. |
26 // Receives IPC messages from the desktop process, running in the console | 29 // Receives IPC messages from the desktop process, running in the console |
27 // session, via |WorkerProcessIpcDelegate|, and monitors console session | 30 // session, via |WorkerProcessIpcDelegate|, and monitors console session |
28 // attach/detach events via |WtsConsoleObserer|. | 31 // attach/detach events via |WtsConsoleObserer|. |
29 // TODO(alexeypa): replace |WtsConsoleObserver| with an interface capable of | 32 // TODO(alexeypa): replace |WtsConsoleObserver| with an interface capable of |
30 // monitoring both the console and RDP connections. See http://crbug.com/137696. | 33 // monitoring both the console and RDP connections. See http://crbug.com/137696. |
31 class DesktopSessionWin | 34 class DesktopSessionWin |
32 : public DesktopSession, | 35 : public DesktopSession, |
33 public WorkerProcessIpcDelegate, | 36 public WorkerProcessIpcDelegate, |
34 public WtsConsoleObserver { | 37 public WtsConsoleObserver { |
35 public: | 38 public: |
36 // Passes the owning |daemon_process|, a unique identifier of the desktop | 39 // Passes the owning |daemon_process|, a unique identifier of the desktop |
37 // session |id| and the interface for monitoring console session attach/detach | 40 // session |id| and the interface for monitoring console session attach/detach |
38 // events. Both |daemon_process| and |monitor| must outlive |this|. | 41 // events. Both |daemon_process| and |monitor| must outlive |this|. |
39 DesktopSessionWin( | 42 DesktopSessionWin( |
40 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 43 scoped_refptr<AutoThreadTaskRunner> main_task_runner, |
41 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 44 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
42 DaemonProcess* daemon_process, | 45 DaemonProcess* daemon_process, |
43 int id, | 46 int id, |
44 WtsConsoleMonitor* monitor); | 47 WtsConsoleMonitor* monitor); |
45 virtual ~DesktopSessionWin(); | 48 virtual ~DesktopSessionWin(); |
46 | 49 |
47 // WorkerProcessIpcDelegate implementation. | 50 // WorkerProcessIpcDelegate implementation. |
48 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 51 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
49 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 52 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
50 virtual void OnPermanentError() OVERRIDE; | 53 virtual void OnPermanentError() OVERRIDE; |
51 | 54 |
52 // WtsConsoleObserver implementation. | 55 // WtsConsoleObserver implementation. |
53 virtual void OnSessionAttached(uint32 session_id) OVERRIDE; | 56 virtual void OnSessionAttached(uint32 session_id) OVERRIDE; |
54 virtual void OnSessionDetached() OVERRIDE; | 57 virtual void OnSessionDetached() OVERRIDE; |
55 | 58 |
56 private: | 59 private: |
| 60 // ChromotingDesktopDaemonMsg_DesktopAttached handler. |
| 61 void OnDesktopSessionAgentAttached(IPC::PlatformFileForTransit desktop_pipe); |
| 62 |
| 63 // Restarts the desktop process. |
| 64 void RestartDesktopProcess(const tracked_objects::Location& location); |
| 65 |
57 // Task runner on which public methods of this class should be called. | 66 // Task runner on which public methods of this class should be called. |
58 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 67 scoped_refptr<AutoThreadTaskRunner> main_task_runner_; |
59 | 68 |
60 // Message loop used by the IPC channel. | 69 // Message loop used by the IPC channel. |
61 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 70 scoped_refptr<AutoThreadTaskRunner> io_task_runner_; |
62 | 71 |
63 // Contains the full path to the desktop binary. | 72 // Contains the full path to the desktop binary. |
64 FilePath desktop_binary_; | 73 FilePath desktop_binary_; |
65 | 74 |
| 75 // Handle of the desktop process. |
| 76 base::win::ScopedHandle desktop_process_; |
| 77 |
66 // Launches and monitors the desktop process. | 78 // Launches and monitors the desktop process. |
67 scoped_ptr<WorkerProcessLauncher> launcher_; | 79 scoped_ptr<WorkerProcessLauncher> launcher_; |
68 | 80 |
69 // Pointer used to unsubscribe from session attach and detach events. | 81 // Pointer used to unsubscribe from session attach and detach events. |
70 WtsConsoleMonitor* monitor_; | 82 WtsConsoleMonitor* monitor_; |
71 | 83 |
72 DISALLOW_COPY_AND_ASSIGN(DesktopSessionWin); | 84 DISALLOW_COPY_AND_ASSIGN(DesktopSessionWin); |
73 }; | 85 }; |
74 | 86 |
75 } // namespace remoting | 87 } // namespace remoting |
76 | 88 |
77 #endif // REMOTING_HOST_DESKTOP_SESSION_WIN_H_ | 89 #endif // REMOTING_HOST_DESKTOP_SESSION_WIN_H_ |
OLD | NEW |