Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: remoting/protocol/input_event_timestamps.h

Issue 2413553003: Add InputEventTimestampSource interface. (Closed)
Patch Set: msvc compilation Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef REMOTING_PROTOCOL_INPUT_EVENT_TIMESTAMPS_H_
6 #define REMOTING_PROTOCOL_INPUT_EVENT_TIMESTAMPS_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/time/time.h"
10
11 namespace remoting {
12 namespace protocol {
13
14 // Used on the host side to track timestamps for input events.
15 struct InputEventTimestamps {
16 // Client-side timestamps. This value comes from the client clock, so it
17 // should not be used for any calculations on the host side (except in tests).
18 base::TimeTicks client_timestamp;
19
20 // Time when the event was processed by the host.
21 base::TimeTicks host_timestamp;
22
23 bool is_null() { return client_timestamp.is_null(); }
24 };
25
26 // InputEventTimestampsSource is used by VideoStream implementations to get
27 // event timestamps that are sent back to the client as part of VideoStats
28 // message.
29 class InputEventTimestampsSource
30 : public base::RefCountedThreadSafe<InputEventTimestampsSource> {
31 public:
32 InputEventTimestampsSource() {}
33
34 // Returns event timestamps for the input event that was received since the
35 // previous call. Null InputEventTimestamps value is returned if no input
36 // events were received. If multiple input events were received, then
37 // timestamps for the last one should be returned
38 virtual InputEventTimestamps TakeLastEventTimestamps() = 0;
39
40 protected:
41 friend base::RefCountedThreadSafe<InputEventTimestampsSource>;
42 virtual ~InputEventTimestampsSource() {}
43 };
44
45 // Simple implementations of InputEventTimestampsSource that just stores the
46 // value provided to OnEventReceived().
47 class InputEventTimestampsSourceImpl : public InputEventTimestampsSource {
48 public:
49 InputEventTimestampsSourceImpl();
50
51 void OnEventReceived(InputEventTimestamps timestamps);
52
53 // InputEventTimestampsSource implementation.
54 InputEventTimestamps TakeLastEventTimestamps() override;
55
56 protected:
57 ~InputEventTimestampsSourceImpl() override;
58
59 private:
60 InputEventTimestamps last_timestamps_;
61 };
62
63 } // namespace protocol
64 } // namespace remoting
65
66 #endif // REMOTING_PROTOCOL_INPUT_EVENT_TIMESTAMPS_H_
OLDNEW
« no previous file with comments | « remoting/protocol/ice_connection_to_client.cc ('k') | remoting/protocol/input_event_timestamps.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698