Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Unified Diff: remoting/protocol/connection_to_host.cc

Issue 841773005: Cleanup channel dispatchers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/connection_to_host.h ('k') | remoting/protocol/host_control_dispatcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « remoting/protocol/connection_to_host.h ('k') | remoting/protocol/host_control_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698