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

Unified Diff: remoting/protocol/channel_dispatcher_base.h

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/audio_writer.cc ('k') | remoting/protocol/channel_dispatcher_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/channel_dispatcher_base.h
diff --git a/remoting/protocol/channel_dispatcher_base.h b/remoting/protocol/channel_dispatcher_base.h
index 705b224caf7b245939e77e9371f01783ac693c7d..0c80b30c5a3758a82853be5338d64d323de05c4d 100644
--- a/remoting/protocol/channel_dispatcher_base.h
+++ b/remoting/protocol/channel_dispatcher_base.h
@@ -10,6 +10,9 @@
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
+#include "remoting/protocol/buffered_socket_writer.h"
+#include "remoting/protocol/errors.h"
+#include "remoting/protocol/message_reader.h"
namespace net {
class StreamSocket;
@@ -28,6 +31,17 @@ class Session;
// messages.
class ChannelDispatcherBase {
public:
+ class EventHandler {
+ public:
+ EventHandler() {}
+ virtual ~EventHandler() {}
+
+ virtual void OnChannelInitialized(
+ ChannelDispatcherBase* channel_dispatcher) = 0;
+ virtual void OnChannelError(ChannelDispatcherBase* channel_dispatcher,
+ ErrorCode error) = 0;
+ };
+
// The callback is called when initialization is finished. The
// parameter is set to true on success.
typedef base::Callback<void(bool)> InitializedCallback;
@@ -38,28 +52,31 @@ class ChannelDispatcherBase {
// |session|. Caller retains ownership of the Session.
void Init(Session* session,
const ChannelConfig& config,
- const InitializedCallback& callback);
+ EventHandler* event_handler);
+
+ const std::string& channel_name() { return channel_name_; }
// Returns true if the channel is currently connected.
- bool is_connected() { return channel() != nullptr; }
+ bool is_connected() { return channel_ != nullptr; }
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;
+ BufferedSocketWriter* writer() { return &writer_; }
+ MessageReader* reader() { return &reader_; }
private:
void OnChannelReady(scoped_ptr<net::StreamSocket> socket);
+ void OnWriteFailed(int error);
std::string channel_name_;
StreamChannelFactory* channel_factory_;
- InitializedCallback initialized_callback_;
+ EventHandler* event_handler_;
scoped_ptr<net::StreamSocket> channel_;
+ BufferedSocketWriter writer_;
+ MessageReader reader_;
+
DISALLOW_COPY_AND_ASSIGN(ChannelDispatcherBase);
};
« no previous file with comments | « remoting/protocol/audio_writer.cc ('k') | remoting/protocol/channel_dispatcher_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698