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

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: Code review 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..ba9697c3f44e83e3f5e6151e4e7a2b7491e1bd56
--- /dev/null
+++ b/content/browser/renderer_host/input/input_queue.h
@@ -0,0 +1,98 @@
+// 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>
aelias_OOO_until_Jul13 2013/08/15 00:52:15 Delete this include.
jdduke (slow) 2013/08/15 23:22:26 Done.
+
+#include "base/basictypes.h"
+#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.
+#include "content/common/content_export.h"
+
+namespace content {
+
+class EventPacket;
+class InputAckObserver;
+class InputEvent;
+class InputQueueClient;
+
+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
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.
+ // 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, InputAckObserver* ack_observer);
+
+ // 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);
+
+ // Total number of evenst in the queue, both being flushed and pending flush.
+ size_t QueuedEventCount() const;
+
+ protected:
+ friend class InputQueueTest;
+
+ // 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();
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_:
+
+ // 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/15 00:52:15 Nit: next_packet_id_
jdduke (slow) 2013/08/15 23:22:26 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_;
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
+
+ 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