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_CONTROL_DISPATCHER_H_ | 5 #ifndef REMOTING_PROTOCOL_HOST_CONTROL_DISPATCHER_H_ |
6 #define REMOTING_PROTOCOL_HOST_CONTROL_DISPATCHER_H_ | 6 #define REMOTING_PROTOCOL_HOST_CONTROL_DISPATCHER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | |
9 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "remoting/protocol/channel_dispatcher_base.h" |
10 #include "remoting/protocol/client_stub.h" | 10 #include "remoting/protocol/client_stub.h" |
11 #include "remoting/protocol/message_reader.h" | 11 #include "remoting/protocol/message_reader.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 class MessageLoopProxy; | 14 class MessageLoopProxy; |
15 } // namespace base | 15 } // namespace base |
16 | 16 |
| 17 namespace net { |
| 18 class StreamSocket; |
| 19 } // namespace net |
| 20 |
17 namespace remoting { | 21 namespace remoting { |
18 namespace protocol { | 22 namespace protocol { |
19 | 23 |
20 class BufferedSocketWriter; | 24 class BufferedSocketWriter; |
21 class ControlMessage; | 25 class ControlMessage; |
22 class HostStub; | 26 class HostStub; |
23 class Session; | 27 class Session; |
24 | 28 |
25 // HostControlDispatcher dispatches incoming messages on the control | 29 // HostControlDispatcher dispatches incoming messages on the control |
26 // channel to HostStub, and also implements ClientStub for outgoing | 30 // channel to HostStub, and also implements ClientStub for outgoing |
27 // messages. | 31 // messages. |
28 class HostControlDispatcher : public ClientStub { | 32 class HostControlDispatcher : public ChannelDispatcherBase, public ClientStub { |
29 public: | 33 public: |
30 HostControlDispatcher(); | 34 HostControlDispatcher(); |
31 virtual ~HostControlDispatcher(); | 35 virtual ~HostControlDispatcher(); |
32 | 36 |
33 // Initialize the control channel and the dispatcher for the | |
34 // |session|. Doesn't take ownership of |session|. | |
35 void Init(Session* session); | |
36 | |
37 // Sets HostStub that will be called for each incoming control | 37 // Sets HostStub that will be called for each incoming control |
38 // message. Doesn't take ownership of |host_stub|. It must outlive | 38 // message. Doesn't take ownership of |host_stub|. It must outlive |
39 // this dispatcher. | 39 // this dispatcher. |
40 void set_host_stub(HostStub* host_stub) { host_stub_ = host_stub; } | 40 void set_host_stub(HostStub* host_stub) { host_stub_ = host_stub; } |
41 | 41 |
| 42 protected: |
| 43 // ChannelDispatcherBase overrides. |
| 44 virtual void OnInitialized() OVERRIDE; |
| 45 |
42 private: | 46 private: |
43 // This method is called by |reader_| when a message is received. | |
44 void OnMessageReceived(ControlMessage* message, | 47 void OnMessageReceived(ControlMessage* message, |
45 const base::Closure& done_task); | 48 const base::Closure& done_task); |
46 | 49 |
47 HostStub* host_stub_; | 50 HostStub* host_stub_; |
48 | 51 |
49 ProtobufMessageReader<ControlMessage> reader_; | 52 ProtobufMessageReader<ControlMessage> reader_; |
50 scoped_refptr<BufferedSocketWriter> writer_; | 53 scoped_refptr<BufferedSocketWriter> writer_; |
51 | 54 |
52 DISALLOW_COPY_AND_ASSIGN(HostControlDispatcher); | 55 DISALLOW_COPY_AND_ASSIGN(HostControlDispatcher); |
53 }; | 56 }; |
54 | 57 |
55 } // namespace protocol | 58 } // namespace protocol |
56 } // namespace remoting | 59 } // namespace remoting |
57 | 60 |
58 #endif // REMOTING_PROTOCOL_HOST_CONTROL_DISPATCHER_H_ | 61 #endif // REMOTING_PROTOCOL_HOST_CONTROL_DISPATCHER_H_ |
OLD | NEW |