1 // Copyright 2016 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 THIRD_PARTY_BLINK_RENDERER_PLATFORM_WIDGET_INPUT_COMPOSITOR_THREAD_EVENT_QUEUE_H_ 6 #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_WIDGET_INPUT_COMPOSITOR_THREAD_EVENT_QUEUE_H_ 7 8 #include <memory> 9 10 #include "base/containers/circular_deque.h" 11 #include "third_party/blink/renderer/platform/platform_export.h" 12 #include "third_party/blink/renderer/platform/widget/input/event_with_callback.h" 13 14 namespace blink { 15 16 namespace test { 17 class InputHandlerProxyEventQueueTest; 18 } 19 20 // CompositorThreadEventQueue is a coalescing queue. It will examine 21 // the current events in the queue and will attempt to coalesce with 22 // the last event. 23 class PLATFORM_EXPORT CompositorThreadEventQueue { 24 public: 25 CompositorThreadEventQueue(); 26 ~CompositorThreadEventQueue(); 27 28 // Adds an event to the queue. The event may be coalesced with the last event. 29 void Queue(std::unique_ptr<EventWithCallback> event, 30 base::TimeTicks timestamp_now); 31 32 std::unique_ptr<EventWithCallback> Pop(); 33 empty()34 bool empty() const { return queue_.empty(); } 35 size()36 size_t size() const { return queue_.size(); } 37 38 private: 39 friend class test::InputHandlerProxyEventQueueTest; 40 using EventQueue = base::circular_deque<std::unique_ptr<EventWithCallback>>; 41 EventQueue queue_; 42 43 DISALLOW_COPY_AND_ASSIGN(CompositorThreadEventQueue); 44 }; 45 46 } // namespace blink 47 48 #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_WIDGET_INPUT_COMPOSITOR_THREAD_EVENT_QUEUE_H_ 49