| OLD | NEW |
| 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/ref_counted.h" | |
| 10 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 11 #include "base/task.h" | 10 #include "base/task.h" |
| 12 | 11 |
| 13 namespace remoting { | 12 namespace remoting { |
| 14 | 13 |
| 15 class EventMessage; | 14 class EventMessage; |
| 16 class MessageReader; | 15 class MessageReader; |
| 17 | 16 |
| 18 namespace protocol { | 17 namespace protocol { |
| 19 | 18 |
| 20 class ControlMessage; | 19 class ControlMessage; |
| 21 class HostStub; | 20 class HostStub; |
| 22 class InputStub; | 21 class InputStub; |
| 23 class Session; | 22 class Session; |
| 24 | 23 |
| 25 // A message dispatcher used to listen for messages received in | 24 // A message dispatcher used to listen for messages received in |
| 26 // protocol::Session. It dispatches messages to the corresponding | 25 // protocol::Session. It dispatches messages to the corresponding |
| 27 // handler. | 26 // handler. |
| 28 // | 27 // |
| 29 // Internally it contains an EventStreamReader that decodes data on | 28 // Internally it contains an EventStreamReader that decodes data on |
| 30 // communications channels into protocol buffer messages. | 29 // communications channels into protocol buffer messages. |
| 31 // EventStreamReader is registered with protocol::Session given to it. | 30 // EventStreamReader is registered with protocol::Session given to it. |
| 32 // | 31 // |
| 33 // Object of this class is owned by ChromotingHost to dispatch messages | 32 // Object of this class is owned by ChromotingHost to dispatch messages |
| 34 // to itself. | 33 // to itself. |
| 35 class HostMessageDispatcher : | 34 class HostMessageDispatcher { |
| 36 public base::RefCountedThreadSafe<HostMessageDispatcher> { | |
| 37 public: | 35 public: |
| 38 // Construct a message dispatcher. | 36 // Construct a message dispatcher. |
| 39 HostMessageDispatcher(); | 37 HostMessageDispatcher(); |
| 40 virtual ~HostMessageDispatcher(); | 38 virtual ~HostMessageDispatcher(); |
| 41 | 39 |
| 42 // Initialize the message dispatcher with the given connection and | 40 // Initialize the message dispatcher with the given connection and |
| 43 // message handlers. | 41 // message handlers. |
| 44 // Return true if initalization was successful. | 42 // Return true if initalization was successful. |
| 45 bool Initialize(protocol::Session* session, | 43 bool Initialize(protocol::Session* session, |
| 46 HostStub* host_stub, InputStub* input_stub); | 44 HostStub* host_stub, InputStub* input_stub); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 65 // Stubs for host and input. These objects are not owned. | 63 // Stubs for host and input. These objects are not owned. |
| 66 // They are called on the thread there data is received, i.e. jingle thread. | 64 // They are called on the thread there data is received, i.e. jingle thread. |
| 67 HostStub* host_stub_; | 65 HostStub* host_stub_; |
| 68 InputStub* input_stub_; | 66 InputStub* input_stub_; |
| 69 }; | 67 }; |
| 70 | 68 |
| 71 } // namespace protocol | 69 } // namespace protocol |
| 72 } // namespace remoting | 70 } // namespace remoting |
| 73 | 71 |
| 74 #endif // REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_ | 72 #endif // REMOTING_PROTOCOL_HOST_MESSAGE_DISPATCHER_H_ |
| OLD | NEW |