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

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

Issue 6271004: Changed MessageReader so that it doesn't read from the socket if there are (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ref-counted MessageReader Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/fake_session.cc ('k') | remoting/protocol/host_message_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/scoped_ptr.h" 9 #include "base/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
15 class EventMessage;
16
17 namespace protocol { 14 namespace protocol {
18 15
19 class ControlMessage; 16 class ControlMessage;
17 class EventMessage;
20 class HostStub; 18 class HostStub;
21 class InputStub; 19 class InputStub;
22 class Session; 20 class Session;
23 21
24 // A message dispatcher used to listen for messages received in 22 // A message dispatcher used to listen for messages received in
25 // protocol::Session. It dispatches messages to the corresponding 23 // protocol::Session. It dispatches messages to the corresponding
26 // handler. 24 // handler.
27 // 25 //
28 // Internally it contains an EventStreamReader that decodes data on 26 // Internally it contains an EventStreamReader that decodes data on
29 // communications channels into protocol buffer messages. 27 // communications channels into protocol buffer messages.
30 // EventStreamReader is registered with protocol::Session given to it. 28 // EventStreamReader is registered with protocol::Session given to it.
31 // 29 //
32 // Object of this class is owned by ConnectionToClient to dispatch messages 30 // Object of this class is owned by ConnectionToClient to dispatch messages
33 // to itself. 31 // to itself.
34 class HostMessageDispatcher { 32 class HostMessageDispatcher {
35 public: 33 public:
36 // Construct a message dispatcher. 34 // Construct a message dispatcher.
37 HostMessageDispatcher(); 35 HostMessageDispatcher();
38 virtual ~HostMessageDispatcher(); 36 virtual ~HostMessageDispatcher();
39 37
40 // Initialize the message dispatcher with the given connection and 38 // Initialize the message dispatcher with the given connection and
41 // message handlers. 39 // message handlers.
42 void Initialize(protocol::Session* session, 40 void Initialize(protocol::Session* session,
43 HostStub* host_stub, InputStub* input_stub); 41 HostStub* host_stub, InputStub* input_stub);
44 42
45 private: 43 private:
46 // This method is called by |control_channel_reader_| when a control 44 // This method is called by |control_channel_reader_| when a control
47 // message is received. 45 // message is received.
48 void OnControlMessageReceived(ControlMessage* message); 46 void OnControlMessageReceived(ControlMessage* message, Task* done_task);
49 47
50 // This method is called by |event_channel_reader_| when a event 48 // This method is called by |event_channel_reader_| when a event
51 // message is received. 49 // message is received.
52 void OnEventMessageReceived(EventMessage* message); 50 void OnEventMessageReceived(EventMessage* message, Task* done_task);
53 51
54 // MessageReader that runs on the control channel. It runs a loop 52 // MessageReader that runs on the control channel. It runs a loop
55 // that parses data on the channel and then delegates the message to this 53 // that parses data on the channel and then delegates the message to this
56 // class. 54 // class.
57 scoped_ptr<ProtobufMessageReader<ControlMessage> > control_message_reader_; 55 scoped_ptr<ProtobufMessageReader<ControlMessage> > control_message_reader_;
58 56
59 // MessageReader that runs on the event channel. 57 // MessageReader that runs on the event channel.
60 scoped_ptr<ProtobufMessageReader<EventMessage> > event_message_reader_; 58 scoped_ptr<ProtobufMessageReader<EventMessage> > event_message_reader_;
61 59
62 // Stubs for host and input. These objects are not owned. 60 // Stubs for host and input. These objects are not owned.
63 // They are called on the thread there data is received, i.e. jingle thread. 61 // They are called on the thread there data is received, i.e. jingle thread.
64 HostStub* host_stub_; 62 HostStub* host_stub_;
65 InputStub* input_stub_; 63 InputStub* input_stub_;
66 }; 64 };
67 65
68 } // namespace protocol 66 } // namespace protocol
69 } // namespace remoting 67 } // namespace remoting
70 68
71 #endif // REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_ 69 #endif // REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_
OLDNEW
« no previous file with comments | « remoting/protocol/fake_session.cc ('k') | remoting/protocol/host_message_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698