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

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

Issue 1631963002: Plumb firing passive event listeners. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_wheel_passive_listeners_2a
Patch Set: Set dependency correctly Created 4 years, 11 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/web_input_event_queue.h
diff --git a/content/renderer/input/web_input_event_queue.h b/content/renderer/input/web_input_event_queue.h
new file mode 100644
index 0000000000000000000000000000000000000000..426f62a7c985068cc37f3f840e94f746c8d3fe81
--- /dev/null
+++ b/content/renderer/input/web_input_event_queue.h
@@ -0,0 +1,64 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_INPUT_WEB_INPUT_EVENT_QUEUE_H_
+#define CONTENT_RENDERER_INPUT_WEB_INPUT_EVENT_QUEUE_H_
+
+#include <deque>
+
+namespace content {
+
+template <typename T>
+class WebInputEventQueue {
aelias_OOO_until_Jul13 2016/01/26 04:50:41 Hmm, we sure have a lot of queue classes now. Thi
dtapuska 2016/01/26 16:53:15 Acknowledged.
+ public:
+ enum class State { ITEM_PENDING, ITEM_NOT_PENDING };
+
+ WebInputEventQueue() : state_(State::ITEM_NOT_PENDING) {}
+
+ ~WebInputEventQueue() {
+ if (!queue_.empty())
+ STLDeleteElements(&queue_);
+ }
+
+ // Adds an event to the queue. The event may be coalesced with previously
+ // queued events.
+ void Queue(const T& event) {
+ if (!queue_.empty()) {
+ T* last_event = queue_.back();
+ if (last_event->CanCoalesceWith(event)) {
+ last_event->CoalesceWith(event);
+ return;
+ }
+ }
+ queue_.push_back(new T(event));
+ }
+
+ scoped_ptr<T> Deque() {
+ scoped_ptr<T> result;
+ if (!queue_.empty()) {
+ result.reset(queue_.front());
+ queue_.pop_front();
+ }
+ return result;
+ }
+
+ bool empty() const { return queue_.empty(); }
+
+ size_t size() const { return queue_.size(); }
+
+ void set_state(State state) { state_ = state; }
+
+ State state() const WARN_UNUSED_RESULT { return state_; }
+
+ private:
+ typedef std::deque<T*> EventQueue;
aelias_OOO_until_Jul13 2016/01/26 04:50:41 Please switch to std::deque<scoped_ptr<T>>, that w
dtapuska 2016/01/26 16:53:15 Done.
+ EventQueue queue_;
+ State state_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebInputEventQueue);
+};
+
+} // namespace content
+
+#endif // CONTENT_RENDERER_INPUT_WEB_INPUT_EVENT_QUEUE_H_

Powered by Google App Engine
This is Rietveld 408576698