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/cursor_shape_stub.h" |
11 #include "remoting/protocol/host_stub.h" | 12 #include "remoting/protocol/host_stub.h" |
12 #include "remoting/protocol/message_reader.h" | 13 #include "remoting/protocol/message_reader.h" |
13 | 14 |
14 namespace remoting { | 15 namespace remoting { |
15 namespace protocol { | 16 namespace protocol { |
16 | 17 |
17 class ClientStub; | 18 class ClientStub; |
18 class ControlMessage; | 19 class ControlMessage; |
19 class BufferedSocketWriter; | 20 class BufferedSocketWriter; |
20 class Session; | 21 class Session; |
21 | 22 |
22 // ClientControlDispatcher dispatches incoming messages on the control | 23 // ClientControlDispatcher dispatches incoming messages on the control |
23 // channel to ClientStub or ClipboardStub, and also implements ClipboardStub | 24 // channel to ClientStub, ClipboardStub or CursorShapeStub. |
24 // and HostStub for outgoing messages. | 25 // It also implements ClipboardStub and HostStub for outgoing messages. |
25 class ClientControlDispatcher : public ChannelDispatcherBase, | 26 class ClientControlDispatcher : public ChannelDispatcherBase, |
26 public ClipboardStub, | 27 public ClipboardStub, |
27 public HostStub { | 28 public HostStub { |
28 public: | 29 public: |
29 ClientControlDispatcher(); | 30 ClientControlDispatcher(); |
30 virtual ~ClientControlDispatcher(); | 31 virtual ~ClientControlDispatcher(); |
31 | 32 |
32 // ClipboardStub implementation. | 33 // ClipboardStub implementation. |
33 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; | 34 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; |
34 | 35 |
35 // HostStub implementation. | 36 // HostStub implementation. |
36 virtual void NotifyClientDimensions( | 37 virtual void NotifyClientDimensions( |
37 const ClientDimensions& dimensions) OVERRIDE; | 38 const ClientDimensions& dimensions) OVERRIDE; |
38 virtual void ControlVideo(const VideoControl& video_control) OVERRIDE; | 39 virtual void ControlVideo(const VideoControl& video_control) OVERRIDE; |
39 | 40 |
40 // Sets the ClientStub that will be called for each incoming control | 41 // Sets the ClientStub that will be called for each incoming control |
41 // message. |client_stub| must outlive this object. | 42 // message. |client_stub| must outlive this object. |
42 void set_client_stub(ClientStub* client_stub) { client_stub_ = client_stub; } | 43 void set_client_stub(ClientStub* client_stub) { client_stub_ = client_stub; } |
43 | 44 |
44 // Sets the ClipboardStub that will be called for each incoming clipboard | 45 // Sets the ClipboardStub that will be called for each incoming clipboard |
45 // message. |clipboard_stub| must outlive this object. | 46 // message. |clipboard_stub| must outlive this object. |
46 void set_clipboard_stub(ClipboardStub* clipboard_stub) { | 47 void set_clipboard_stub(ClipboardStub* clipboard_stub) { |
47 clipboard_stub_ = clipboard_stub; | 48 clipboard_stub_ = clipboard_stub; |
48 } | 49 } |
49 | 50 |
| 51 // Sets stub to call for incoming cursor shape messages. |
| 52 void set_cursor_shape_stub(CursorShapeStub* cursor_shape_stub) { |
| 53 cursor_shape_stub_ = cursor_shape_stub; |
| 54 } |
| 55 |
50 protected: | 56 protected: |
51 // ChannelDispatcherBase overrides. | 57 // ChannelDispatcherBase overrides. |
52 virtual void OnInitialized() OVERRIDE; | 58 virtual void OnInitialized() OVERRIDE; |
53 | 59 |
54 private: | 60 private: |
55 void OnMessageReceived(scoped_ptr<ControlMessage> message, | 61 void OnMessageReceived(scoped_ptr<ControlMessage> message, |
56 const base::Closure& done_task); | 62 const base::Closure& done_task); |
57 | 63 |
58 ClientStub* client_stub_; | 64 ClientStub* client_stub_; |
59 ClipboardStub* clipboard_stub_; | 65 ClipboardStub* clipboard_stub_; |
| 66 CursorShapeStub* cursor_shape_stub_; |
60 | 67 |
61 ProtobufMessageReader<ControlMessage> reader_; | 68 ProtobufMessageReader<ControlMessage> reader_; |
62 scoped_refptr<BufferedSocketWriter> writer_; | 69 scoped_refptr<BufferedSocketWriter> writer_; |
63 | 70 |
64 DISALLOW_COPY_AND_ASSIGN(ClientControlDispatcher); | 71 DISALLOW_COPY_AND_ASSIGN(ClientControlDispatcher); |
65 }; | 72 }; |
66 | 73 |
67 } // namespace protocol | 74 } // namespace protocol |
68 } // namespace remoting | 75 } // namespace remoting |
69 | 76 |
70 #endif // REMOTING_PROTOCOL_CLIENT_CONTROL_DISPATCHER_H_ | 77 #endif // REMOTING_PROTOCOL_CLIENT_CONTROL_DISPATCHER_H_ |
OLD | NEW |