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_CLIENT_CONTROL_DISPATCHER_H_ | 5 #ifndef REMOTING_PROTOCOL_CLIENT_CONTROL_DISPATCHER_H_ |
6 #define REMOTING_PROTOCOL_CLIENT_CONTROL_DISPATCHER_H_ | 6 #define REMOTING_PROTOCOL_CLIENT_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/host_stub.h" | 10 #include "remoting/protocol/host_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 remoting { | 17 namespace remoting { |
18 namespace protocol { | 18 namespace protocol { |
19 | 19 |
20 class ClientStub; | 20 class ClientStub; |
21 class ControlMessage; | 21 class ControlMessage; |
22 class BufferedSocketWriter; | 22 class BufferedSocketWriter; |
23 class Session; | 23 class Session; |
24 | 24 |
25 // ClientControlDispatcher dispatches incoming messages on the control | 25 // ClientControlDispatcher dispatches incoming messages on the control |
26 // channel to ClientStub, and also implements HostStub for outgoing | 26 // channel to ClientStub, and also implements HostStub for outgoing |
27 // messages. | 27 // messages. |
28 class ClientControlDispatcher : public HostStub { | 28 class ClientControlDispatcher : public ChannelDispatcherBase, public HostStub { |
29 public: | 29 public: |
30 ClientControlDispatcher(); | 30 ClientControlDispatcher(); |
31 virtual ~ClientControlDispatcher(); | 31 virtual ~ClientControlDispatcher(); |
32 | 32 |
33 // Initialize the control channel and the dispatcher for the | |
34 // |session|. Doesn't take ownership of |session|. | |
35 void Init(protocol::Session* session); | |
36 | |
37 // Sets ClientStub that will be called for each incoming control | 33 // Sets ClientStub that will be called for each incoming control |
38 // message. Doesn't take ownership of |client_stub|. It must outlive | 34 // message. Doesn't take ownership of |client_stub|. It must outlive |
39 // this dispatcher. | 35 // this dispatcher. |
40 void set_client_stub(ClientStub* client_stub) { client_stub_ = client_stub; } | 36 void set_client_stub(ClientStub* client_stub) { client_stub_ = client_stub; } |
41 | 37 |
| 38 protected: |
| 39 // ChannelDispatcherBase overrides. |
| 40 virtual void OnInitialized() OVERRIDE; |
| 41 |
42 private: | 42 private: |
43 void OnMessageReceived(ControlMessage* message, | 43 void OnMessageReceived(ControlMessage* message, |
44 const base::Closure& done_task); | 44 const base::Closure& done_task); |
45 | 45 |
46 ClientStub* client_stub_; | 46 ClientStub* client_stub_; |
47 | 47 |
48 ProtobufMessageReader<ControlMessage> reader_; | 48 ProtobufMessageReader<ControlMessage> reader_; |
49 scoped_refptr<BufferedSocketWriter> writer_; | 49 scoped_refptr<BufferedSocketWriter> writer_; |
50 | 50 |
51 DISALLOW_COPY_AND_ASSIGN(ClientControlDispatcher); | 51 DISALLOW_COPY_AND_ASSIGN(ClientControlDispatcher); |
52 }; | 52 }; |
53 | 53 |
54 } // namespace protocol | 54 } // namespace protocol |
55 } // namespace remoting | 55 } // namespace remoting |
56 | 56 |
57 #endif // REMOTING_PROTOCOL_CLIENT_CONTROL_DISPATCHER_H_ | 57 #endif // REMOTING_PROTOCOL_CLIENT_CONTROL_DISPATCHER_H_ |
OLD | NEW |