| 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 #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 "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 8 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
| 9 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" | 9 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |
| 10 #include "content/common/input_messages.h" | 10 #include "content/common/input_messages.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 bool was_empty = pending_gesture_queue_.IsEmpty(); | 26 bool was_empty = pending_gesture_queue_.IsEmpty(); |
| 27 | 27 |
| 28 pending_gesture_queue_.Push(synthetic_gesture.Pass(), completion_callback); | 28 pending_gesture_queue_.Push(synthetic_gesture.Pass(), completion_callback); |
| 29 | 29 |
| 30 if (was_empty) | 30 if (was_empty) |
| 31 StartGesture(*pending_gesture_queue_.FrontGesture()); | 31 StartGesture(*pending_gesture_queue_.FrontGesture()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void SyntheticGestureController::Flush(base::TimeTicks timestamp) { | 34 void SyntheticGestureController::Flush(base::TimeTicks timestamp) { |
| 35 TRACE_EVENT0("benchmark", "SyntheticGestureController::Flush"); | 35 TRACE_EVENT0("input", "SyntheticGestureController::Flush"); |
| 36 if (pending_gesture_queue_.IsEmpty()) | 36 if (pending_gesture_queue_.IsEmpty()) |
| 37 return; | 37 return; |
| 38 | 38 |
| 39 SyntheticGesture* gesture = pending_gesture_queue_.FrontGesture(); | 39 SyntheticGesture* gesture = pending_gesture_queue_.FrontGesture(); |
| 40 SyntheticGesture::Result result = gesture->ForwardInputEvents(timestamp, | 40 SyntheticGesture::Result result = gesture->ForwardInputEvents(timestamp, |
| 41 gesture_target_.get()); | 41 gesture_target_.get()); |
| 42 | 42 |
| 43 if (result == SyntheticGesture::GESTURE_RUNNING) { | 43 if (result == SyntheticGesture::GESTURE_RUNNING) { |
| 44 gesture_target_->SetNeedsFlush(); | 44 gesture_target_->SetNeedsFlush(); |
| 45 return; | 45 return; |
| 46 } | 46 } |
| 47 | 47 |
| 48 StopGesture(*gesture, pending_gesture_queue_.FrontCallback(), result); | 48 StopGesture(*gesture, pending_gesture_queue_.FrontCallback(), result); |
| 49 pending_gesture_queue_.Pop(); | 49 pending_gesture_queue_.Pop(); |
| 50 | 50 |
| 51 if (!pending_gesture_queue_.IsEmpty()) | 51 if (!pending_gesture_queue_.IsEmpty()) |
| 52 StartGesture(*pending_gesture_queue_.FrontGesture()); | 52 StartGesture(*pending_gesture_queue_.FrontGesture()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void SyntheticGestureController::StartGesture(const SyntheticGesture& gesture) { | 55 void SyntheticGestureController::StartGesture(const SyntheticGesture& gesture) { |
| 56 TRACE_EVENT_ASYNC_BEGIN0("benchmark", "SyntheticGestureController::running", | 56 TRACE_EVENT_ASYNC_BEGIN0("input,benchmark", |
| 57 "SyntheticGestureController::running", |
| 57 &gesture); | 58 &gesture); |
| 58 gesture_target_->SetNeedsFlush(); | 59 gesture_target_->SetNeedsFlush(); |
| 59 } | 60 } |
| 60 | 61 |
| 61 void SyntheticGestureController::StopGesture( | 62 void SyntheticGestureController::StopGesture( |
| 62 const SyntheticGesture& gesture, | 63 const SyntheticGesture& gesture, |
| 63 const OnGestureCompleteCallback& completion_callback, | 64 const OnGestureCompleteCallback& completion_callback, |
| 64 SyntheticGesture::Result result) { | 65 SyntheticGesture::Result result) { |
| 65 DCHECK_NE(result, SyntheticGesture::GESTURE_RUNNING); | 66 DCHECK_NE(result, SyntheticGesture::GESTURE_RUNNING); |
| 66 TRACE_EVENT_ASYNC_END0("benchmark", "SyntheticGestureController::running", | 67 TRACE_EVENT_ASYNC_END0("input,benchmark", |
| 68 "SyntheticGestureController::running", |
| 67 &gesture); | 69 &gesture); |
| 68 | 70 |
| 69 completion_callback.Run(result); | 71 completion_callback.Run(result); |
| 70 } | 72 } |
| 71 | 73 |
| 72 SyntheticGestureController::GestureAndCallbackQueue::GestureAndCallbackQueue() { | 74 SyntheticGestureController::GestureAndCallbackQueue::GestureAndCallbackQueue() { |
| 73 } | 75 } |
| 74 | 76 |
| 75 SyntheticGestureController::GestureAndCallbackQueue:: | 77 SyntheticGestureController::GestureAndCallbackQueue:: |
| 76 ~GestureAndCallbackQueue() { | 78 ~GestureAndCallbackQueue() { |
| 77 } | 79 } |
| 78 | 80 |
| 79 } // namespace content | 81 } // namespace content |
| OLD | NEW |