Index: remoting/protocol/connection_to_host.cc |
diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc |
index 5eb438ae16a8cdd1a29c44e081dda49f224af57b..a9b8fb7b14ac4e161457edcdcca25e7db891e15c 100644 |
--- a/remoting/protocol/connection_to_host.cc |
+++ b/remoting/protocol/connection_to_host.cc |
@@ -36,16 +36,16 @@ ConnectionToHost::ConnectionToHost( |
video_stub_(NULL), |
state_(CONNECTING), |
error_(OK), |
- control_connected_(false), |
- input_connected_(false), |
- video_connected_(false) { |
+ control_channel_connected_(false), |
+ event_channel_connected_(false), |
+ video_channel_connected_(false) { |
} |
ConnectionToHost::~ConnectionToHost() { |
} |
InputStub* ConnectionToHost::input_stub() { |
- return input_dispatcher_.get(); |
+ return event_dispatcher_.get(); |
} |
HostStub* ConnectionToHost::host_stub() { |
@@ -190,24 +190,22 @@ void ConnectionToHost::OnSessionStateChange( |
break; |
case Session::CONNECTED: |
- video_reader_.reset( |
- VideoReader::Create(message_loop_, session_->config())); |
- video_reader_->Init( |
- session_.get(), video_stub_, |
- base::Bind(&ConnectionToHost::OnVideoChannelInitialized, |
- base::Unretained(this))); |
- break; |
+ video_reader_.reset(VideoReader::Create( |
+ message_loop_, session_->config())); |
+ video_reader_->Init(session_.get(), video_stub_, base::Bind( |
+ &ConnectionToHost::OnVideoChannelInitialized, |
+ base::Unretained(this))); |
- case Session::CONNECTED_CHANNELS: |
control_dispatcher_.reset(new ClientControlDispatcher()); |
- control_dispatcher_->Init(session_.get()); |
+ control_dispatcher_->Init(session_.get(), base::Bind( |
+ &ConnectionToHost::OnControlChannelInitialized, |
+ base::Unretained(this))); |
control_dispatcher_->set_client_stub(client_stub_); |
- input_dispatcher_.reset(new ClientEventDispatcher()); |
- input_dispatcher_->Init(session_.get()); |
- control_connected_ = true; |
- input_connected_ = true; |
- NotifyIfChannelsReady(); |
+ event_dispatcher_.reset(new ClientEventDispatcher()); |
+ event_dispatcher_->Init(session_.get(), base::Bind( |
+ &ConnectionToHost::OnEventChannelInitialized, |
+ base::Unretained(this))); |
break; |
default: |
@@ -216,6 +214,30 @@ void ConnectionToHost::OnSessionStateChange( |
} |
} |
+void ConnectionToHost::OnControlChannelInitialized(bool successful) { |
+ if (!successful) { |
+ LOG(ERROR) << "Failed to connect video channel"; |
+ CloseOnError(NETWORK_FAILURE); |
+ return; |
+ } |
+ |
+ control_channel_connected_ = true; |
+ NotifyIfChannelsReady(); |
+} |
+ |
+ |
+void ConnectionToHost::OnEventChannelInitialized(bool successful) { |
+ if (!successful) { |
+ LOG(ERROR) << "Failed to connect video channel"; |
+ CloseOnError(NETWORK_FAILURE); |
+ return; |
+ } |
+ |
+ event_channel_connected_ = true; |
+ NotifyIfChannelsReady(); |
+} |
+ |
+ |
void ConnectionToHost::OnVideoChannelInitialized(bool successful) { |
if (!successful) { |
LOG(ERROR) << "Failed to connect video channel"; |
@@ -223,13 +245,13 @@ void ConnectionToHost::OnVideoChannelInitialized(bool successful) { |
return; |
} |
- video_connected_ = true; |
+ video_channel_connected_ = true; |
NotifyIfChannelsReady(); |
} |
void ConnectionToHost::NotifyIfChannelsReady() { |
- if (control_connected_ && input_connected_ && video_connected_ && |
- state_ == CONNECTING) { |
+ if (control_channel_connected_ && event_channel_connected_ && |
+ video_channel_connected_ && state_ == CONNECTING) { |
SetState(CONNECTED, OK); |
SetState(AUTHENTICATED, OK); |
} |
@@ -242,7 +264,7 @@ void ConnectionToHost::CloseOnError(Error error) { |
void ConnectionToHost::CloseChannels() { |
control_dispatcher_.reset(); |
- input_dispatcher_.reset(); |
+ event_dispatcher_.reset(); |
video_reader_.reset(); |
} |