OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_ | 5 #ifndef REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_ |
6 #define REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_ | 6 #define REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/task.h" | 10 #include "base/task.h" |
11 #include "remoting/protocol/message_reader.h" | 11 #include "remoting/protocol/message_reader.h" |
12 | 12 |
13 namespace remoting { | 13 namespace remoting { |
14 namespace protocol { | 14 namespace protocol { |
15 | 15 |
16 class ConnectionToClient; | |
16 class ControlMessage; | 17 class ControlMessage; |
17 class EventMessage; | 18 class EventMessage; |
18 class HostStub; | 19 class HostStub; |
19 class InputStub; | 20 class InputStub; |
20 class Session; | 21 class Session; |
21 | 22 |
22 // A message dispatcher used to listen for messages received in | 23 // A message dispatcher used to listen for messages received in |
23 // protocol::Session. It dispatches messages to the corresponding | 24 // protocol::Session. It dispatches messages to the corresponding |
24 // handler. | 25 // handler. |
25 // | 26 // |
26 // Internally it contains an EventStreamReader that decodes data on | 27 // Internally it contains an EventStreamReader that decodes data on |
27 // communications channels into protocol buffer messages. | 28 // communications channels into protocol buffer messages. |
28 // EventStreamReader is registered with protocol::Session given to it. | 29 // EventStreamReader is registered with protocol::Session given to it. |
29 // | 30 // |
30 // Object of this class is owned by ConnectionToClient to dispatch messages | 31 // Object of this class is owned by ConnectionToClient to dispatch messages |
31 // to itself. | 32 // to itself. |
32 class HostMessageDispatcher { | 33 class HostMessageDispatcher { |
33 public: | 34 public: |
34 // Construct a message dispatcher. | 35 // Construct a message dispatcher. |
35 HostMessageDispatcher(); | 36 HostMessageDispatcher(); |
36 virtual ~HostMessageDispatcher(); | 37 virtual ~HostMessageDispatcher(); |
37 | 38 |
38 // Initialize the message dispatcher with the given connection and | 39 // Initialize the message dispatcher with the given connection and |
39 // message handlers. | 40 // message handlers. |
40 void Initialize(protocol::Session* session, | 41 void Initialize(ConnectionToClient* connection, |
simonmorris
2011/04/05 10:47:06
Does HostMessageDispatcher need to use ConnectionT
Alpha Left Google
2011/04/08 00:07:20
We don't want to expose sequence number to the stu
simonmorris
2011/04/08 08:18:25
UpdateSequenceNumber() ends up at the ScreenRecord
| |
41 HostStub* host_stub, InputStub* input_stub); | 42 HostStub* host_stub, InputStub* input_stub); |
42 | 43 |
43 private: | 44 private: |
44 // This method is called by |control_channel_reader_| when a control | 45 // This method is called by |control_channel_reader_| when a control |
45 // message is received. | 46 // message is received. |
46 void OnControlMessageReceived(ControlMessage* message, Task* done_task); | 47 void OnControlMessageReceived(ControlMessage* message, Task* done_task); |
47 | 48 |
48 // This method is called by |event_channel_reader_| when a event | 49 // This method is called by |event_channel_reader_| when a event |
49 // message is received. | 50 // message is received. |
50 void OnEventMessageReceived(EventMessage* message, Task* done_task); | 51 void OnEventMessageReceived(EventMessage* message, Task* done_task); |
51 | 52 |
52 // MessageReader that runs on the control channel. It runs a loop | 53 // MessageReader that runs on the control channel. It runs a loop |
53 // that parses data on the channel and then delegates the message to this | 54 // that parses data on the channel and then delegates the message to this |
54 // class. | 55 // class. |
55 scoped_ptr<ProtobufMessageReader<ControlMessage> > control_message_reader_; | 56 scoped_ptr<ProtobufMessageReader<ControlMessage> > control_message_reader_; |
56 | 57 |
57 // MessageReader that runs on the event channel. | 58 // MessageReader that runs on the event channel. |
58 scoped_ptr<ProtobufMessageReader<EventMessage> > event_message_reader_; | 59 scoped_ptr<ProtobufMessageReader<EventMessage> > event_message_reader_; |
59 | 60 |
61 // Connection that this object belongs to. | |
62 ConnectionToClient* connection_; | |
63 | |
60 // Stubs for host and input. These objects are not owned. | 64 // Stubs for host and input. These objects are not owned. |
61 // They are called on the thread there data is received, i.e. jingle thread. | 65 // They are called on the thread there data is received, i.e. jingle thread. |
62 HostStub* host_stub_; | 66 HostStub* host_stub_; |
63 InputStub* input_stub_; | 67 InputStub* input_stub_; |
64 }; | 68 }; |
65 | 69 |
66 } // namespace protocol | 70 } // namespace protocol |
67 } // namespace remoting | 71 } // namespace remoting |
68 | 72 |
69 #endif // REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_ | 73 #endif // REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_ |
OLD | NEW |