| Index: remoting/protocol/connection_to_client.cc
|
| diff --git a/remoting/protocol/connection_to_client.cc b/remoting/protocol/connection_to_client.cc
|
| index 84ad51592493a80b0b0aacd6fba146d66c21210d..691b3d7031501147fc3cd312ba8c11d349aeddc9 100644
|
| --- a/remoting/protocol/connection_to_client.cc
|
| +++ b/remoting/protocol/connection_to_client.cc
|
| @@ -22,9 +22,9 @@ ConnectionToClient::ConnectionToClient(protocol::Session* session)
|
| host_stub_(NULL),
|
| input_stub_(NULL),
|
| session_(session),
|
| - control_connected_(false),
|
| - input_connected_(false),
|
| - video_connected_(false) {
|
| + control_channel_connected_(false),
|
| + event_channel_connected_(false),
|
| + video_channel_connected_(false) {
|
| session_->SetStateChangeCallback(
|
| base::Bind(&ConnectionToClient::OnSessionStateChange,
|
| base::Unretained(this)));
|
| @@ -101,27 +101,27 @@ void ConnectionToClient::OnSessionStateChange(protocol::Session::State state) {
|
| break;
|
|
|
| case protocol::Session::CONNECTED:
|
| - video_writer_.reset(
|
| - VideoWriter::Create(base::MessageLoopProxy::current(),
|
| - session_->config()));
|
| - video_writer_->Init(
|
| - session_.get(), base::Bind(&ConnectionToClient::OnVideoInitialized,
|
| - base::Unretained(this)));
|
| - break;
|
| -
|
| - case protocol::Session::CONNECTED_CHANNELS:
|
| + // Initialize channels.
|
| control_dispatcher_.reset(new HostControlDispatcher());
|
| - control_dispatcher_->Init(session_.get());
|
| + control_dispatcher_->Init(session_.get(), base::Bind(
|
| + &ConnectionToClient::OnControlChannelInitialized,
|
| + base::Unretained(this)));
|
| control_dispatcher_->set_host_stub(host_stub_);
|
| - input_dispatcher_.reset(new HostEventDispatcher());
|
| - input_dispatcher_->Init(session_.get());
|
| - input_dispatcher_->set_input_stub(input_stub_);
|
| - input_dispatcher_->set_sequence_number_callback(base::Bind(
|
| +
|
| + event_dispatcher_.reset(new HostEventDispatcher());
|
| + event_dispatcher_->Init(session_.get(), base::Bind(
|
| + &ConnectionToClient::OnEventChannelInitialized,
|
| + base::Unretained(this)));
|
| + event_dispatcher_->set_input_stub(input_stub_);
|
| + event_dispatcher_->set_sequence_number_callback(base::Bind(
|
| &ConnectionToClient::UpdateSequenceNumber, base::Unretained(this)));
|
|
|
| - control_connected_ = true;
|
| - input_connected_ = true;
|
| - NotifyIfChannelsReady();
|
| + video_writer_.reset(VideoWriter::Create(
|
| + base::MessageLoopProxy::current(), session_->config()));
|
| + video_writer_->Init(session_.get(), base::Bind(
|
| + &ConnectionToClient::OnVideoChannelInitialized,
|
| + base::Unretained(this)));
|
| +
|
| break;
|
|
|
| case protocol::Session::CLOSED:
|
| @@ -139,7 +139,33 @@ void ConnectionToClient::OnSessionStateChange(protocol::Session::State state) {
|
| }
|
| }
|
|
|
| -void ConnectionToClient::OnVideoInitialized(bool successful) {
|
| +void ConnectionToClient::OnControlChannelInitialized(bool successful) {
|
| + DCHECK(CalledOnValidThread());
|
| +
|
| + if (!successful) {
|
| + LOG(ERROR) << "Failed to connect control channel";
|
| + CloseOnError();
|
| + return;
|
| + }
|
| +
|
| + control_channel_connected_ = true;
|
| + NotifyIfChannelsReady();
|
| +}
|
| +
|
| +void ConnectionToClient::OnEventChannelInitialized(bool successful) {
|
| + DCHECK(CalledOnValidThread());
|
| +
|
| + if (!successful) {
|
| + LOG(ERROR) << "Failed to connect event channel";
|
| + CloseOnError();
|
| + return;
|
| + }
|
| +
|
| + event_channel_connected_ = true;
|
| + NotifyIfChannelsReady();
|
| +}
|
| +
|
| +void ConnectionToClient::OnVideoChannelInitialized(bool successful) {
|
| DCHECK(CalledOnValidThread());
|
|
|
| if (!successful) {
|
| @@ -148,15 +174,17 @@ void ConnectionToClient::OnVideoInitialized(bool successful) {
|
| return;
|
| }
|
|
|
| - video_connected_ = true;
|
| + video_channel_connected_ = true;
|
| NotifyIfChannelsReady();
|
| }
|
|
|
| void ConnectionToClient::NotifyIfChannelsReady() {
|
| DCHECK(CalledOnValidThread());
|
|
|
| - if (control_connected_ && input_connected_ && video_connected_)
|
| + if (control_channel_connected_ && event_channel_connected_ &&
|
| + video_channel_connected_) {
|
| handler_->OnConnectionOpened(this);
|
| + }
|
| }
|
|
|
| void ConnectionToClient::CloseOnError() {
|
| @@ -166,7 +194,7 @@ void ConnectionToClient::CloseOnError() {
|
|
|
| void ConnectionToClient::CloseChannels() {
|
| control_dispatcher_.reset();
|
| - input_dispatcher_.reset();
|
| + event_dispatcher_.reset();
|
| video_writer_.reset();
|
| }
|
|
|
|
|