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_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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "remoting/protocol/channel_dispatcher_base.h" | 11 #include "remoting/protocol/channel_dispatcher_base.h" |
12 #include "remoting/protocol/protobuf_message_parser.h" | |
13 | 12 |
14 namespace remoting { | 13 namespace remoting { |
15 namespace protocol { | 14 namespace protocol { |
16 | 15 |
17 class EventMessage; | 16 class EventMessage; |
18 class InputStub; | 17 class InputStub; |
19 | 18 |
20 // HostEventDispatcher dispatches incoming messages on the event | 19 // HostEventDispatcher dispatches incoming messages on the event |
21 // channel to InputStub. | 20 // channel to InputStub. |
22 class HostEventDispatcher : public ChannelDispatcherBase { | 21 class HostEventDispatcher : public ChannelDispatcherBase { |
23 public: | 22 public: |
24 typedef base::Callback<void(int64_t)> OnInputEventCallback; | 23 typedef base::Callback<void(int64_t)> OnInputEventCallback; |
25 | 24 |
26 HostEventDispatcher(); | 25 HostEventDispatcher(); |
27 ~HostEventDispatcher() override; | 26 ~HostEventDispatcher() override; |
28 | 27 |
29 // Set InputStub that will be called for each incoming input | 28 // Set InputStub that will be called for each incoming input |
30 // message. Doesn't take ownership of |input_stub|. It must outlive | 29 // message. Doesn't take ownership of |input_stub|. It must outlive |
31 // the dispatcher. | 30 // the dispatcher. |
32 void set_input_stub(InputStub* input_stub) { input_stub_ = input_stub; } | 31 void set_input_stub(InputStub* input_stub) { input_stub_ = input_stub; } |
33 | 32 |
34 // Set callback to notify of each message's sequence number. The | 33 // Set callback to notify of each message's sequence number. The |
35 // callback cannot tear down this object. | 34 // callback cannot tear down this object. |
36 void set_on_input_event_callback(const OnInputEventCallback& value) { | 35 void set_on_input_event_callback(const OnInputEventCallback& value) { |
37 on_input_event_callback_ = value; | 36 on_input_event_callback_ = value; |
38 } | 37 } |
39 | 38 |
40 private: | 39 private: |
41 void OnMessageReceived(scoped_ptr<EventMessage> message); | 40 void OnIncomingMessage(scoped_ptr<CompoundBuffer> buffer) override; |
42 | 41 |
43 InputStub* input_stub_; | 42 InputStub* input_stub_ = nullptr; |
44 OnInputEventCallback on_input_event_callback_; | 43 OnInputEventCallback on_input_event_callback_; |
45 | 44 |
46 ProtobufMessageParser<EventMessage> parser_; | |
47 | |
48 DISALLOW_COPY_AND_ASSIGN(HostEventDispatcher); | 45 DISALLOW_COPY_AND_ASSIGN(HostEventDispatcher); |
49 }; | 46 }; |
50 | 47 |
51 } // namespace protocol | 48 } // namespace protocol |
52 } // namespace remoting | 49 } // namespace remoting |
53 | 50 |
54 #endif // REMOTING_PROTOCOL_HOST_EVENT_DISPATCHER_H_ | 51 #endif // REMOTING_PROTOCOL_HOST_EVENT_DISPATCHER_H_ |
OLD | NEW |