OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "remoting/protocol/channel_dispatcher_base.h" | 9 #include "remoting/protocol/channel_dispatcher_base.h" |
10 #include "remoting/protocol/clipboard_stub.h" | 10 #include "remoting/protocol/clipboard_stub.h" |
11 #include "remoting/protocol/host_stub.h" | 11 #include "remoting/protocol/host_stub.h" |
12 #include "remoting/protocol/message_reader.h" | 12 #include "remoting/protocol/message_reader.h" |
13 | 13 |
14 namespace remoting { | 14 namespace remoting { |
15 namespace protocol { | 15 namespace protocol { |
16 | 16 |
17 class ClientStub; | 17 class ClientStub; |
18 class ControlMessage; | 18 class ControlMessage; |
19 class BufferedSocketWriter; | 19 class BufferedSocketWriter; |
20 class Session; | 20 class Session; |
21 | 21 |
22 // ClientControlDispatcher dispatches incoming messages on the control | 22 // ClientControlDispatcher dispatches incoming messages on the control |
23 // channel to ClientStub, and also implements ClipboardStub and HostStub for | 23 // channel to ClientStub or ClipboardStub, and also implements ClipboardStub |
24 // outgoing messages. | 24 // and HostStub for outgoing messages. |
25 class ClientControlDispatcher : public ChannelDispatcherBase, | 25 class ClientControlDispatcher : public ChannelDispatcherBase, |
26 public ClipboardStub, | 26 public ClipboardStub, |
27 public HostStub { | 27 public HostStub { |
28 public: | 28 public: |
29 ClientControlDispatcher(); | 29 ClientControlDispatcher(); |
30 virtual ~ClientControlDispatcher(); | 30 virtual ~ClientControlDispatcher(); |
31 | 31 |
32 // ClipboardStub implementation. | 32 // ClipboardStub implementation. |
33 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; | 33 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; |
34 | 34 |
35 // Sets ClientStub that will be called for each incoming control | 35 // Sets the ClientStub that will be called for each incoming control |
36 // message. Doesn't take ownership of |client_stub|. It must outlive | 36 // message. |client_stub| must outlive this object. |
37 // this dispatcher. | |
38 void set_client_stub(ClientStub* client_stub) { client_stub_ = client_stub; } | 37 void set_client_stub(ClientStub* client_stub) { client_stub_ = client_stub; } |
39 | 38 |
| 39 // Sets the ClipboardStub that will be called for each incoming clipboard |
| 40 // message. |clipboard_stub| must outlive this object. |
| 41 void set_clipboard_stub(ClipboardStub* clipboard_stub) { |
| 42 clipboard_stub_ = clipboard_stub; |
| 43 } |
| 44 |
40 protected: | 45 protected: |
41 // ChannelDispatcherBase overrides. | 46 // ChannelDispatcherBase overrides. |
42 virtual void OnInitialized() OVERRIDE; | 47 virtual void OnInitialized() OVERRIDE; |
43 | 48 |
44 private: | 49 private: |
45 void OnMessageReceived(scoped_ptr<ControlMessage> message, | 50 void OnMessageReceived(scoped_ptr<ControlMessage> message, |
46 const base::Closure& done_task); | 51 const base::Closure& done_task); |
47 | 52 |
48 ClientStub* client_stub_; | 53 ClientStub* client_stub_; |
| 54 ClipboardStub* clipboard_stub_; |
49 | 55 |
50 ProtobufMessageReader<ControlMessage> reader_; | 56 ProtobufMessageReader<ControlMessage> reader_; |
51 scoped_refptr<BufferedSocketWriter> writer_; | 57 scoped_refptr<BufferedSocketWriter> writer_; |
52 | 58 |
53 DISALLOW_COPY_AND_ASSIGN(ClientControlDispatcher); | 59 DISALLOW_COPY_AND_ASSIGN(ClientControlDispatcher); |
54 }; | 60 }; |
55 | 61 |
56 } // namespace protocol | 62 } // namespace protocol |
57 } // namespace remoting | 63 } // namespace remoting |
58 | 64 |
59 #endif // REMOTING_PROTOCOL_CLIENT_CONTROL_DISPATCHER_H_ | 65 #endif // REMOTING_PROTOCOL_CLIENT_CONTROL_DISPATCHER_H_ |
OLD | NEW |