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. Doesn't take ownership of |client_stub|, which must outlive |
37 // this dispatcher. | 37 // this dispatcher. |
38 void set_client_stub(ClientStub* client_stub) { client_stub_ = client_stub; } | 38 void set_client_stub(ClientStub* client_stub) { client_stub_ = client_stub; } |
39 | 39 |
40 // Sets the ClipboardStub that will be called for each incoming clipboard | |
41 // message. Doesn't take ownership of |clipboard_stub|, which must outlive | |
Wez
2012/03/30 22:20:15
nit: Could just say "|clipboard_stub| must outlive
simonmorris
2012/03/30 22:36:07
Done.
| |
42 // this dispatcher. | |
43 void set_clipboard_stub(ClipboardStub* clipboard_stub) { | |
44 clipboard_stub_ = clipboard_stub; | |
45 } | |
46 | |
40 protected: | 47 protected: |
41 // ChannelDispatcherBase overrides. | 48 // ChannelDispatcherBase overrides. |
42 virtual void OnInitialized() OVERRIDE; | 49 virtual void OnInitialized() OVERRIDE; |
43 | 50 |
44 private: | 51 private: |
45 void OnMessageReceived(scoped_ptr<ControlMessage> message, | 52 void OnMessageReceived(scoped_ptr<ControlMessage> message, |
46 const base::Closure& done_task); | 53 const base::Closure& done_task); |
47 | 54 |
48 ClientStub* client_stub_; | 55 ClientStub* client_stub_; |
56 ClipboardStub* clipboard_stub_; | |
49 | 57 |
50 ProtobufMessageReader<ControlMessage> reader_; | 58 ProtobufMessageReader<ControlMessage> reader_; |
51 scoped_refptr<BufferedSocketWriter> writer_; | 59 scoped_refptr<BufferedSocketWriter> writer_; |
52 | 60 |
53 DISALLOW_COPY_AND_ASSIGN(ClientControlDispatcher); | 61 DISALLOW_COPY_AND_ASSIGN(ClientControlDispatcher); |
54 }; | 62 }; |
55 | 63 |
56 } // namespace protocol | 64 } // namespace protocol |
57 } // namespace remoting | 65 } // namespace remoting |
58 | 66 |
59 #endif // REMOTING_PROTOCOL_CLIENT_CONTROL_DISPATCHER_H_ | 67 #endif // REMOTING_PROTOCOL_CLIENT_CONTROL_DISPATCHER_H_ |
OLD | NEW |