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

Side by Side Diff: content/browser/renderer_host/input/synthetic_gesture_controller.cc

Issue 2890603002: input: Delay the dispatch of synthesized input event. (Closed)
Patch Set: . Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" 5 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 21 matching lines...) Expand all
32 bool was_empty = pending_gesture_queue_.IsEmpty(); 32 bool was_empty = pending_gesture_queue_.IsEmpty();
33 33
34 pending_gesture_queue_.Push(std::move(synthetic_gesture), 34 pending_gesture_queue_.Push(std::move(synthetic_gesture),
35 completion_callback); 35 completion_callback);
36 36
37 if (was_empty) 37 if (was_empty)
38 StartGesture(*pending_gesture_queue_.FrontGesture()); 38 StartGesture(*pending_gesture_queue_.FrontGesture());
39 } 39 }
40 40
41 void SyntheticGestureController::OnBeginFrame() { 41 void SyntheticGestureController::OnBeginFrame() {
42 // TODO(sad): Instead of dispatching the events immediately, dispatch after an 42 constexpr base::TimeDelta kSynthesizedDispatchDelay =
43 // offset. 43 base::TimeDelta::FromMilliseconds(2);
44 DispatchNextEvent(); 44 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
dtapuska 2017/05/17 16:30:45 I don't think this is quite right. Didn't we want
sadrul 2017/05/17 18:18:01 Yep, that's where we want to go. I am trying to ta
45 FROM_HERE,
46 base::BindOnce(
47 [](base::WeakPtr<SyntheticGestureController> weak_ptr) {
48 if (weak_ptr)
49 weak_ptr->DispatchNextEvent(base::TimeTicks::Now());
50 },
51 weak_ptr_factory_.GetWeakPtr()),
52 kSynthesizedDispatchDelay);
45 } 53 }
46 54
47 bool SyntheticGestureController::DispatchNextEvent(base::TimeTicks timestamp) { 55 bool SyntheticGestureController::DispatchNextEvent(base::TimeTicks timestamp) {
48 TRACE_EVENT0("input", "SyntheticGestureController::Flush"); 56 TRACE_EVENT0("input", "SyntheticGestureController::Flush");
49 if (pending_gesture_queue_.IsEmpty()) 57 if (pending_gesture_queue_.IsEmpty())
50 return false; 58 return false;
51 59
52 SyntheticGesture::Result result = 60 SyntheticGesture::Result result =
53 pending_gesture_queue_.FrontGesture()->ForwardInputEvents( 61 pending_gesture_queue_.FrontGesture()->ForwardInputEvents(
54 timestamp, gesture_target_.get()); 62 timestamp, gesture_target_.get());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 99 }
92 100
93 SyntheticGestureController::GestureAndCallbackQueue::GestureAndCallbackQueue() { 101 SyntheticGestureController::GestureAndCallbackQueue::GestureAndCallbackQueue() {
94 } 102 }
95 103
96 SyntheticGestureController::GestureAndCallbackQueue:: 104 SyntheticGestureController::GestureAndCallbackQueue::
97 ~GestureAndCallbackQueue() { 105 ~GestureAndCallbackQueue() {
98 } 106 }
99 107
100 } // namespace content 108 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698