Chromium Code Reviews| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 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_BROWSER_RENDERER_HOST_INPUT_INPUT_QUEUE_H_ | |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_QUEUE_H_ | |
| 7 | |
| 8 #include <vector> | |
| 
 
aelias_OOO_until_Jul13
2013/08/15 00:52:15
Delete this include.
 
jdduke (slow)
2013/08/15 23:22:26
Done.
 
 | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/callback.h" | |
| 
 
aelias_OOO_until_Jul13
2013/08/15 00:52:15
Delete this include.
 
jdduke (slow)
2013/08/15 23:22:26
Done.
 
 | |
| 12 #include "content/common/content_export.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 class EventPacket; | |
| 17 class InputAckObserver; | |
| 18 class InputEvent; | |
| 19 class InputQueueClient; | |
| 20 | |
| 21 class CONTENT_EXPORT InputQueue { | |
| 22 public: | |
| 23 | |
| 24 // The |client| must outlive this object. | |
| 25 InputQueue(InputQueueClient* client); | |
| 26 virtual ~InputQueue(); | |
| 27 | |
| 28 // If |ack_handler| is non-null, it must live at least until |event| has been | |
| 
 
aelias_OOO_until_Jul13
2013/08/15 00:52:15
This comment is out of date.
 
jdduke (slow)
2013/08/15 23:22:26
Done.
 
 | |
| 29 // ack'ed. If null, no ack response is made for |event|. | |
| 30 // If |event| is flagged for follow-up, its |ack_handler| will receive | |
| 31 // an EventInjector capable of inserting events into the current flush stream. | |
| 32 void QueueEvent(const InputEvent& event, InputAckObserver* ack_observer); | |
| 33 | |
| 34 // Initiates the flush of the pending event packet to |client_|, if necessary. | |
| 35 // This should only be called in response to |client_->SetNeedsFlush()| | |
| 36 // Note: Events queued after this call, but before the flush completes, will | |
| 37 // not be sent until the following flush. If a flush is still in progress, the | |
| 38 // call will be ignored. | |
| 39 void FlushEventsInCurrentFrame(); | |
| 40 | |
| 41 | |
| 42 // Called by the owner upon EventPacket responses from the sender target. This | |
| 43 // will dispatch event acks for events with a corresponding |ack_handler|. | |
| 44 enum AckResult { | |
| 45 ACK_OK, // |acked_packet| was processed successfully. | |
| 46 ACK_UNEXPECTED, // |acked_packet| was unexpected; no flush was in-progress. | |
| 47 ACK_INVALID, // |acked_packet| contains invalid data. | |
| 48 ACK_SHUTDOWN // |acked_packet| processing triggered queue shutdown. | |
| 49 }; | |
| 50 AckResult OnEventPacketAck(const EventPacket& acked_packet); | |
| 51 | |
| 52 // Total number of evenst in the queue, both being flushed and pending flush. | |
| 53 size_t QueuedEventCount() const; | |
| 54 | |
| 55 protected: | |
| 56 friend class InputQueueTest; | |
| 57 | |
| 58 // If we have a current, non-empty EventPacket, deliver it to |client_|. | |
| 59 // Otherwise, finish the flush by signalling flush completion, and requesting | |
| 60 // an additional flush, if necessary. | |
| 61 void TryFinishFlush(); | |
| 62 | |
| 63 // Requests a flush via the |client_|, but only if a flush is required and has | |
| 64 // not yet been requested. | |
| 65 void RequestFlushIfNecessary(); | |
| 66 | |
| 67 // Signal flush completion to the |client_| if not yet sent for this flush. | |
| 68 void SignalFlushedIfNecessary(); | |
| 
 
aelias_OOO_until_Jul13
2013/08/15 00:52:15
Rename to SignalFlushCompleteIfNecessary
 
jdduke (slow)
2013/08/15 23:22:26
See comment below about flush_complete_signalled_:
 
 | |
| 69 | |
| 70 // True when |current_frame_| is non-empty. | |
| 71 bool IsFlushing() const; | |
| 72 | |
| 73 private: | |
| 74 InputQueueClient* client_; | |
| 75 | |
| 76 // Used to assign unique ID's to each EventPacket that is generated. | |
| 77 int64 last_packet_id_; | |
| 
 
aelias_OOO_until_Jul13
2013/08/15 00:52:15
Nit: next_packet_id_
 
jdduke (slow)
2013/08/15 23:22:26
Done.
 
 | |
| 78 | |
| 79 // Avoid spamming the client with redundant flush requests. | |
| 80 bool flush_requested_; | |
| 81 | |
| 82 // Allows a DidFlush() signal before the packet has been ack'ed. | |
| 83 bool flush_signalled_; | |
| 
 
aelias_OOO_until_Jul13
2013/08/15 00:52:15
Rename to flush_complete_signalled_.
 
jdduke (slow)
2013/08/15 23:22:26
Hmm, I think this is a relic from when I had the a
 
 | |
| 84 | |
| 85 class EventFrame; | |
| 86 | |
| 87 // Events currently being flushed. | |
| 88 scoped_ptr<EventFrame> current_frame_; | |
| 89 | |
| 90 // Events pending flush. | |
| 91 scoped_ptr<EventFrame> pending_frame_; | |
| 92 | |
| 93 DISALLOW_COPY_AND_ASSIGN(InputQueue); | |
| 94 }; | |
| 95 | |
| 96 } // namespace content | |
| 97 | |
| 98 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_QUEUE_H_ | |
| OLD | NEW |