| OLD | NEW |
| 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 Loading... |
| 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: |
| 58 friend class SyntheticGestureControllerTestBase; |
| 59 |
| 57 void RequestBeginFrame(); | 60 void RequestBeginFrame(); |
| 58 void OnBeginFrame(); | 61 void OnBeginFrame(); |
| 62 void StartTimer(); |
| 59 | 63 |
| 60 void StartGesture(const SyntheticGesture& gesture); | 64 void StartGesture(const SyntheticGesture& gesture); |
| 61 void StopGesture(const SyntheticGesture& gesture, | 65 void StopGesture(const SyntheticGesture& gesture, |
| 62 const OnGestureCompleteCallback& completion_callback, | 66 const OnGestureCompleteCallback& completion_callback, |
| 63 SyntheticGesture::Result result); | 67 SyntheticGesture::Result result); |
| 64 | 68 |
| 65 Delegate* const delegate_; | 69 Delegate* const delegate_; |
| 66 std::unique_ptr<SyntheticGestureTarget> gesture_target_; | 70 std::unique_ptr<SyntheticGestureTarget> gesture_target_; |
| 67 | 71 |
| 68 // A queue of gesture/callback pairs. Implemented as two queues to | 72 // A queue of gesture/callback pairs. Implemented as two queues to |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 108 |
| 105 private: | 109 private: |
| 106 SyntheticGesture::Result result_of_current_gesture_ = | 110 SyntheticGesture::Result result_of_current_gesture_ = |
| 107 SyntheticGesture::GESTURE_RUNNING; | 111 SyntheticGesture::GESTURE_RUNNING; |
| 108 std::vector<std::unique_ptr<SyntheticGesture>> gestures_; | 112 std::vector<std::unique_ptr<SyntheticGesture>> gestures_; |
| 109 std::queue<OnGestureCompleteCallback> callbacks_; | 113 std::queue<OnGestureCompleteCallback> callbacks_; |
| 110 | 114 |
| 111 DISALLOW_COPY_AND_ASSIGN(GestureAndCallbackQueue); | 115 DISALLOW_COPY_AND_ASSIGN(GestureAndCallbackQueue); |
| 112 } pending_gesture_queue_; | 116 } pending_gesture_queue_; |
| 113 | 117 |
| 118 base::RepeatingTimer dispatch_timer_; |
| 114 base::WeakPtrFactory<SyntheticGestureController> weak_ptr_factory_; | 119 base::WeakPtrFactory<SyntheticGestureController> weak_ptr_factory_; |
| 115 | 120 |
| 116 DISALLOW_COPY_AND_ASSIGN(SyntheticGestureController); | 121 DISALLOW_COPY_AND_ASSIGN(SyntheticGestureController); |
| 117 }; | 122 }; |
| 118 | 123 |
| 119 } // namespace content | 124 } // namespace content |
| 120 | 125 |
| 121 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_ | 126 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_SYNTHETIC_GESTURE_CONTROLLER_H_ |
| OLD | NEW |