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

Unified Diff: remoting/protocol/connection_to_client.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_client.h ('k') | remoting/protocol/connection_to_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/connection_to_client.cc
diff --git a/remoting/protocol/connection_to_client.cc b/remoting/protocol/connection_to_client.cc
index 536fa75255de21f9d602a2ff929f0237162d2125..6894a9c421baec01b95638d23992b4f882424638 100644
--- a/remoting/protocol/connection_to_client.cc
+++ b/remoting/protocol/connection_to_client.cc
@@ -119,34 +119,26 @@ void ConnectionToClient::OnSessionStateChange(Session::State state) {
case Session::AUTHENTICATED:
// Initialize channels.
control_dispatcher_.reset(new HostControlDispatcher());
- control_dispatcher_->Init(
- session_.get(), session_->config().control_config(),
- base::Bind(&ConnectionToClient::OnChannelInitialized,
- base::Unretained(this)));
+ control_dispatcher_->Init(session_.get(),
+ session_->config().control_config(), this);
control_dispatcher_->set_clipboard_stub(clipboard_stub_);
control_dispatcher_->set_host_stub(host_stub_);
event_dispatcher_.reset(new HostEventDispatcher());
- event_dispatcher_->Init(
- session_.get(), session_->config().event_config(),
- base::Bind(&ConnectionToClient::OnChannelInitialized,
- base::Unretained(this)));
+ event_dispatcher_->Init(session_.get(), session_->config().event_config(),
+ this);
event_dispatcher_->set_input_stub(input_stub_);
event_dispatcher_->set_event_timestamp_callback(base::Bind(
&ConnectionToClient::OnEventTimestamp, base::Unretained(this)));
video_dispatcher_.reset(new HostVideoDispatcher());
- video_dispatcher_->Init(
- session_.get(), session_->config().video_config(),
- base::Bind(&ConnectionToClient::OnChannelInitialized,
- base::Unretained(this)));
+ video_dispatcher_->Init(session_.get(), session_->config().video_config(),
+ this);
audio_writer_ = AudioWriter::Create(session_->config());
if (audio_writer_.get()) {
- audio_writer_->Init(
- session_.get(), session_->config().audio_config(),
- base::Bind(&ConnectionToClient::OnChannelInitialized,
- base::Unretained(this)));
+ audio_writer_->Init(session_.get(), session_->config().audio_config(),
+ this);
}
// Notify the handler after initializing the channels, so that
@@ -170,28 +162,33 @@ void ConnectionToClient::OnSessionRouteChange(
handler_->OnRouteChange(this, channel_name, route);
}
-void ConnectionToClient::OnChannelInitialized(bool successful) {
+void ConnectionToClient::OnChannelInitialized(
+ ChannelDispatcherBase* channel_dispatcher) {
DCHECK(CalledOnValidThread());
- if (!successful) {
- LOG(ERROR) << "Failed to connect a channel";
- Close(CHANNEL_CONNECTION_ERROR);
- return;
- }
-
NotifyIfChannelsReady();
}
+void ConnectionToClient::OnChannelError(
+ ChannelDispatcherBase* channel_dispatcher,
+ ErrorCode error) {
+ DCHECK(CalledOnValidThread());
+
+ LOG(ERROR) << "Failed to connect channel "
+ << channel_dispatcher->channel_name();
+ Close(CHANNEL_CONNECTION_ERROR);
+}
+
void ConnectionToClient::NotifyIfChannelsReady() {
DCHECK(CalledOnValidThread());
- if (!control_dispatcher_.get() || !control_dispatcher_->is_connected())
+ if (!control_dispatcher_ || !control_dispatcher_->is_connected())
return;
- if (!event_dispatcher_.get() || !event_dispatcher_->is_connected())
+ if (!event_dispatcher_ || !event_dispatcher_->is_connected())
return;
- if (!video_dispatcher_.get() || !video_dispatcher_->is_connected())
+ if (!video_dispatcher_ || !video_dispatcher_->is_connected())
return;
- if ((!audio_writer_.get() || !audio_writer_->is_connected()) &&
+ if ((!audio_writer_ || !audio_writer_->is_connected()) &&
session_->config().is_audio_enabled()) {
return;
}
« no previous file with comments | « remoting/protocol/connection_to_client.h ('k') | remoting/protocol/connection_to_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698