| Index: remoting/protocol/connection_to_client.cc
|
| diff --git a/remoting/protocol/connection_to_client.cc b/remoting/protocol/connection_to_client.cc
|
| index ee2131a20dbc3d171cdb0f453cea45a719d7ae33..16795b79694feca2bda6d979cb623ade0cf2c849 100644
|
| --- a/remoting/protocol/connection_to_client.cc
|
| +++ b/remoting/protocol/connection_to_client.cc
|
| @@ -57,6 +57,8 @@ void ConnectionToClient::Disconnect() {
|
| return;
|
| }
|
|
|
| + CloseChannels();
|
| +
|
| // If there is a channel then close it and release the reference.
|
| if (session_) {
|
| session_->Close(NewRunnableMethod(this, &ConnectionToClient::OnClosed));
|
| @@ -74,7 +76,7 @@ VideoStub* ConnectionToClient::video_stub() {
|
|
|
| // Return pointer to ClientStub.
|
| ClientStub* ConnectionToClient::client_stub() {
|
| - return client_stub_.get();
|
| + return client_control_sender_.get();
|
| }
|
|
|
| void ConnectionToClient::set_host_stub(protocol::HostStub* host_stub) {
|
| @@ -86,26 +88,6 @@ void ConnectionToClient::set_input_stub(protocol::InputStub* input_stub) {
|
| }
|
|
|
| void ConnectionToClient::OnSessionStateChange(protocol::Session::State state) {
|
| - if (state == protocol::Session::CONNECTED) {
|
| - client_stub_.reset(new ClientControlSender(session_->control_channel()));
|
| - video_writer_.reset(VideoWriter::Create(session_->config()));
|
| - video_writer_->Init(session_);
|
| -
|
| - dispatcher_.reset(new HostMessageDispatcher());
|
| - dispatcher_->Initialize(this, host_stub_, input_stub_);
|
| - }
|
| -
|
| - // This method can be called from main thread so perform threading switching.
|
| - if (MessageLoop::current() != loop_) {
|
| - loop_->PostTask(
|
| - FROM_HERE,
|
| - NewRunnableMethod(this, &ConnectionToClient::StateChangeTask, state));
|
| - } else {
|
| - StateChangeTask(state);
|
| - }
|
| -}
|
| -
|
| -void ConnectionToClient::StateChangeTask(protocol::Session::State state) {
|
| DCHECK_EQ(loop_, MessageLoop::current());
|
|
|
| DCHECK(handler_);
|
| @@ -114,12 +96,22 @@ void ConnectionToClient::StateChangeTask(protocol::Session::State state) {
|
| break;
|
| // Don't care about this message.
|
| case protocol::Session::CONNECTED:
|
| + client_control_sender_.reset(
|
| + new ClientControlSender(session_->control_channel()));
|
| + video_writer_.reset(VideoWriter::Create(session_->config()));
|
| + video_writer_->Init(session_);
|
| +
|
| + dispatcher_.reset(new HostMessageDispatcher());
|
| + dispatcher_->Initialize(this, host_stub_, input_stub_);
|
| +
|
| handler_->OnConnectionOpened(this);
|
| break;
|
| case protocol::Session::CLOSED:
|
| + CloseChannels();
|
| handler_->OnConnectionClosed(this);
|
| break;
|
| case protocol::Session::FAILED:
|
| + CloseChannels();
|
| handler_->OnConnectionFailed(this);
|
| break;
|
| default:
|
| @@ -128,6 +120,13 @@ void ConnectionToClient::StateChangeTask(protocol::Session::State state) {
|
| }
|
| }
|
|
|
| +void ConnectionToClient::CloseChannels() {
|
| + if (video_writer_.get())
|
| + video_writer_->Close();
|
| + if (client_control_sender_.get())
|
| + client_control_sender_->Close();
|
| +}
|
| +
|
| // OnClosed() is used as a callback for protocol::Session::Close().
|
| void ConnectionToClient::OnClosed() {
|
| }
|
|
|