Index: remoting/protocol/connection_to_host.cc |
diff --git a/remoting/protocol/connection_to_host.cc b/remoting/protocol/connection_to_host.cc |
index 9217202bd42c26f2030b5a5543c5559d5bf1af0a..e2346e64f878cf7eb25a9777b598548078ab2e59 100644 |
--- a/remoting/protocol/connection_to_host.cc |
+++ b/remoting/protocol/connection_to_host.cc |
@@ -184,31 +184,24 @@ void ConnectionToHost::OnSessionStateChange( |
SetState(AUTHENTICATED, OK); |
control_dispatcher_.reset(new ClientControlDispatcher()); |
- control_dispatcher_->Init( |
- session_.get(), session_->config().control_config(), |
- base::Bind(&ConnectionToHost::OnChannelInitialized, |
- base::Unretained(this))); |
+ control_dispatcher_->Init(session_.get(), |
+ session_->config().control_config(), this); |
control_dispatcher_->set_client_stub(client_stub_); |
control_dispatcher_->set_clipboard_stub(clipboard_stub_); |
event_dispatcher_.reset(new ClientEventDispatcher()); |
- event_dispatcher_->Init( |
- session_.get(), session_->config().event_config(), |
- base::Bind(&ConnectionToHost::OnChannelInitialized, |
- base::Unretained(this))); |
+ event_dispatcher_->Init(session_.get(), session_->config().event_config(), |
+ this); |
video_dispatcher_.reset( |
new ClientVideoDispatcher(monitored_video_stub_.get())); |
video_dispatcher_->Init(session_.get(), session_->config().video_config(), |
- base::Bind(&ConnectionToHost::OnChannelInitialized, |
- base::Unretained(this))); |
+ this); |
- audio_reader_ = AudioReader::Create(session_->config()); |
- if (audio_reader_.get()) { |
+ if (session_->config().is_audio_enabled()) { |
+ audio_reader_.reset(new AudioReader(audio_stub_)); |
audio_reader_->Init(session_.get(), session_->config().audio_config(), |
- base::Bind(&ConnectionToHost::OnChannelInitialized, |
- base::Unretained(this))); |
- audio_reader_->set_audio_stub(audio_stub_); |
+ this); |
} |
break; |
@@ -241,6 +234,19 @@ void ConnectionToHost::OnSessionRouteChange(const std::string& channel_name, |
event_callback_->OnRouteChanged(channel_name, route); |
} |
+void ConnectionToHost::OnChannelInitialized( |
+ ChannelDispatcherBase* channel_dispatcher) { |
+ NotifyIfChannelsReady(); |
+} |
+ |
+void ConnectionToHost::OnChannelError( |
+ ChannelDispatcherBase* channel_dispatcher, |
+ ErrorCode error) { |
+ LOG(ERROR) << "Failed to connect channel " << channel_dispatcher; |
+ CloseOnError(CHANNEL_CONNECTION_ERROR); |
+ return; |
+} |
+ |
void ConnectionToHost::OnVideoChannelStatus(bool active) { |
event_callback_->OnConnectionReady(active); |
} |
@@ -249,16 +255,6 @@ ConnectionToHost::State ConnectionToHost::state() const { |
return state_; |
} |
-void ConnectionToHost::OnChannelInitialized(bool successful) { |
- if (!successful) { |
- LOG(ERROR) << "Failed to connect video channel"; |
- CloseOnError(CHANNEL_CONNECTION_ERROR); |
- return; |
- } |
- |
- NotifyIfChannelsReady(); |
-} |
- |
void ConnectionToHost::NotifyIfChannelsReady() { |
if (!control_dispatcher_.get() || !control_dispatcher_->is_connected()) |
return; |