host_event_dispatcher.h 1.87 KB
Newer Older
1
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 3 4 5 6 7
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef REMOTING_PROTOCOL_HOST_EVENT_DISPATCHER_H_
#define REMOTING_PROTOCOL_HOST_EVENT_DISPATCHER_H_

8 9 10
#include <stdint.h>

#include "base/macros.h"
11
#include "remoting/protocol/channel_dispatcher_base.h"
12
#include "remoting/protocol/input_event_timestamps.h"
13 14 15 16 17 18 19 20

namespace remoting {
namespace protocol {

class InputStub;

// HostEventDispatcher dispatches incoming messages on the event
// channel to InputStub.
21
class HostEventDispatcher : public ChannelDispatcherBase {
22 23
 public:
  HostEventDispatcher();
24
  ~HostEventDispatcher() override;
25 26 27 28 29 30

  // Set InputStub that will be called for each incoming input
  // message. Doesn't take ownership of |input_stub|. It must outlive
  // the dispatcher.
  void set_input_stub(InputStub* input_stub) { input_stub_ = input_stub; }

31 32 33 34 35 36 37 38 39 40
  // Returns InputEventTimestampsSource for events received on input channel.
  //
  // TODO(sergeyu): This timestamps source generates timestamps for input events
  // as they are received. This means that any potential delay in the input
  // injector is not accounted for. Consider moving this to InputInjector to
  // ensure that the timestamps source emits timestamps for each input event
  // only after it's injected. This would require updating InputStub to get
  // timestamps for each event.
  scoped_refptr<InputEventTimestampsSource> event_timestamps_source() {
    return event_timestamps_source_;
41 42 43
  }

 private:
44
  void OnIncomingMessage(std::unique_ptr<CompoundBuffer> buffer) override;
45

46 47
  scoped_refptr<InputEventTimestampsSourceImpl> event_timestamps_source_;

sergeyu's avatar
sergeyu committed
48
  InputStub* input_stub_ = nullptr;
49 50 51 52 53 54 55 56

  DISALLOW_COPY_AND_ASSIGN(HostEventDispatcher);
};

}  // namespace protocol
}  // namespace remoting

#endif  // REMOTING_PROTOCOL_HOST_EVENT_DISPATCHER_H_