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_EVENT_DISPATCHER_H_ | 5 #ifndef REMOTING_PROTOCOL_HOST_EVENT_DISPATCHER_H_ |
6 #define REMOTING_PROTOCOL_HOST_EVENT_DISPATCHER_H_ | 6 #define REMOTING_PROTOCOL_HOST_EVENT_DISPATCHER_H_ |
7 | 7 |
8 #include "remoting/protocol/channel_dispatcher_base.h" | 8 #include "remoting/protocol/channel_dispatcher_base.h" |
9 #include "remoting/protocol/message_reader.h" | 9 #include "remoting/protocol/message_reader.h" |
10 | 10 |
11 namespace remoting { | 11 namespace remoting { |
12 namespace protocol { | 12 namespace protocol { |
13 | 13 |
14 class ClipboardStub; | |
14 class EventMessage; | 15 class EventMessage; |
15 class InputStub; | 16 class InputStub; |
16 | 17 |
17 // HostEventDispatcher dispatches incoming messages on the event | 18 // HostEventDispatcher dispatches incoming messages on the event |
18 // channel to InputStub. | 19 // channel to InputStub or ClipboardStub. |
19 class HostEventDispatcher : public ChannelDispatcherBase { | 20 class HostEventDispatcher : public ChannelDispatcherBase { |
20 public: | 21 public: |
21 typedef base::Callback<void(int64)> SequenceNumberCallback; | 22 typedef base::Callback<void(int64)> SequenceNumberCallback; |
22 | 23 |
23 HostEventDispatcher(); | 24 HostEventDispatcher(); |
24 virtual ~HostEventDispatcher(); | 25 virtual ~HostEventDispatcher(); |
25 | 26 |
27 // Set the ClipboardStub that will be called for each incoming clipboard | |
28 // message. Doesn't take ownership of |clipboard_stub|. It must outlive | |
29 // the dispatcher. | |
30 void set_clipboard_stub(ClipboardStub* clipboard_stub) { | |
Sergey Ulanov
2012/03/09 00:23:41
Would it be better to use control channel for clip
simonmorris
2012/03/09 00:34:14
I think it's better to send clipboard events over
Wez
2012/03/09 00:44:07
We'll have a keyboard-event-specific reliability p
| |
31 clipboard_stub_ = clipboard_stub; | |
32 } | |
33 | |
26 // Set InputStub that will be called for each incoming input | 34 // Set InputStub that will be called for each incoming input |
27 // message. Doesn't take ownership of |input_stub|. It must outlive | 35 // message. Doesn't take ownership of |input_stub|. It must outlive |
28 // the dispatcher. | 36 // the dispatcher. |
29 void set_input_stub(InputStub* input_stub) { input_stub_ = input_stub; } | 37 void set_input_stub(InputStub* input_stub) { input_stub_ = input_stub; } |
30 | 38 |
31 // Set callback to notify of each message's sequence number. The | 39 // Set callback to notify of each message's sequence number. The |
32 // callback cannot tear down this object. | 40 // callback cannot tear down this object. |
33 void set_sequence_number_callback(const SequenceNumberCallback& value) { | 41 void set_sequence_number_callback(const SequenceNumberCallback& value) { |
34 sequence_number_callback_ = value; | 42 sequence_number_callback_ = value; |
35 } | 43 } |
36 | 44 |
37 protected: | 45 protected: |
38 // ChannelDispatcherBase overrides. | 46 // ChannelDispatcherBase overrides. |
39 virtual void OnInitialized() OVERRIDE; | 47 virtual void OnInitialized() OVERRIDE; |
40 | 48 |
41 private: | 49 private: |
42 void OnMessageReceived(EventMessage* message, | 50 void OnMessageReceived(EventMessage* message, |
43 const base::Closure& done_task); | 51 const base::Closure& done_task); |
44 | 52 |
53 ClipboardStub* clipboard_stub_; | |
45 InputStub* input_stub_; | 54 InputStub* input_stub_; |
46 SequenceNumberCallback sequence_number_callback_; | 55 SequenceNumberCallback sequence_number_callback_; |
47 | 56 |
48 ProtobufMessageReader<EventMessage> reader_; | 57 ProtobufMessageReader<EventMessage> reader_; |
49 | 58 |
50 DISALLOW_COPY_AND_ASSIGN(HostEventDispatcher); | 59 DISALLOW_COPY_AND_ASSIGN(HostEventDispatcher); |
51 }; | 60 }; |
52 | 61 |
53 } // namespace protocol | 62 } // namespace protocol |
54 } // namespace remoting | 63 } // namespace remoting |
55 | 64 |
56 #endif // REMOTING_PROTOCOL_HOST_EVENT_DISPATCHER_H_ | 65 #endif // REMOTING_PROTOCOL_HOST_EVENT_DISPATCHER_H_ |
OLD | NEW |