diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-09 19:41:30 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-09 19:41:30 +0000 |
commit | a08f3031e346307b8480cf515273f6d5cf0ccffb (patch) | |
tree | ac5a65b15bead18d15581df5b8b3bed7e702019c /remoting | |
parent | 017547499f6e549798fd0a09c1aa953d99667b50 (diff) | |
download | chromium_src-a08f3031e346307b8480cf515273f6d5cf0ccffb.zip chromium_src-a08f3031e346307b8480cf515273f6d5cf0ccffb.tar.gz chromium_src-a08f3031e346307b8480cf515273f6d5cf0ccffb.tar.bz2 |
Don't post NULL tasks from ChromotingHost::Start().
Previously ChromotingHost::Start() would post shutdown_task to
the network thread even if shutdown_task is null. This causes DCHECK
in debug builds and crashes the host in release build.
Also some minor cleanups in that code to make it more readable.
Review URL: https://chromiumcodereview.appspot.com/10756004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/chromoting_host.cc | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index 74917e69..d9417b6 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -106,32 +106,38 @@ void ChromotingHost::Shutdown(const base::Closure& shutdown_task) { return; } - // No-op if this object is not started yet. - if (state_ == kInitial || state_ == kStopped) { + switch (state_) { + case kInitial: + case kStopped: // Nothing to do if we are not started. - state_ = kStopped; - context_->network_task_runner()->PostTask(FROM_HERE, shutdown_task); - return; - } - if (!shutdown_task.is_null()) - shutdown_tasks_.push_back(shutdown_task); - if (state_ == kStopping) - return; - state_ = kStopping; - - // Disconnect all of the clients, implicitly stopping the ScreenRecorder. - while (!clients_.empty()) { - clients_.front()->Disconnect(); - } - - // Destroy session manager. - session_manager_.reset(); - - // Stop screen recorder - if (recorder_.get()) { - StopScreenRecorder(); - } else if (!stopping_recorders_) { - ShutdownFinish(); + state_ = kStopped; + if (!shutdown_task.is_null()) + context_->network_task_runner()->PostTask(FROM_HERE, shutdown_task); + break; + + case kStopping: + // We are already stopping. Just save the task. + if (!shutdown_task.is_null()) + shutdown_tasks_.push_back(shutdown_task); + break; + + case kStarted: + if (!shutdown_task.is_null()) + shutdown_tasks_.push_back(shutdown_task); + state_ = kStopping; + + // Disconnect all of the clients, implicitly stopping the ScreenRecorder. + while (!clients_.empty()) { + clients_.front()->Disconnect(); + } + DCHECK(!recorder_.get()); + + // Destroy session manager. + session_manager_.reset(); + + if (!stopping_recorders_) + ShutdownFinish(); + break; } } |