Index: remoting/host/chromoting_host.cc |
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc |
index 21cc126b579acb7bab351f48de5a84b8cffefb1d..c769d39e11b4fe6539b542bf363f1d6d576a6bbe 100644 |
--- a/remoting/host/chromoting_host.cc |
+++ b/remoting/host/chromoting_host.cc |
@@ -24,35 +24,30 @@ |
#include "remoting/protocol/session_config.h" |
using remoting::protocol::ConnectionToClient; |
-using remoting::protocol::InputStub; |
namespace remoting { |
// static |
ChromotingHost* ChromotingHost::Create(ChromotingHostContext* context, |
MutableHostConfig* config) { |
- Capturer* capturer = Capturer::Create(context->main_message_loop()); |
- InputStub* input_stub = CreateEventExecutor(context->main_message_loop(), |
- capturer); |
- return Create(context, config, capturer, input_stub); |
+ return Create(context, config, |
+ Capturer::Create(context->main_message_loop())); |
} |
// static |
ChromotingHost* ChromotingHost::Create(ChromotingHostContext* context, |
MutableHostConfig* config, |
- Capturer* capturer, |
- InputStub* input_stub) { |
- return new ChromotingHost(context, config, capturer, input_stub); |
+ Capturer* capturer) { |
+ return new ChromotingHost(context, config, capturer); |
} |
ChromotingHost::ChromotingHost(ChromotingHostContext* context, |
- MutableHostConfig* config, |
- Capturer* capturer, |
- InputStub* input_stub) |
+ MutableHostConfig* config, Capturer* capturer) |
: context_(context), |
config_(config), |
capturer_(capturer), |
- input_stub_(input_stub), |
+ input_stub_(CreateEventExecutor( |
+ context->main_message_loop(), capturer)), |
host_stub_(new HostStubFake()), |
state_(kInitial), |
protocol_config_(protocol::CandidateSessionConfig::CreateDefault()) { |
@@ -126,6 +121,12 @@ void ChromotingHost::Shutdown() { |
state_ = kStopped; |
} |
+ // Tell the session to stop and then disconnect all clients. |
+ if (recorder_.get()) { |
+ recorder_->Stop(NULL); |
+ recorder_->RemoveAllConnections(); |
+ } |
+ |
// Disconnect the client. |
if (connection_) { |
connection_->Disconnect(); |
@@ -147,13 +148,9 @@ void ChromotingHost::Shutdown() { |
jingle_client_->Close(); |
} |
- // Tell the recorder to stop and then disconnect all clients. |
- if (recorder_.get()) { |
- recorder_->RemoveAllConnections(); |
- recorder_->Stop(shutdown_task_.release()); |
- } else { |
+ // Lastly call the shutdown task. |
+ if (shutdown_task_.get()) { |
shutdown_task_->Run(); |
- shutdown_task_.reset(); |
} |
} |
@@ -172,7 +169,7 @@ void ChromotingHost::OnClientConnected(ConnectionToClient* connection) { |
recorder_ = new ScreenRecorder(context_->main_message_loop(), |
context_->encode_message_loop(), |
context_->network_message_loop(), |
- capturer_.get(), |
+ capturer_.release(), |
encoder); |
} |
@@ -190,7 +187,6 @@ void ChromotingHost::OnClientDisconnected(ConnectionToClient* connection) { |
if (recorder_.get()) { |
recorder_->RemoveConnection(connection); |
recorder_->Stop(NULL); |
- recorder_ = NULL; |
} |
// Close the connection to connection just to be safe. |
@@ -210,7 +206,7 @@ void ChromotingHost::OnConnectionOpened(ConnectionToClient* connection) { |
context_->main_message_loop()->PostTask( |
FROM_HERE, |
NewRunnableMethod(this, &ChromotingHost::OnClientConnected, |
- make_scoped_refptr(connection))); |
+ connection_)); |
} |
void ChromotingHost::OnConnectionClosed(ConnectionToClient* connection) { |
@@ -220,7 +216,7 @@ void ChromotingHost::OnConnectionClosed(ConnectionToClient* connection) { |
context_->main_message_loop()->PostTask( |
FROM_HERE, |
NewRunnableMethod(this, &ChromotingHost::OnClientDisconnected, |
- make_scoped_refptr(connection))); |
+ connection_)); |
} |
void ChromotingHost::OnConnectionFailed(ConnectionToClient* connection) { |
@@ -230,7 +226,7 @@ void ChromotingHost::OnConnectionFailed(ConnectionToClient* connection) { |
context_->main_message_loop()->PostTask( |
FROM_HERE, |
NewRunnableMethod(this, &ChromotingHost::OnClientDisconnected, |
- make_scoped_refptr(connection))); |
+ connection_)); |
} |
//////////////////////////////////////////////////////////////////////////// |
@@ -303,7 +299,8 @@ void ChromotingHost::OnNewClientSession( |
VLOG(1) << "Client connected: " << session->jid(); |
- // If we accept the connected then create a connection object. |
+ // If we accept the connected then create a client object and set the |
+ // callback. |
connection_ = new ConnectionToClient(context_->network_message_loop(), |
this, host_stub_.get(), |
input_stub_.get()); |