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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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 CONTENT_RENDERER_INPUT_WEB_INPUT_EVENT_QUEUE_H_
6 #define CONTENT_RENDERER_INPUT_WEB_INPUT_EVENT_QUEUE_H_
7
8 #include <deque>
9
10 namespace content {
11
12 template <typename T>
13 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.
14 public:
15 enum class State { ITEM_PENDING, ITEM_NOT_PENDING };
16
17 WebInputEventQueue() : state_(State::ITEM_NOT_PENDING) {}
18
19 ~WebInputEventQueue() {
20 if (!queue_.empty())
21 STLDeleteElements(&queue_);
22 }
23
24 // Adds an event to the queue. The event may be coalesced with previously
25 // queued events.
26 void Queue(const T& event) {
27 if (!queue_.empty()) {
28 T* last_event = queue_.back();
29 if (last_event->CanCoalesceWith(event)) {
30 last_event->CoalesceWith(event);
31 return;
32 }
33 }
34 queue_.push_back(new T(event));
35 }
36
37 scoped_ptr<T> Deque() {
38 scoped_ptr<T> result;
39 if (!queue_.empty()) {
40 result.reset(queue_.front());
41 queue_.pop_front();
42 }
43 return result;
44 }
45
46 bool empty() const { return queue_.empty(); }
47
48 size_t size() const { return queue_.size(); }
49
50 void set_state(State state) { state_ = state; }
51
52 State state() const WARN_UNUSED_RESULT { return state_; }
53
54 private:
55 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.
56 EventQueue queue_;
57 State state_;
58
59 DISALLOW_COPY_AND_ASSIGN(WebInputEventQueue);
60 };
61
62 } // namespace content
63
64 #endif // CONTENT_RENDERER_INPUT_WEB_INPUT_EVENT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698