diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 00:07:13 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 00:07:13 +0000 |
commit | 2e8b52cb6b93877a77557fa519ddbceec7deab6e (patch) | |
tree | 23ad90684e62f9139a7859a2c8a935284bad33c6 /remoting/protocol/channel_dispatcher_base.h | |
parent | d1850b19dccf7be8310d031b956f27b4b2a71e9d (diff) | |
download | chromium_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.h')
-rw-r--r-- | remoting/protocol/channel_dispatcher_base.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/remoting/protocol/channel_dispatcher_base.h b/remoting/protocol/channel_dispatcher_base.h new file mode 100644 index 0000000..26a8d2b --- /dev/null +++ b/remoting/protocol/channel_dispatcher_base.h @@ -0,0 +1,65 @@ +// 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. + +#ifndef REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ +#define REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ + +#include <string> + +#include "base/basictypes.h" +#include "base/callback.h" +#include "base/memory/scoped_ptr.h" + +namespace net { +class StreamSocket; +} // namespace net + +namespace remoting { +namespace protocol { + +class Session; + +// Base class for channel message dispatchers. It's responsible for +// creating the named channel. Derived dispatchers then dispatch +// incoming messages on this channel as well as send outgoing +// messages. +class ChannelDispatcherBase { + public: + // The callback is called when initialization is finished. The + // parameter is set to true on success. + typedef base::Callback<void(bool)> InitializedCallback; + + virtual ~ChannelDispatcherBase(); + + // Creates and connects the channel in the specified + // |session|. Caller retains ownership of the Session. + void Init(Session* session, const InitializedCallback& callback); + + // Returns true if the channel is currently connected. + bool is_connected() { return channel() != NULL; } + + protected: + explicit ChannelDispatcherBase(const char* channel_name); + + net::StreamSocket* channel() { return channel_.get(); } + + // Called when channel is initialized. Must be overriden in the + // child classes. Should not delete the dispatcher. + virtual void OnInitialized() = 0; + + private: + void OnChannelReady(net::StreamSocket* socket); + + std::string channel_name_; + Session* session_; + InitializedCallback initialized_callback_; + scoped_ptr<net::StreamSocket> channel_; + + DISALLOW_COPY_AND_ASSIGN(ChannelDispatcherBase); +}; + +} // namespace protocol +} // namespace remoting + +#endif // REMOTING_PROTOCOL_CHANNEL_DISPATCHER_BASE_H_ |