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

Unified Diff: remoting/protocol/channel_dispatcher_base.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/channel_dispatcher_base.h ('k') | remoting/protocol/channel_multiplexer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/channel_dispatcher_base.cc
diff --git a/remoting/protocol/channel_dispatcher_base.cc b/remoting/protocol/channel_dispatcher_base.cc
index 0209cc27063766888e99d621e330ca27b2a36d73..ee90ee56dcbc7bc02756ebf80e919e90889d6cbd 100644
--- a/remoting/protocol/channel_dispatcher_base.cc
+++ b/remoting/protocol/channel_dispatcher_base.cc
@@ -15,17 +15,19 @@ namespace protocol {
ChannelDispatcherBase::ChannelDispatcherBase(const char* channel_name)
: channel_name_(channel_name),
- channel_factory_(nullptr) {
+ channel_factory_(nullptr),
+ event_handler_(nullptr) {
}
ChannelDispatcherBase::~ChannelDispatcherBase() {
+ writer()->Close();
if (channel_factory_)
channel_factory_->CancelChannelCreation(channel_name_);
}
void ChannelDispatcherBase::Init(Session* session,
const ChannelConfig& config,
- const InitializedCallback& callback) {
+ EventHandler* event_handler) {
DCHECK(session);
switch (config.transport) {
case ChannelConfig::TRANSPORT_MUX_STREAM:
@@ -37,12 +39,10 @@ void ChannelDispatcherBase::Init(Session* session,
break;
default:
- NOTREACHED();
- callback.Run(false);
- return;
+ LOG(FATAL) << "Unknown transport type: " << config.transport;
}
- initialized_callback_ = callback;
+ event_handler_ = event_handler;
channel_factory_->CreateChannel(channel_name_, base::Bind(
&ChannelDispatcherBase::OnChannelReady, base::Unretained(this)));
@@ -51,16 +51,21 @@ void ChannelDispatcherBase::Init(Session* session,
void ChannelDispatcherBase::OnChannelReady(
scoped_ptr<net::StreamSocket> socket) {
if (!socket.get()) {
- initialized_callback_.Run(false);
+ event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR);
return;
}
channel_factory_ = nullptr;
channel_ = socket.Pass();
+ writer_.Init(channel_.get(), base::Bind(&ChannelDispatcherBase::OnWriteFailed,
+ base::Unretained(this)));
+ reader_.StartReading(channel_.get());
- OnInitialized();
+ event_handler_->OnChannelInitialized(this);
+}
- initialized_callback_.Run(true);
+void ChannelDispatcherBase::OnWriteFailed(int error) {
+ event_handler_->OnChannelError(this, CHANNEL_CONNECTION_ERROR);
}
} // namespace protocol
« no previous file with comments | « remoting/protocol/channel_dispatcher_base.h ('k') | remoting/protocol/channel_multiplexer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698