Chromium Code Reviews| Index: remoting/host/wts_session_process_launcher_win.cc |
| diff --git a/remoting/host/wts_session_process_launcher_win.cc b/remoting/host/wts_session_process_launcher_win.cc |
| index 510ee2fbb9bfd8ef6a5445f6d6e813c29540ae40..ffc38c6b47b097e9107520f46bf18fd11ea08678 100644 |
| --- a/remoting/host/wts_session_process_launcher_win.cc |
| +++ b/remoting/host/wts_session_process_launcher_win.cc |
| @@ -16,7 +16,7 @@ |
| #include "base/bind_helpers.h" |
| #include "base/command_line.h" |
| #include "base/logging.h" |
| -#include "base/message_loop_proxy.h" |
| +#include "base/single_thread_task_runner.h" |
| #include "base/process_util.h" |
| #include "base/rand_util.h" |
| #include "base/stringprintf.h" |
| @@ -212,11 +212,13 @@ namespace remoting { |
| const uint32 kInvalidSessionId = 0xffffffff; |
| WtsSessionProcessLauncher::WtsSessionProcessLauncher( |
| + const Shutdownable::Callback& done, |
| WtsConsoleMonitor* monitor, |
| const FilePath& host_binary, |
| - scoped_refptr<base::MessageLoopProxy> main_message_loop, |
| - scoped_refptr<base::MessageLoopProxy> ipc_message_loop) |
| - : host_binary_(host_binary), |
| + scoped_refptr<base::SingleThreadTaskRunner> main_message_loop, |
| + scoped_refptr<base::SingleThreadTaskRunner> ipc_message_loop) |
| + : Shutdownable(main_message_loop, done), |
| + host_binary_(host_binary), |
| main_message_loop_(main_message_loop), |
| ipc_message_loop_(ipc_message_loop), |
| monitor_(monitor), |
| @@ -225,14 +227,16 @@ WtsSessionProcessLauncher::WtsSessionProcessLauncher( |
| } |
| WtsSessionProcessLauncher::~WtsSessionProcessLauncher() { |
| + monitor_->RemoveWtsConsoleObserver(this); |
| + if (state_ != StateDetached) { |
| + OnSessionDetached(); |
| + } |
| + |
| DCHECK(state_ == StateDetached); |
| DCHECK(!timer_.IsRunning()); |
| DCHECK(process_.handle() == NULL); |
| DCHECK(process_watcher_.GetWatchedObject() == NULL); |
| DCHECK(chromoting_channel_.get() == NULL); |
| - if (monitor_ != NULL) { |
| - monitor_->RemoveWtsConsoleObserver(this); |
| - } |
| } |
| void WtsSessionProcessLauncher::LaunchProcess() { |
| @@ -328,12 +332,7 @@ void WtsSessionProcessLauncher::OnObjectSignaled(HANDLE object) { |
| state_ = StateStarting; |
| if (stop_trying) { |
| - OnSessionDetached(); |
| - |
| - // N.B. The service will stop once the last observer is removed from |
| - // the list. |
| - monitor_->RemoveWtsConsoleObserver(this); |
| - monitor_ = NULL; |
| + Shutdown(); |
| return; |
| } |
| @@ -386,6 +385,10 @@ void WtsSessionProcessLauncher::OnSendSasToConsole() { |
| void WtsSessionProcessLauncher::OnSessionAttached(uint32 session_id) { |
| DCHECK(main_message_loop_->BelongsToCurrentThread()); |
| + |
| + if (get_shutdownable_state() != Shutdownable::kRunning) |
| + return; |
|
Sergey Ulanov
2012/07/30 19:46:22
add {} around this line for consistency?
alexeypa (please no reviews)
2012/07/30 20:41:43
Done.
|
| + |
| DCHECK(state_ == StateDetached); |
| DCHECK(!timer_.IsRunning()); |
| DCHECK(process_.handle() == NULL); |
| @@ -463,4 +466,12 @@ void WtsSessionProcessLauncher::OnSessionDetached() { |
| session_token_.Close(); |
| } |
| +void WtsSessionProcessLauncher::DoShutdown() { |
| + if (state_ != StateDetached) { |
| + OnSessionDetached(); |
| + } |
| + |
| + CompleteShutdown(); |
| +} |
| + |
| } // namespace remoting |