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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/input_queue.h
diff --git a/content/browser/renderer_host/input/input_queue.h b/content/browser/renderer_host/input/input_queue.h
new file mode 100644
index 0000000000000000000000000000000000000000..9ce426c5b098e2ec9dea449c6a3ac2deba05b00c
--- /dev/null
+++ b/content/browser/renderer_host/input/input_queue.h
@@ -0,0 +1,107 @@
+// Copyright (c) 2013 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_BROWSER_RENDERER_HOST_INPUT_INPUT_QUEUE_H_
+#define CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_QUEUE_H_
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "content/common/content_export.h"
+
+namespace content {
+
+class InputQueueClient;
+
+class EventAckHandler;
+class EventPacket;
+class InputEvent;
+
+class CONTENT_EXPORT InputQueue {
+ public:
+
+ // The |client| must outlive this object.
+ InputQueue(InputQueueClient* client);
+ virtual ~InputQueue();
+
+ // If |ack_handler| is non-null, it must live at least until |event| has been
+ // ack'ed. If null, no ack response is made for |event|.
+ // If |event| is flagged for follow-up, its |ack_handler| will receive
+ // an EventInjector capable of inserting events into the current flush stream.
+ 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...
+
+ // Initiates the flush of the pending event packet to |client_|, if necessary.
+ // This should only be called in response to |client_->SetNeedsFlush()|
+ // Note: Events queued after this call, but before the flush completes, will
+ // not be sent until the following flush. If a flush is still in progress, the
+ // call will be ignored.
+ void FlushEventsInCurrentFrame();
+
+
+ // Called by the owner upon EventPacket responses from the sender target. This
+ // will dispatch event acks for events with a corresponding |ack_handler|.
+ enum AckResult {
+ ACK_OK, // |acked_packet| was processed successfully.
+ ACK_UNEXPECTED, // |acked_packet| was unexpected; no flush was in-progress.
+ ACK_INVALID, // |acked_packet| contains invalid data.
+ ACK_SHUTDOWN // |acked_packet| processing triggered queue shutdown.
+ };
+ AckResult OnEventPacketAck(const EventPacket& acked_packet);
+
+ // 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
+ // |DidFlush()| will be signalled to the client, but the queue will continue
+ // waiting for the packet ack. If there are pending events, a flush
+ // will be requested; if the requested |Flush()| is made before the
+ // outstanding packet has been ack'ed, the packet will be dropped and all
+ // outstanding events will be marked |UNHANDLED| and ack'ed appropriately.
+ void OnEventPacketAckDelayed();
+
+ // 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.
+ size_t QueuedEventCount() const;
+
+ protected:
+ 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
+
+ // If we have a current, non-empty EventPacket, deliver it to |client_|.
+ // Otherwise, finish the flush by signalling flush completion, and requesting
+ // an additional flush, if necessary.
+ void TryFinishFlush();
+
+ // Requests a flush via the |client_|, but only if a flush is required and has
+ // not yet been requested.
+ void RequestFlushIfNecessary();
+
+ // Signal flush completion to the |client_| if not yet sent for this flush.
+ void SignalFlushedIfNecessary();
+
+ // True when |current_frame_| is non-empty.
+ bool IsFlushing() const;
+
+private:
+ InputQueueClient* client_;
+
+ // Used to assign unique ID's to each EventPacket that is generated.
+ 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.
+
+ // Avoid spamming the client with redundant flush requests.
+ bool flush_requested_;
+
+ // Allows a DidFlush() signal before the packet has been ack'ed.
+ bool flush_signalled_;
+
+ class EventFrame;
+
+ // Events currently being flushed.
+ scoped_ptr<EventFrame> current_frame_;
+
+ // Events pending flush.
+ scoped_ptr<EventFrame> pending_frame_;
+
+ DISALLOW_COPY_AND_ASSIGN(InputQueue);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_QUEUE_H_

Powered by Google App Engine
This is Rietveld 408576698