Chromium Code Reviews| 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..9482791c7bae25dc0f587693ed121cf73789917d 100644 |
| --- a/remoting/protocol/connection_to_client.cc |
| +++ b/remoting/protocol/connection_to_client.cc |
| @@ -57,6 +57,11 @@ void ConnectionToClient::Disconnect() { |
| return; |
| } |
| + if (video_writer_.get()) |
| + video_writer_->Close(); |
| + if (client_control_sender_.get()) |
| + client_control_sender_->Close(); |
|
Wez
2011/06/30 18:27:31
We Close() these in Disconnect(), but we created t
Sergey Ulanov
2011/06/30 20:55:24
Done.
|
| + |
| // If there is a channel then close it and release the reference. |
| if (session_) { |
| session_->Close(NewRunnableMethod(this, &ConnectionToClient::OnClosed)); |
| @@ -74,7 +79,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 +91,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,6 +99,14 @@ 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: |