Index: remoting/host/desktop_session_win.h |
diff --git a/remoting/host/desktop_session_win.h b/remoting/host/desktop_session_win.h |
index d174019591aa8ffb7822f950349754bf12a4e869..51d229bfaee279c6c7fc3f551d1d5f0809611d30 100644 |
--- a/remoting/host/desktop_session_win.h |
+++ b/remoting/host/desktop_session_win.h |
@@ -5,15 +5,19 @@ |
#ifndef REMOTING_HOST_DESKTOP_SESSION_WIN_H_ |
#define REMOTING_HOST_DESKTOP_SESSION_WIN_H_ |
-#include "base/files/file_path.h" |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/timer.h" |
#include "base/win/scoped_handle.h" |
#include "ipc/ipc_platform_file.h" |
#include "remoting/host/desktop_session.h" |
#include "remoting/host/win/wts_terminal_observer.h" |
#include "remoting/host/worker_process_ipc_delegate.h" |
+namespace net { |
+class IPEndPoint; |
+} // namespace net |
+ |
namespace tracked_objects { |
class Location; |
} // namespace tracked_objects |
@@ -22,35 +26,64 @@ namespace remoting { |
class AutoThreadTaskRunner; |
class DaemonProcess; |
+class DesktopSession; |
struct DesktopSessionParams; |
-class SasInjector; |
class WorkerProcessLauncher; |
class WtsTerminalMonitor; |
-// DesktopSession implementation which attaches to the host's physical console. |
-// Receives IPC messages from the desktop process, running in the console |
-// session, via |WorkerProcessIpcDelegate|, and monitors console session |
-// attach/detach events via |WtsConsoleObserer|. |
-// TODO(alexeypa): replace |WtsTerminalObserver| with an interface capable of |
-// monitoring both the console and RDP connections. See http://crbug.com/137696. |
+// DesktopSession implementation which attaches to either physical or virtual |
+// (RDP) console. Receives IPC messages from the desktop process, running in |
+// the target session, via |WorkerProcessIpcDelegate|, and monitors session |
+// attach/detach events via |WtsTerminalObserer|. |
class DesktopSessionWin |
: public DesktopSession, |
public WorkerProcessIpcDelegate, |
public WtsTerminalObserver { |
public: |
+ // Creates a desktop session instance that attaches to the physical console. |
+ static scoped_ptr<DesktopSession> CreateForConsole( |
+ scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
+ scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
+ DaemonProcess* daemon_process, |
+ int id, |
+ const DesktopSessionParams& params); |
+ |
+ // Creates a desktop session instance that attaches to a virtual console. |
+ static scoped_ptr<DesktopSession> CreateForVirtualTerminal( |
+ scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
+ scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
+ DaemonProcess* daemon_process, |
+ int id, |
+ const DesktopSessionParams& params); |
+ |
+ protected: |
// Passes the owning |daemon_process|, a unique identifier of the desktop |
- // session |id| and the interface for monitoring console session attach/detach |
- // events. Both |daemon_process| and |monitor| must outlive |this|. |
+ // session |id| and the interface for monitoring session attach/detach events. |
+ // Both |daemon_process| and |monitor| must outlive |this|. |
DesktopSessionWin( |
- scoped_refptr<AutoThreadTaskRunner> main_task_runner, |
+ scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
DaemonProcess* daemon_process, |
int id, |
- const DesktopSessionParams& params, |
- bool virtual_terminal, |
WtsTerminalMonitor* monitor); |
virtual ~DesktopSessionWin(); |
+ const scoped_refptr<AutoThreadTaskRunner>& caller_task_runner() const { |
+ return caller_task_runner_; |
+ } |
+ |
+ // Called when |session_attach_timer_| expires. |
+ void OnSessionAttachTimeout(); |
+ |
+ // Starts monitoring for session attach/detach events for |client_endpoint|. |
+ void StartMonitoring(const net::IPEndPoint& client_endpoint); |
+ |
+ // Stops monitoring for session attach/detach events. |
+ void StopMonitoring(); |
+ |
+ // Injects a secure attention sequence into the session. |
+ virtual void InjectSas() = 0; |
+ |
// WorkerProcessIpcDelegate implementation. |
virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
@@ -64,31 +97,30 @@ class DesktopSessionWin |
// ChromotingDesktopDaemonMsg_DesktopAttached handler. |
void OnDesktopSessionAgentAttached(IPC::PlatformFileForTransit desktop_pipe); |
- // ChromotingDesktopDaemonMsg_InjectSas handler. |
- void OnInjectSas(); |
- |
// Requests the desktop process to crash. |
void CrashDesktopProcess(const tracked_objects::Location& location); |
// Task runner on which public methods of this class should be called. |
- scoped_refptr<AutoThreadTaskRunner> main_task_runner_; |
+ scoped_refptr<AutoThreadTaskRunner> caller_task_runner_; |
// Message loop used by the IPC channel. |
scoped_refptr<AutoThreadTaskRunner> io_task_runner_; |
- // Contains the full path to the desktop binary. |
- base::FilePath desktop_binary_; |
- |
- // Handle of the desktop process. |
+ // Handle of the desktop process (running an instance of DesktopSessionAgent). |
base::win::ScopedHandle desktop_process_; |
// Launches and monitors the desktop process. |
scoped_ptr<WorkerProcessLauncher> launcher_; |
- // Pointer used to unsubscribe from session attach and detach events. |
+ // Used to unsubscribe from session attach and detach events. |
WtsTerminalMonitor* monitor_; |
- scoped_ptr<SasInjector> sas_injector_; |
+ // True if |this| is subsribed to receive session attach/detach notifications. |
+ bool monitoring_notifications_; |
+ |
+ // Used to report an error if the session attach notification does not arrives |
+ // for too long. |
+ base::OneShotTimer<DesktopSessionWin> session_attach_timer_; |
DISALLOW_COPY_AND_ASSIGN(DesktopSessionWin); |
}; |