Chromium Code Reviews| Index: remoting/protocol/channel_dispatcher_base.h |
| diff --git a/remoting/protocol/channel_dispatcher_base.h b/remoting/protocol/channel_dispatcher_base.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..49e779405547c970bf703a36d4f312c03a1d626d |
| --- /dev/null |
| +++ b/remoting/protocol/channel_dispatcher_base.h |
| @@ -0,0 +1,62 @@ |
| +// 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 dispatchers. It is responsible for creation |
|
Wez
2011/11/21 02:39:04
nit: What kind of dispatchers? I/O dispatchers, p
Sergey Ulanov
2011/11/21 22:14:22
Done.
|
| +// of channel with the name specified in the constructor. |
|
Wez
2011/11/21 02:39:04
nit: It's responsible for creating the named chann
Sergey Ulanov
2011/11/21 22:14:22
Done.
|
| +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; |
| + |
| + explicit ChannelDispatcherBase(const char* channel_name); |
|
Wez
2011/11/21 02:39:04
Should this be protected?
Sergey Ulanov
2011/11/21 22:14:22
Done.
|
| + virtual ~ChannelDispatcherBase(); |
| + |
| + // Creates and connects channel in the specified |session|. Called |
|
Wez
2011/11/21 02:39:04
typo: Called -> caller.
Wez
2011/11/21 02:39:04
nit: connects _the_ channel.
Wez
2011/11/21 02:39:04
nit: |session| -> Session. (|session| isn't the t
Sergey Ulanov
2011/11/21 22:14:22
Done.
Sergey Ulanov
2011/11/21 22:14:22
Done.
Sergey Ulanov
2011/11/21 22:14:22
Done.
|
| + // retains ownership of |session|. |
| + void Init(Session* session, const InitializedCallback& callback); |
| + |
| + // Returns true if the channel is currently connected. |
| + bool is_connected() { return channel_.get() != NULL; } |
|
Wez
2011/11/21 02:39:04
nit: This could be { return channel() != NULL; }
Sergey Ulanov
2011/11/21 22:14:22
Done.
|
| + |
| + protected: |
| + 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_ |