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

Unified Diff: content/renderer/input/input_event_filter.cc

Issue 2289173003: Make event timestamp consistent in renderer even if TimeTicks isn't consistent x-process. (Closed)
Patch Set: rebae Created 4 years, 4 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
« no previous file with comments | « content/renderer/input/input_event_filter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/input/input_event_filter.cc
diff --git a/content/renderer/input/input_event_filter.cc b/content/renderer/input/input_event_filter.cc
index e9bd18ce6663e9e9a130212d230cb74aff34a86d..f05d91c019c55f497e399ce3b7de7f673231775b 100644
--- a/content/renderer/input/input_event_filter.cc
+++ b/content/renderer/input/input_event_filter.cc
@@ -22,6 +22,7 @@
#include "content/renderer/render_thread_impl.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_sender.h"
+#include "ui/events/base_event_utils.h"
#include "ui/events/blink/did_overscroll_params.h"
#include "ui/events/blink/web_input_event_traits.h"
#include "ui/gfx/geometry/vector2d_f.h"
@@ -169,6 +170,13 @@ bool InputEventFilter::OnMessageReceived(const IPC::Message& message) {
if (!RequiresThreadBounce(message))
return false;
+ // If TimeTicks is not consistent across processes we cannot use the event's
+ // platform timestamp in this process. Instead the time that the event is
+ // received on the IO thread is used as the event's timestamp.
+ base::TimeTicks received_time;
+ if (!base::TimeTicks::IsConsistentAcrossProcesses())
+ received_time = base::TimeTicks::Now();
+
TRACE_EVENT0("input", "InputEventFilter::OnMessageReceived::InputMessage");
{
@@ -178,8 +186,8 @@ bool InputEventFilter::OnMessageReceived(const IPC::Message& message) {
}
target_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&InputEventFilter::ForwardToHandler, this, message));
+ FROM_HERE, base::Bind(&InputEventFilter::ForwardToHandler, this, message,
+ received_time));
return true;
}
@@ -187,7 +195,8 @@ InputEventFilter::~InputEventFilter() {
DCHECK(!current_overscroll_params_);
}
-void InputEventFilter::ForwardToHandler(const IPC::Message& message) {
+void InputEventFilter::ForwardToHandler(const IPC::Message& message,
+ base::TimeTicks received_time) {
DCHECK(input_handler_manager_);
DCHECK(target_task_runner_->BelongsToCurrentThread());
TRACE_EVENT1("input", "InputEventFilter::ForwardToHandler",
@@ -214,6 +223,9 @@ void InputEventFilter::ForwardToHandler(const IPC::Message& message) {
DCHECK(dispatch_type == DISPATCH_TYPE_BLOCKING ||
dispatch_type == DISPATCH_TYPE_NON_BLOCKING);
+ if (!received_time.is_null())
+ event->timeStampSeconds = ui::EventTimeStampToSeconds(received_time);
+
bool send_ack = dispatch_type == DISPATCH_TYPE_BLOCKING;
// Intercept |DidOverscroll| notifications, bundling any triggered overscroll
« no previous file with comments | « content/renderer/input/input_event_filter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698