OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_TASK_H_ | 5 #ifndef CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_TASK_H_ |
6 #define CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_TASK_H_ | 6 #define CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_TASK_H_ |
7 | 7 |
8 #include "content/common/input/input_event_ack_state.h" | 8 #include "content/common/input/input_event_ack_state.h" |
9 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 9 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
10 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" | 10 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 class MainThreadEventQueueClient; | 14 class MainThreadEventQueueClient; |
15 | 15 |
16 // A work item to execute from the main thread event queue. | 16 // A work item to execute from the main thread event queue. |
17 // The MainThreadEventQueue supports 2 types of tasks (subclasses): | 17 // The MainThreadEventQueue supports 2 types of tasks (subclasses): |
18 // 1) Closures | 18 // 1) Closures |
19 // 2) WebInputEvent | 19 // 2) WebInputEvent |
20 class MainThreadEventQueueTask { | 20 class MainThreadEventQueueTask { |
21 public: | 21 public: |
22 virtual ~MainThreadEventQueueTask() {} | 22 virtual ~MainThreadEventQueueTask() {} |
23 | 23 |
24 enum class CoalesceResult { | 24 enum class FilterResult { |
25 Coalesced, | 25 // The passed in event was coalesced into this event. Don't queue |
26 CannotCoalesce, | 26 // the new event. |
27 // Keep iterating on the queue looking for a matching event with the | 27 CoalescedEvent, |
28 // same modality. | 28 |
29 KeepSearching, | 29 // Stop invoking FilterNewEvent on any other events in the queue. |
| 30 StopIterating, |
| 31 |
| 32 // Keep invoking FilterNewEvent on the next older event in the queue. |
| 33 KeepIterating, |
30 }; | 34 }; |
31 | 35 |
32 virtual CoalesceResult CoalesceWith(const MainThreadEventQueueTask&) = 0; | 36 // Filter a new event that is about to be queued. Acceptable actions |
| 37 // are to coalesce event, stop iterating or keep iterating. |
| 38 // Iteration of the list begins at the end of the queue (newest to oldest). |
| 39 virtual FilterResult FilterNewEvent(const MainThreadEventQueueTask&) = 0; |
33 virtual bool IsWebInputEvent() const = 0; | 40 virtual bool IsWebInputEvent() const = 0; |
34 virtual void Dispatch(int routing_id, MainThreadEventQueueClient*) = 0; | 41 virtual void Dispatch(int routing_id, MainThreadEventQueueClient*) = 0; |
| 42 |
35 virtual void EventHandled( | 43 virtual void EventHandled( |
36 int routing_id, | 44 int routing_id, |
37 blink::scheduler::RendererScheduler* renderer_scheduler, | 45 blink::scheduler::RendererScheduler* renderer_scheduler, |
38 MainThreadEventQueueClient* client, | 46 MainThreadEventQueueClient* client, |
39 blink::WebInputEvent::Type type, | 47 blink::WebInputEvent::Type type, |
40 blink::WebInputEventResult result, | 48 blink::WebInputEventResult result, |
41 InputEventAckState ack_result) = 0; | 49 InputEventAckState ack_result) = 0; |
42 }; | 50 }; |
43 | 51 |
44 } // namespace content | 52 } // namespace content |
45 | 53 |
46 #endif // CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_TASK_H_ | 54 #endif // CONTENT_RENDERER_INPUT_MAIN_THREAD_EVENT_QUEUE_TASK_H_ |
OLD | NEW |