Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_TIMEOUT_HANDLER_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_TIMEOUT_HANDLER_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 #include <stdint.h> | |
| 10 | |
| 11 #include <deque> | |
| 12 #include <list> | |
| 13 #include <memory> | |
| 14 | |
| 15 #include "base/macros.h" | |
| 16 #include "base/time/time.h" | |
| 17 #include "content/browser/renderer_host/event_with_latency_info.h" | |
| 18 #include "content/browser/renderer_host/input/timeout_monitor.h" | |
| 19 #include "content/browser/renderer_host/input/touch_event_queue.h" | |
| 20 #include "content/common/content_export.h" | |
| 21 #include "content/common/input/input_event_ack_state.h" | |
| 22 #include "third_party/WebKit/public/platform/WebInputEvent.h" | |
| 23 #include "ui/gfx/geometry/point_f.h" | |
|
tdresser
2017/02/21 18:16:31
At least this include is unnecessary. Are there ot
dtapuska
2017/02/21 18:26:47
Done.
| |
| 24 | |
| 25 namespace content { | |
| 26 | |
| 27 class TouchEventQueue; | |
|
tdresser
2017/02/21 18:16:31
We're including this and forward declaring it curr
dtapuska
2017/02/21 18:26:47
Done.
| |
| 28 | |
| 29 class TouchTimeoutHandler { | |
| 30 public: | |
| 31 TouchTimeoutHandler(TouchEventQueue* touch_queue, | |
| 32 base::TimeDelta desktop_timeout_delay, | |
| 33 base::TimeDelta mobile_timeout_delay); | |
| 34 | |
| 35 ~TouchTimeoutHandler(); | |
| 36 | |
| 37 void StartIfNecessary(const TouchEventWithLatencyInfo& event); | |
| 38 bool ConfirmTouchEvent(uint32_t unique_touch_event_id, | |
| 39 InputEventAckState ack_result); | |
| 40 bool FilterEvent(const blink::WebTouchEvent& event); | |
| 41 void SetEnabled(bool enabled); | |
| 42 void SetUseMobileTimeout(bool use_mobile_timeout); | |
| 43 bool IsTimeoutTimerRunning() const { return timeout_monitor_.IsRunning(); } | |
| 44 bool IsEnabled() const { return enabled_ && !GetTimeoutDelay().is_zero(); } | |
| 45 | |
| 46 private: | |
|
tdresser
2017/02/21 18:16:31
DISALLOW_COPY_AND_ASSIGN?
dtapuska
2017/02/21 18:26:47
Done.
| |
| 47 enum PendingAckState { | |
| 48 PENDING_ACK_NONE, | |
| 49 PENDING_ACK_ORIGINAL_EVENT, | |
| 50 PENDING_ACK_CANCEL_EVENT, | |
| 51 }; | |
| 52 | |
| 53 void OnTimeOut(); | |
| 54 // Skip a cancel event if the timed-out event had no consumer and was the | |
| 55 // initial event in the gesture. | |
| 56 bool AckedTimeoutEventRequiresCancel(InputEventAckState ack_result) const; | |
| 57 void SetPendingAckState(PendingAckState new_pending_ack_state); | |
| 58 void LogSequenceStartForUMA(); | |
| 59 void LogSequenceEndForUMAIfNecessary(bool timed_out); | |
| 60 base::TimeDelta GetTimeoutDelay() const; | |
| 61 bool HasTimeoutEvent() const; | |
| 62 | |
| 63 TouchEventQueue* touch_queue_; | |
| 64 | |
| 65 // How long to wait on a touch ack before cancelling the touch sequence. | |
| 66 const base::TimeDelta desktop_timeout_delay_; | |
| 67 const base::TimeDelta mobile_timeout_delay_; | |
| 68 bool use_mobile_timeout_; | |
| 69 | |
| 70 // The touch event source for which we expect the next ack. | |
| 71 PendingAckState pending_ack_state_; | |
| 72 | |
| 73 // The event for which the ack timeout is triggered. | |
| 74 TouchEventWithLatencyInfo timeout_event_; | |
| 75 | |
| 76 // Provides timeout-based callback behavior. | |
| 77 TimeoutMonitor timeout_monitor_; | |
| 78 | |
| 79 bool enabled_; | |
| 80 bool enabled_for_current_sequence_; | |
| 81 | |
| 82 // Bookkeeping to classify and log whether a touch sequence times out. | |
| 83 bool sequence_awaiting_uma_update_; | |
| 84 bool sequence_using_mobile_timeout_; | |
| 85 }; | |
| 86 | |
| 87 } // namespace content | |
| 88 | |
| 89 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_TOUCH_TIMEOUT_HANDLER_H_ | |
| OLD | NEW |