OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_COMMON_INPUT_WEB_INPUT_EVENT_QUEUE_H_ | 5 #ifndef CONTENT_COMMON_INPUT_WEB_INPUT_EVENT_QUEUE_H_ |
6 #define CONTENT_COMMON_INPUT_WEB_INPUT_EVENT_QUEUE_H_ | 6 #define CONTENT_COMMON_INPUT_WEB_INPUT_EVENT_QUEUE_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 if ((*last_event_iter)->CanCoalesceWith(*event.get())) { | 30 if ((*last_event_iter)->CanCoalesceWith(*event.get())) { |
31 (*last_event_iter)->CoalesceWith(*event.get()); | 31 (*last_event_iter)->CoalesceWith(*event.get()); |
32 return; | 32 return; |
33 } | 33 } |
34 break; | 34 break; |
35 } | 35 } |
36 queue_.emplace_back(std::move(event)); | 36 queue_.emplace_back(std::move(event)); |
37 } | 37 } |
38 | 38 |
| 39 const std::unique_ptr<T>& front() const { return queue_.front(); } |
| 40 const std::unique_ptr<T>& at(size_t pos) const { return queue_.at(pos); } |
| 41 |
39 std::unique_ptr<T> Pop() { | 42 std::unique_ptr<T> Pop() { |
40 std::unique_ptr<T> result; | 43 std::unique_ptr<T> result; |
41 if (!queue_.empty()) { | 44 if (!queue_.empty()) { |
42 result.reset(queue_.front().release()); | 45 result.reset(queue_.front().release()); |
43 queue_.pop_front(); | 46 queue_.pop_front(); |
44 } | 47 } |
45 return result; | 48 return result; |
46 } | 49 } |
47 | 50 |
48 bool empty() const { return queue_.empty(); } | 51 bool empty() const { return queue_.empty(); } |
49 | 52 |
50 size_t size() const { return queue_.size(); } | 53 size_t size() const { return queue_.size(); } |
51 | 54 |
52 private: | 55 private: |
53 typedef std::deque<std::unique_ptr<T>> EventQueue; | 56 typedef std::deque<std::unique_ptr<T>> EventQueue; |
54 EventQueue queue_; | 57 EventQueue queue_; |
55 | 58 |
56 DISALLOW_COPY_AND_ASSIGN(WebInputEventQueue); | 59 DISALLOW_COPY_AND_ASSIGN(WebInputEventQueue); |
57 }; | 60 }; |
58 | 61 |
59 } // namespace content | 62 } // namespace content |
60 | 63 |
61 #endif // CONTENT_COMMON_INPUT_WEB_INPUT_EVENT_QUEUE_H_ | 64 #endif // CONTENT_COMMON_INPUT_WEB_INPUT_EVENT_QUEUE_H_ |
OLD | NEW |