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

Side by Side Diff: remoting/protocol/host_message_dispatcher.h

Issue 8468022: Refactor channel dispatchers on the host side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_
6 #define REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/task.h"
11 #include "remoting/protocol/message_reader.h"
12
13 namespace remoting {
14 namespace protocol {
15
16 class ConnectionToClient;
17 class ControlMessage;
18 class EventMessage;
19 class HostStub;
20 class InputStub;
21 class Session;
22
23 // A message dispatcher used to listen for messages received in
24 // protocol::Session. It dispatches messages to the corresponding
25 // handler.
26 //
27 // Internally it contains an EventStreamReader that decodes data on
28 // communications channels into protocol buffer messages.
29 // EventStreamReader is registered with protocol::Session given to it.
30 //
31 // Object of this class is owned by ConnectionToClient to dispatch messages
32 // to itself.
33 class HostMessageDispatcher {
34 public:
35 // Construct a message dispatcher.
36 HostMessageDispatcher();
37 virtual ~HostMessageDispatcher();
38
39 // Initialize the message dispatcher with the given connection and
40 // message handlers.
41 void Initialize(ConnectionToClient* connection,
42 HostStub* host_stub, InputStub* input_stub);
43
44 private:
45 // This method is called by |control_channel_reader_| when a control
46 // message is received.
47 void OnControlMessageReceived(ControlMessage* message,
48 const base::Closure& done_task);
49
50 // This method is called by |event_channel_reader_| when a event
51 // message is received.
52 void OnEventMessageReceived(EventMessage* message,
53 const base::Closure& done_task);
54
55 // MessageReader that runs on the control channel. It runs a loop
56 // that parses data on the channel and then delegates the message to this
57 // class.
58 scoped_ptr<ProtobufMessageReader<ControlMessage> > control_message_reader_;
59
60 // MessageReader that runs on the event channel.
61 scoped_ptr<ProtobufMessageReader<EventMessage> > event_message_reader_;
62
63 // Connection that this object belongs to.
64 ConnectionToClient* connection_;
65
66 // Stubs for host and input. These objects are not owned.
67 // They are called on the thread there data is received, i.e. jingle thread.
68 HostStub* host_stub_;
69 InputStub* input_stub_;
70 };
71
72 } // namespace protocol
73 } // namespace remoting
74
75 #endif // REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698