Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: content/renderer/input/main_thread_event_queue.h

Issue 2765583002: Teach main thread event queue about closures. (Closed)
Patch Set: Remove two virtuals Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/input/main_thread_event_queue.h
diff --git a/content/renderer/input/main_thread_event_queue.h b/content/renderer/input/main_thread_event_queue.h
index c793bdd7efcc0a2b0fc580f5095e61eb3cba3f93..45923f8fcac78f59d6461de485d1f5a4c6c7b953 100644
--- a/content/renderer/input/main_thread_event_queue.h
+++ b/content/renderer/input/main_thread_event_queue.h
@@ -10,8 +10,8 @@
#include "content/common/content_export.h"
#include "content/common/input/input_event_ack_state.h"
#include "content/common/input/input_event_dispatch_type.h"
-#include "content/common/input/web_input_event_queue.h"
#include "content/public/common/content_features.h"
+#include "content/renderer/input/main_thread_event_queue_task_list.h"
#include "content/renderer/input/scoped_web_input_event_with_latency_info.h"
#include "third_party/WebKit/public/platform/WebInputEvent.h"
#include "third_party/WebKit/public/platform/scheduler/renderer/renderer_scheduler.h"
@@ -20,50 +20,6 @@
namespace content {
-class EventWithDispatchType : public ScopedWebInputEventWithLatencyInfo {
- public:
- EventWithDispatchType(ui::WebScopedInputEvent event,
- const ui::LatencyInfo& latency,
- InputEventDispatchType dispatch_type,
- bool originally_cancelable);
- ~EventWithDispatchType();
- void CoalesceWith(const EventWithDispatchType& other);
-
- const std::deque<uint32_t>& blockingCoalescedEventIds() const {
- return blocking_coalesced_event_ids_;
- }
- InputEventDispatchType dispatchType() const { return dispatch_type_; }
- base::TimeTicks creationTimestamp() const { return creation_timestamp_; }
- base::TimeTicks lastCoalescedTimestamp() const {
- return last_coalesced_timestamp_;
- }
-
- size_t coalescedCount() const {
- return non_blocking_coalesced_count_ + blocking_coalesced_event_ids_.size();
- }
-
- bool originallyCancelable() const { return originally_cancelable_; }
-
- private:
- InputEventDispatchType dispatch_type_;
-
- // Contains the unique touch event ids to be acked. If
- // the events are not TouchEvents the values will be 0. More importantly for
- // those cases the deque ends up containing how many additional ACKs
- // need to be sent.
- std::deque<uint32_t> blocking_coalesced_event_ids_;
- // Contains the number of non-blocking events coalesced.
- size_t non_blocking_coalesced_count_;
- base::TimeTicks creation_timestamp_;
- base::TimeTicks last_coalesced_timestamp_;
-
- // Whether the received event was originally cancelable or not. The compositor
- // input handler can change the event based on presence of event handlers so
- // this is the state at which the renderer received the event from the
- // browser.
- bool originally_cancelable_;
-};
-
class CONTENT_EXPORT MainThreadEventQueueClient {
public:
// Handle an |event| that was previously queued (possibly
@@ -134,6 +90,7 @@ class CONTENT_EXPORT MainThreadEventQueue
InputEventDispatchType dispatch_type,
InputEventAckState ack_result);
void DispatchRafAlignedInput(base::TimeTicks frame_time);
+ void QueueClosure(const base::Closure& closure);
// Call once the main thread has handled an outstanding |type| event
// in flight.
@@ -144,9 +101,9 @@ class CONTENT_EXPORT MainThreadEventQueue
private:
friend class base::RefCountedThreadSafe<MainThreadEventQueue>;
~MainThreadEventQueue();
- void QueueEvent(std::unique_ptr<EventWithDispatchType> event);
- void SendEventNotificationToMainThread();
- void DispatchSingleEvent();
+ void QueueEvent(std::unique_ptr<MainThreadEventQueueTask> event);
+ void PostTaskToMainThread();
+ void DispatchEvents();
void DispatchInFlightEvent();
void PossiblyScheduleMainFrame();
@@ -154,14 +111,15 @@ class CONTENT_EXPORT MainThreadEventQueue
const ui::LatencyInfo& latency,
InputEventDispatchType original_dispatch_type);
- bool IsRafAlignedInputDisabled();
- bool IsRafAlignedEvent(const blink::WebInputEvent& event);
+ bool IsRafAlignedInputDisabled() const;
+ bool IsRafAlignedEvent(
+ const std::unique_ptr<MainThreadEventQueueTask>& item) const;
friend class MainThreadEventQueueTest;
friend class MainThreadEventQueueInitializationTest;
int routing_id_;
MainThreadEventQueueClient* client_;
- std::unique_ptr<EventWithDispatchType> in_flight_event_;
+ std::unique_ptr<MainThreadEventQueueTask> in_flight_event_;
bool last_touch_start_forced_nonblocking_due_to_fling_;
bool enable_fling_passive_listener_flag_;
bool enable_non_blocking_due_to_main_thread_responsiveness_flag_;
@@ -174,8 +132,11 @@ class CONTENT_EXPORT MainThreadEventQueue
SharedState();
~SharedState();
- WebInputEventQueue<EventWithDispatchType> events_;
+ MainThreadEventQueueTaskList events_;
+ // A BeginMainFrame has been requested but not received yet.
bool sent_main_frame_request_;
+ // A PostTask to the main thread has been sent but not executed yet.
+ bool sent_post_task_;
base::TimeTicks last_async_touch_move_timestamp_;
};

Powered by Google App Engine
This is Rietveld 408576698