Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1258)

Unified Diff: remoting/host/chromoting_host.cc

Issue 7635005: Properly handle screen recorder shutdown in ChromotingHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/chromoting_host.h ('k') | remoting/host/screen_recorder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/chromoting_host.cc
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index 1d42059425fd92743d49edec0e46b872983a5221..67f7bbe31aa0a72c95f5defa91788be982569ce6 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -55,6 +55,7 @@ ChromotingHost::ChromotingHost(ChromotingHostContext* context,
access_verifier_(access_verifier),
allow_nat_traversal_(allow_nat_traversal),
state_(kInitial),
+ stopping_recorders_(0),
protocol_config_(protocol::CandidateSessionConfig::CreateDefault()),
is_curtained_(false),
is_it2me_(false) {
@@ -376,13 +377,11 @@ void ChromotingHost::OnClientDisconnected(ConnectionToClient* connection) {
recorder_->RemoveConnection(connection);
// The recorder only exists to serve the unique authenticated client.
// If that client has disconnected, then we can kill the recorder.
- if (client->get()->authenticated()) {
- recorder_->Stop(NULL);
- recorder_ = NULL;
- }
+ if (client->get()->authenticated())
+ StopScreenRecorder();
}
- // Close the connection to connection just to be safe.
+ // Close the connection to client just to be safe.
connection->Disconnect();
// Also remove reference to ConnectionToClient from this object.
@@ -542,6 +541,35 @@ void ChromotingHost::ProcessPreAuthentication(
client->get()->OnAuthorizationComplete(true);
}
+void ChromotingHost::StopScreenRecorder() {
+ DCHECK(MessageLoop::current() == context_->main_message_loop());
+ DCHECK(recorder_.get());
+
+ ++stopping_recorders_;
+ recorder_->Stop(base::Bind(&ChromotingHost::OnScreenRecorderStopped, this));
+ recorder_ = NULL;
+}
+
+void ChromotingHost::OnScreenRecorderStopped() {
+ if (MessageLoop::current() != context_->main_message_loop()) {
+ context_->main_message_loop()->PostTask(
+ FROM_HERE, base::Bind(&ChromotingHost::OnScreenRecorderStopped, this));
+ return;
+ }
+
+ --stopping_recorders_;
+ DCHECK_GE(stopping_recorders_, 0);
+
+ bool stopping;
+ {
+ base::AutoLock auto_lock(lock_);
+ stopping = state_ == kStopping;
+ }
+
+ if (!stopping_recorders_ && stopping)
+ ShutdownFinish();
+}
+
void ChromotingHost::ShutdownNetwork() {
if (MessageLoop::current() != context_->network_message_loop()) {
context_->network_message_loop()->PostTask(
@@ -577,8 +605,8 @@ void ChromotingHost::ShutdownRecorder() {
}
if (recorder_.get()) {
- recorder_->Stop(NewRunnableMethod(this, &ChromotingHost::ShutdownFinish));
- } else {
+ StopScreenRecorder();
+ } else if (!stopping_recorders_) {
ShutdownFinish();
}
}
« no previous file with comments | « remoting/host/chromoting_host.h ('k') | remoting/host/screen_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698