summaryrefslogtreecommitdiffstats
path: root/remoting/protocol/channel_dispatcher_base.cc
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-22 00:07:13 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-22 00:07:13 +0000
commit2e8b52cb6b93877a77557fa519ddbceec7deab6e (patch)
tree23ad90684e62f9139a7859a2c8a935284bad33c6 /remoting/protocol/channel_dispatcher_base.cc
parentd1850b19dccf7be8310d031b956f27b4b2a71e9d (diff)
downloadchromium_src-2e8b52cb6b93877a77557fa519ddbceec7deab6e.zip
chromium_src-2e8b52cb6b93877a77557fa519ddbceec7deab6e.tar.gz
chromium_src-2e8b52cb6b93877a77557fa519ddbceec7deab6e.tar.bz2
Remove event_channel() and control_channel() from Session interface.
Now all channels are created using CreateStreamChannel() as they should be! Review URL: http://codereview.chromium.org/8587053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111045 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/protocol/channel_dispatcher_base.cc')
-rw-r--r--remoting/protocol/channel_dispatcher_base.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/remoting/protocol/channel_dispatcher_base.cc b/remoting/protocol/channel_dispatcher_base.cc
new file mode 100644
index 0000000..21f1187
--- /dev/null
+++ b/remoting/protocol/channel_dispatcher_base.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/protocol/channel_dispatcher_base.h"
+
+#include "base/bind.h"
+#include "net/socket/stream_socket.h"
+#include "remoting/protocol/session.h"
+
+namespace remoting {
+namespace protocol {
+
+ChannelDispatcherBase::ChannelDispatcherBase(const char* channel_name)
+ : channel_name_(channel_name),
+ session_(NULL) {
+}
+
+ChannelDispatcherBase::~ChannelDispatcherBase() {
+ if (session_)
+ session_->CancelChannelCreation(channel_name_);
+}
+
+void ChannelDispatcherBase::Init(Session* session,
+ const InitializedCallback& callback) {
+ DCHECK(session);
+ session_ = session;
+ initialized_callback_ = callback;
+
+ session_->CreateStreamChannel(channel_name_, base::Bind(
+ &ChannelDispatcherBase::OnChannelReady, base::Unretained(this)));
+}
+
+void ChannelDispatcherBase::OnChannelReady(net::StreamSocket* socket) {
+ if (!socket) {
+ initialized_callback_.Run(false);
+ return;
+ }
+
+ channel_.reset(socket);
+
+ OnInitialized();
+
+ initialized_callback_.Run(true);
+}
+
+} // namespace protocol
+} // namespace remoting