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

Unified Diff: remoting/protocol/input_event_timestamps.h

Issue 2413553003: Add InputEventTimestampSource interface. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/input_event_timestamps.h
diff --git a/remoting/protocol/input_event_timestamps.h b/remoting/protocol/input_event_timestamps.h
new file mode 100644
index 0000000000000000000000000000000000000000..3cb13ceac07414ff57dce6d532495c515a8d1de6
--- /dev/null
+++ b/remoting/protocol/input_event_timestamps.h
@@ -0,0 +1,61 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_PROTOCOL_INPUT_EVENT_TIMESTAMPS_H_
+#define REMOTING_PROTOCOL_INPUT_EVENT_TIMESTAMPS_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/time/time.h"
+
+namespace remoting {
+namespace protocol {
+
+// Used on the host side to track timestamps for input events.
+struct InputEventTimestamps {
+ // Client-side timestamps. This value comesfrom the client clock, so it should
Jamie 2016/10/12 21:41:23 Nit: missing space "comesfrom"
Sergey Ulanov 2016/10/14 19:34:26 Done.
+ // not be used for any calculations on the host side (except in tests).
+ base::TimeTicks client_timestamp;
+
+ // Time when the event was received by the host.
+ base::TimeTicks host_timestamp;
+
+ bool is_null() { return client_timestamp.is_null(); }
+};
+
+// InputEventTimestampSource is used by VideoStream implementations to get event
+// timestamps that are sent back to the client as part of VideoStats message.
+class InputEventTimestampSource
+ : public base::RefCountedThreadSafe<InputEventTimestampSource> {
+ public:
+ InputEventTimestampSource() {}
+
+ virtual InputEventTimestamps GetLastEventTimestamps() = 0;
+
+ protected:
+ friend base::RefCountedThreadSafe<InputEventTimestampSource>;
+ virtual ~InputEventTimestampSource() {}
+};
+
+// Simple implementations of InputEventTimestampSource that just stores the
+// value provided to OnEventReceived().
+class InputEventTimestampSourceImpl : public InputEventTimestampSource {
+ public:
+ InputEventTimestampSourceImpl();
+
+ void OnEventReceived(InputEventTimestamps timestamps);
+
+ // InputEventTimestampSource implementation.
+ InputEventTimestamps GetLastEventTimestamps() override;
+
+ protected:
+ ~InputEventTimestampSourceImpl() override;
+
+ private:
+ InputEventTimestamps last_timestamps_;
+};
+
+} // namespace protocol
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_INPUT_EVENT_TIMESTAMPS_H_

Powered by Google App Engine
This is Rietveld 408576698