Index: remoting/host/desktop_session_win.cc |
diff --git a/remoting/host/desktop_session_win.cc b/remoting/host/desktop_session_win.cc |
index 23d42b862e31fd3d23ed214510b9a0bd4e54fdb0..f4a56ef9d337b17d67195ee6fe341d5565ea43f3 100644 |
--- a/remoting/host/desktop_session_win.cc |
+++ b/remoting/host/desktop_session_win.cc |
@@ -273,7 +273,7 @@ void RdpSession::OnRdpConnected(const net::IPEndPoint& client_endpoint) { |
void RdpSession::OnRdpClosed() { |
DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
- OnPermanentError(); |
+ TerminateSession(); |
} |
void RdpSession::SetScreenResolution(const ScreenResolution& resolution) { |
@@ -425,7 +425,7 @@ void DesktopSessionWin::OnSessionAttachTimeout() { |
LOG(ERROR) << "Session attach notification didn't arrived within " |
<< kSessionAttachTimeoutSeconds << " seconds."; |
- OnPermanentError(); |
+ TerminateSession(); |
} |
void DesktopSessionWin::StartMonitoring( |
@@ -458,6 +458,15 @@ void DesktopSessionWin::StopMonitoring() { |
OnSessionDetached(); |
} |
+void DesktopSessionWin::TerminateSession() { |
+ DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
+ |
+ StopMonitoring(); |
+ |
+ // This call will delete |this| so it should be at the very end of the method. |
+ daemon_process()->CloseDesktopSession(id()); |
+} |
+ |
void DesktopSessionWin::OnChannelConnected(int32 peer_pid) { |
DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
@@ -495,13 +504,10 @@ bool DesktopSessionWin::OnMessageReceived(const IPC::Message& message) { |
return handled; |
} |
-void DesktopSessionWin::OnPermanentError() { |
+void DesktopSessionWin::OnPermanentError(int exit_code) { |
DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
- StopMonitoring(); |
- |
- // This call will delete |this| so it should be at the very end of the method. |
- daemon_process()->CloseDesktopSession(id()); |
+ TerminateSession(); |
} |
void DesktopSessionWin::OnSessionAttached(uint32 session_id) { |
@@ -525,7 +531,7 @@ void DesktopSessionWin::OnSessionAttached(uint32 session_id) { |
} |
if (!result) { |
- OnPermanentError(); |
+ TerminateSession(); |
return; |
} |
@@ -545,7 +551,7 @@ void DesktopSessionWin::OnSessionAttached(uint32 session_id) { |
launch_elevated, |
WideToUTF8(kDaemonIpcSecurityDescriptor))); |
if (!delegate->Initialize(session_id)) { |
- OnPermanentError(); |
+ TerminateSession(); |
return; |
} |