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

Unified Diff: content/browser/renderer_host/input/input_queue.h

Issue 19220002: [WIP] BufferedInputRouter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix client assignment Created 7 years, 3 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..f3322a3dd6b2d399fb9da8b2e0ca88c8ccf5a9a7
--- /dev/null
+++ b/content/browser/renderer_host/input/input_queue.h
@@ -0,0 +1,82 @@
+// 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 "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/common/content_export.h"
+#include "content/common/input/input_event_disposition.h"
+
+namespace content {
+
+class BrowserInputEvent;
+class EventPacketAck;
+class InputQueueClient;
+
+// |InputQueue| handles browser input event batching and response.
+// Event packets are assembled into sequential event packets. A flush entails
+// delivery and dispatch of a single event packet, and continues until the
+// packet is ack'ed and all its events have been dispatched to the renderer.
+class CONTENT_EXPORT InputQueue {
+ public:
+ // The |client| should outlive the InputQueue.
+ InputQueue(InputQueueClient* client);
+ virtual ~InputQueue();
+
+ // If a flush is in progress, |event| will be dispatched in the next flush.
+ // If no flush is in progress, a flush will be requested if necessary.
+ // |event| is assumed to be both non-NULL and valid.
+ void QueueEvent(scoped_ptr<BrowserInputEvent> event);
+
+ // Initiates the flush of the pending event packet to |client_|, if necessary.
+ // This should only be called in response to |client_->SetNeedsFlush()|.
+ void BeginFlush();
+
+ // 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(int64 packet_id,
+ const InputEventDispositions& dispositions);
+
+ // Total number of evenst in the queue, both being flushed and pending flush.
+ size_t QueuedEventCount() const;
+
+ protected:
+ friend class InputQueueTest;
+
+ // Delivers |in_flush_packet_| to the client.
+ void DeliverInFlushPacket();
+
+ // Requests a flush via |client_| if the necessary request has not been made.
+ void RequestFlushIfNecessary();
+
+ // True when |in_flush_packet_| is non-empty.
+ bool FlushInProgress() const;
+
+ private:
+ InputQueueClient* client_;
+
+ // Used to assign unique, non-zero ID's to each delivered EventPacket.
+ int64 next_packet_id_;
+
+ // Avoid spamming the client with redundant flush requests.
+ bool flush_requested_;
+
+ class BrowserEventPacket;
+ scoped_ptr<BrowserEventPacket> in_flush_packet_;
+ scoped_ptr<BrowserEventPacket> pending_flush_packet_;
+
+ DISALLOW_COPY_AND_ASSIGN(InputQueue);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_INPUT_QUEUE_H_
« no previous file with comments | « content/browser/renderer_host/input/input_ack_handler.h ('k') | content/browser/renderer_host/input/input_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698