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

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

Issue 2886263002: input: Dispatch synthesized events at regular intervals. (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
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 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <queue> 9 #include <queue>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "base/timer/timer.h"
17 #include "content/browser/renderer_host/input/synthetic_gesture.h" 18 #include "content/browser/renderer_host/input/synthetic_gesture.h"
18 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
19 #include "content/common/input/synthetic_gesture_params.h" 20 #include "content/common/input/synthetic_gesture_params.h"
20 21
21 namespace content { 22 namespace content {
22 23
23 class SyntheticGestureTarget; 24 class SyntheticGestureTarget;
24 25
25 // Controls a synthetic gesture. 26 // Controls a synthetic gesture.
26 // Repeatedly invokes the gesture object's ForwardInputEvent method to send 27 // Repeatedly invokes the gesture object's ForwardInputEvent method to send
(...skipping 20 matching lines...) Expand all
47 48
48 typedef base::Callback<void(SyntheticGesture::Result)> 49 typedef base::Callback<void(SyntheticGesture::Result)>
49 OnGestureCompleteCallback; 50 OnGestureCompleteCallback;
50 void QueueSyntheticGesture( 51 void QueueSyntheticGesture(
51 std::unique_ptr<SyntheticGesture> synthetic_gesture, 52 std::unique_ptr<SyntheticGesture> synthetic_gesture,
52 const OnGestureCompleteCallback& completion_callback); 53 const OnGestureCompleteCallback& completion_callback);
53 54
54 bool DispatchNextEvent(base::TimeTicks = base::TimeTicks::Now()); 55 bool DispatchNextEvent(base::TimeTicks = base::TimeTicks::Now());
55 56
56 private: 57 private:
57 void RequestBeginFrame(); 58 void RequestBeginFrameIfNecessary();
58 void OnBeginFrame(); 59 void OnBeginFrame();
60 void StartTimer();
59 61
60 void StartGesture(const SyntheticGesture& gesture); 62 void StartGesture(const SyntheticGesture& gesture);
61 void StopGesture(const SyntheticGesture& gesture, 63 void StopGesture(const SyntheticGesture& gesture,
62 const OnGestureCompleteCallback& completion_callback, 64 const OnGestureCompleteCallback& completion_callback,
63 SyntheticGesture::Result result); 65 SyntheticGesture::Result result);
64 66
65 Delegate* const delegate_; 67 Delegate* const delegate_;
66 std::unique_ptr<SyntheticGestureTarget> gesture_target_; 68 std::unique_ptr<SyntheticGestureTarget> gesture_target_;
67 69
68 // A queue of gesture/callback pairs. Implemented as two queues to 70 // A queue of gesture/callback pairs. Implemented as two queues to
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 106
105 private: 107 private:
106 SyntheticGesture::Result result_of_current_gesture_ = 108 SyntheticGesture::Result result_of_current_gesture_ =
107 SyntheticGesture::GESTURE_RUNNING; 109 SyntheticGesture::GESTURE_RUNNING;
108 std::vector<std::unique_ptr<SyntheticGesture>> gestures_; 110 std::vector<std::unique_ptr<SyntheticGesture>> gestures_;
109 std::queue<OnGestureCompleteCallback> callbacks_; 111 std::queue<OnGestureCompleteCallback> callbacks_;
110 112
111 DISALLOW_COPY_AND_ASSIGN(GestureAndCallbackQueue); 113 DISALLOW_COPY_AND_ASSIGN(GestureAndCallbackQueue);
112 } pending_gesture_queue_; 114 } pending_gesture_queue_;
113 115
116 base::RepeatingTimer dispatch_timer_;
114 base::WeakPtrFactory<SyntheticGestureController> weak_ptr_factory_; 117 base::WeakPtrFactory<SyntheticGestureController> weak_ptr_factory_;
115 118
116 DISALLOW_COPY_AND_ASSIGN(SyntheticGestureController); 119 DISALLOW_COPY_AND_ASSIGN(SyntheticGestureController);
117 }; 120 };
118 121
119 } // namespace content 122 } // namespace content
120 123
121 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_ 124 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698