| 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 12 matching lines...) Expand all Loading... |
| 23 DCHECK(synthetic_gesture); | 23 DCHECK(synthetic_gesture); |
| 24 | 24 |
| 25 pending_gesture_queue_.push_back(synthetic_gesture.release()); | 25 pending_gesture_queue_.push_back(synthetic_gesture.release()); |
| 26 | 26 |
| 27 // Start forwarding input events if the queue was previously empty. | 27 // Start forwarding input events if the queue was previously empty. |
| 28 if (pending_gesture_queue_.size() == 1) | 28 if (pending_gesture_queue_.size() == 1) |
| 29 StartGesture(*pending_gesture_queue_.front()); | 29 StartGesture(*pending_gesture_queue_.front()); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void SyntheticGestureController::Flush(base::TimeTicks timestamp) { | 32 void SyntheticGestureController::Flush(base::TimeTicks timestamp) { |
| 33 TRACE_EVENT0("benchmark", "SyntheticGestureController::Flush"); | 33 TRACE_EVENT0("input", "SyntheticGestureController::Flush"); |
| 34 if (pending_gesture_queue_.empty()) | 34 if (pending_gesture_queue_.empty()) |
| 35 return; | 35 return; |
| 36 | 36 |
| 37 SyntheticGesture::Result result = | 37 SyntheticGesture::Result result = |
| 38 pending_gesture_queue_.front()->ForwardInputEvents(timestamp, | 38 pending_gesture_queue_.front()->ForwardInputEvents(timestamp, |
| 39 gesture_target_.get()); | 39 gesture_target_.get()); |
| 40 | 40 |
| 41 if (result == SyntheticGesture::GESTURE_RUNNING) { | 41 if (result == SyntheticGesture::GESTURE_RUNNING) { |
| 42 gesture_target_->SetNeedsFlush(); | 42 gesture_target_->SetNeedsFlush(); |
| 43 return; | 43 return; |
| 44 } | 44 } |
| 45 | 45 |
| 46 StopGesture(*pending_gesture_queue_.front(), result); | 46 StopGesture(*pending_gesture_queue_.front(), result); |
| 47 pending_gesture_queue_.erase(pending_gesture_queue_.begin()); | 47 pending_gesture_queue_.erase(pending_gesture_queue_.begin()); |
| 48 | 48 |
| 49 if (!pending_gesture_queue_.empty()) | 49 if (!pending_gesture_queue_.empty()) |
| 50 StartGesture(*pending_gesture_queue_.front()); | 50 StartGesture(*pending_gesture_queue_.front()); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void SyntheticGestureController::StartGesture(const SyntheticGesture& gesture) { | 53 void SyntheticGestureController::StartGesture(const SyntheticGesture& gesture) { |
| 54 TRACE_EVENT_ASYNC_BEGIN0("benchmark", "SyntheticGestureController::running", | 54 TRACE_EVENT_ASYNC_BEGIN0("input,benchmark", |
| 55 "SyntheticGestureController::running", |
| 55 &gesture); | 56 &gesture); |
| 56 gesture_target_->SetNeedsFlush(); | 57 gesture_target_->SetNeedsFlush(); |
| 57 } | 58 } |
| 58 | 59 |
| 59 void SyntheticGestureController::StopGesture( | 60 void SyntheticGestureController::StopGesture( |
| 60 const SyntheticGesture& gesture, SyntheticGesture::Result result) { | 61 const SyntheticGesture& gesture, SyntheticGesture::Result result) { |
| 61 DCHECK_NE(result, SyntheticGesture::GESTURE_RUNNING); | 62 DCHECK_NE(result, SyntheticGesture::GESTURE_RUNNING); |
| 62 TRACE_EVENT_ASYNC_END0("benchmark", "SyntheticGestureController::running", | 63 TRACE_EVENT_ASYNC_END0("input,benchmark", |
| 64 "SyntheticGestureController::running", |
| 63 &gesture); | 65 &gesture); |
| 64 | 66 |
| 65 gesture_target_->OnSyntheticGestureCompleted(result); | 67 gesture_target_->OnSyntheticGestureCompleted(result); |
| 66 } | 68 } |
| 67 | 69 |
| 68 } // namespace content | 70 } // namespace content |
| OLD | NEW |