| 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/input_event_timestamps.h" |
| 12 | 13 |
| 13 namespace remoting { | 14 namespace remoting { |
| 14 namespace protocol { | 15 namespace protocol { |
| 15 | 16 |
| 16 class EventMessage; | 17 class EventMessage; |
| 17 class InputStub; | 18 class InputStub; |
| 18 | 19 |
| 19 // HostEventDispatcher dispatches incoming messages on the event | 20 // HostEventDispatcher dispatches incoming messages on the event |
| 20 // channel to InputStub. | 21 // channel to InputStub. |
| 21 class HostEventDispatcher : public ChannelDispatcherBase { | 22 class HostEventDispatcher : public ChannelDispatcherBase { |
| 22 public: | 23 public: |
| 23 typedef base::Callback<void(int64_t)> OnInputEventCallback; | |
| 24 | |
| 25 HostEventDispatcher(); | 24 HostEventDispatcher(); |
| 26 ~HostEventDispatcher() override; | 25 ~HostEventDispatcher() override; |
| 27 | 26 |
| 28 // Set InputStub that will be called for each incoming input | 27 // Set InputStub that will be called for each incoming input |
| 29 // message. Doesn't take ownership of |input_stub|. It must outlive | 28 // message. Doesn't take ownership of |input_stub|. It must outlive |
| 30 // the dispatcher. | 29 // the dispatcher. |
| 31 void set_input_stub(InputStub* input_stub) { input_stub_ = input_stub; } | 30 void set_input_stub(InputStub* input_stub) { input_stub_ = input_stub; } |
| 32 | 31 |
| 33 // Set callback to notify of each message's sequence number. The | 32 // Returns InputEventTimestampsSource for events received on input channel. |
| 34 // callback cannot tear down this object. | 33 // |
| 35 void set_on_input_event_callback(const OnInputEventCallback& value) { | 34 // TODO(sergeyu): This timestamps source generates timestamps for input events |
| 36 on_input_event_callback_ = value; | 35 // as they are received. This means that any potential delay in the input |
| 36 // injector is not accounted for. Consider moving this to InputInjector to |
| 37 // ensure that the timestamps source emits timestamps for each input event |
| 38 // only after it's injected. This would require updating InputStub to get |
| 39 // timestamps for each event. |
| 40 scoped_refptr<InputEventTimestampsSource> event_timestamps_source() { |
| 41 return event_timestamps_source_; |
| 37 } | 42 } |
| 38 | 43 |
| 39 private: | 44 private: |
| 40 void OnIncomingMessage(std::unique_ptr<CompoundBuffer> buffer) override; | 45 void OnIncomingMessage(std::unique_ptr<CompoundBuffer> buffer) override; |
| 41 | 46 |
| 47 scoped_refptr<InputEventTimestampsSourceImpl> event_timestamps_source_; |
| 48 |
| 42 InputStub* input_stub_ = nullptr; | 49 InputStub* input_stub_ = nullptr; |
| 43 OnInputEventCallback on_input_event_callback_; | |
| 44 | 50 |
| 45 DISALLOW_COPY_AND_ASSIGN(HostEventDispatcher); | 51 DISALLOW_COPY_AND_ASSIGN(HostEventDispatcher); |
| 46 }; | 52 }; |
| 47 | 53 |
| 48 } // namespace protocol | 54 } // namespace protocol |
| 49 } // namespace remoting | 55 } // namespace remoting |
| 50 | 56 |
| 51 #endif // REMOTING_PROTOCOL_HOST_EVENT_DISPATCHER_H_ | 57 #endif // REMOTING_PROTOCOL_HOST_EVENT_DISPATCHER_H_ |
| OLD | NEW |