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

Side by Side Diff: content/browser/renderer_host/input/input_queue.h

Issue 20356003: Provided batched input delivery with a BufferedInputRouter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: BufferedInputRouter unit tests Created 7 years, 4 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 (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>
9
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "content/common/content_export.h"
13
14 namespace content {
15
16 class InputQueueClient;
17
18 class EventAckHandler;
19 class EventPacket;
20 class InputEvent;
21
22 class CONTENT_EXPORT InputQueue {
23 public:
24
25 // The |client| must outlive this object.
26 InputQueue(InputQueueClient* client);
27 virtual ~InputQueue();
28
29 // If |ack_handler| is non-null, it must live at least until |event| has been
30 // ack'ed. If null, no ack response is made for |event|.
31 // If |event| is flagged for follow-up, its |ack_handler| will receive
32 // an EventInjector capable of inserting events into the current flush stream.
33 void QueueEvent(const InputEvent& event, EventAckHandler* ack_handler);
aelias_OOO_until_Jul13 2013/08/13 06:11:51 InputQueue is basically a split-off portion of Buf
jdduke (slow) 2013/08/13 15:29:48 Right, this is what I told you I wanted to do...
34
35 // Initiates the flush of the pending event packet to |client_|, if necessary.
36 // This should only be called in response to |client_->SetNeedsFlush()|
37 // Note: Events queued after this call, but before the flush completes, will
38 // not be sent until the following flush. If a flush is still in progress, the
39 // call will be ignored.
40 void FlushEventsInCurrentFrame();
41
42
43 // Called by the owner upon EventPacket responses from the sender target. This
44 // will dispatch event acks for events with a corresponding |ack_handler|.
45 enum AckResult {
46 ACK_OK, // |acked_packet| was processed successfully.
47 ACK_UNEXPECTED, // |acked_packet| was unexpected; no flush was in-progress.
48 ACK_INVALID, // |acked_packet| contains invalid data.
49 ACK_SHUTDOWN // |acked_packet| processing triggered queue shutdown.
50 };
51 AckResult OnEventPacketAck(const EventPacket& acked_packet);
52
53 // Called by the owner if the in-flight EventPacket has been delayed.
aelias_OOO_until_Jul13 2013/08/13 06:11:51 OK, I've read this comment but I still don't reall
jdduke (slow) 2013/08/13 15:29:48 In short, "DidFlush" allows the client to proceed
54 // |DidFlush()| will be signalled to the client, but the queue will continue
55 // waiting for the packet ack. If there are pending events, a flush
56 // will be requested; if the requested |Flush()| is made before the
57 // outstanding packet has been ack'ed, the packet will be dropped and all
58 // outstanding events will be marked |UNHANDLED| and ack'ed appropriately.
59 void OnEventPacketAckDelayed();
60
61 // Total number of evenst in the queue, both being flushed and pending flush.
aelias_OOO_until_Jul13 2013/08/13 06:11:51 typo: "evenst"
jdduke (slow) 2013/08/13 15:29:48 Done.
62 size_t QueuedEventCount() const;
63
64 protected:
65 friend class InputQueueTest;
aelias_OOO_until_Jul13 2013/08/13 06:11:51 Shouldn't use friending here either.
jdduke (slow) 2013/08/13 15:29:48 Where is this policy established? I see "friend Fo
66
67 // If we have a current, non-empty EventPacket, deliver it to |client_|.
68 // Otherwise, finish the flush by signalling flush completion, and requesting
69 // an additional flush, if necessary.
70 void TryFinishFlush();
71
72 // Requests a flush via the |client_|, but only if a flush is required and has
73 // not yet been requested.
74 void RequestFlushIfNecessary();
75
76 // Signal flush completion to the |client_| if not yet sent for this flush.
77 void SignalFlushedIfNecessary();
78
79 // True when |current_frame_| is non-empty.
80 bool IsFlushing() const;
81
82 private:
83 InputQueueClient* client_;
84
85 // Used to assign unique ID's to each EventPacket that is generated.
86 int64 last_packet_id_;
aelias_OOO_until_Jul13 2013/08/13 06:11:51 next_packet_id_
jdduke (slow) 2013/08/13 15:29:48 Done.
87
88 // Avoid spamming the client with redundant flush requests.
89 bool flush_requested_;
90
91 // Allows a DidFlush() signal before the packet has been ack'ed.
92 bool flush_signalled_;
93
94 class EventFrame;
95
96 // Events currently being flushed.
97 scoped_ptr<EventFrame> current_frame_;
98
99 // Events pending flush.
100 scoped_ptr<EventFrame> pending_frame_;
101
102 DISALLOW_COPY_AND_ASSIGN(InputQueue);
103 };
104
105 } // namespace content
106
107 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698