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

Unified Diff: content/browser/renderer_host/input/buffered_input_router.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/buffered_input_router.h
diff --git a/content/browser/renderer_host/input/buffered_input_router.h b/content/browser/renderer_host/input/buffered_input_router.h
new file mode 100644
index 0000000000000000000000000000000000000000..606027137e93bad3daa9eb90eeeb3605cda94387
--- /dev/null
+++ b/content/browser/renderer_host/input/buffered_input_router.h
@@ -0,0 +1,135 @@
+// 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_INPUT_RENDERER_HOST_BUFFERED_INPUT_ROUTER_H_
+#define CONTENT_BROWSER_INPUT_RENDERER_HOST_BUFFERED_INPUT_ROUTER_H_
+
+#include <map>
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/time/time.h"
+#include "base/timer/timer.h"
+#include "content/browser/renderer_host/input/input_queue.h"
+#include "content/browser/renderer_host/input/input_queue_client.h"
+#include "content/browser/renderer_host/input/input_router.h"
+
+namespace IPC {
+class Sender;
+}
+
+namespace content {
+
+class InputAckHandler;
+class RenderProcessHost;
+class RenderWidgetHostImpl;
+
+// Batches input events into EventPackets using a general input queue. Packets
+// are sent the renderer on |Flush()|, called in response to flush requests.
+class CONTENT_EXPORT BufferedInputRouter
+ : public NON_EXPORTED_BASE(InputQueueClient),
+ public NON_EXPORTED_BASE(InputRouter) {
+ public:
+ BufferedInputRouter(IPC::Sender* sender,
+ InputRouterClient* client,
+ InputAckHandler* ack_handler,
+ int routing_id);
+ virtual ~BufferedInputRouter();
+
+ // InputRouter
+ virtual void Flush() OVERRIDE;
+ virtual bool SendInput(scoped_ptr<IPC::Message> message) OVERRIDE;
+ virtual void SendMouseEvent(
aelias_OOO_until_Jul13 2013/08/15 00:52:15 There should be a detailed comment here explaining
jdduke (slow) 2013/08/15 23:22:26 Done.
+ const MouseEventWithLatencyInfo& mouse_event) OVERRIDE;
+ virtual void SendWheelEvent(
+ const MouseWheelEventWithLatencyInfo& wheel_event) OVERRIDE;
+ virtual void SendKeyboardEvent(
+ const NativeWebKeyboardEvent& key_event,
+ const ui::LatencyInfo& latency_info) OVERRIDE;
+ virtual void SendGestureEvent(
+ const GestureEventWithLatencyInfo& gesture_event) OVERRIDE;
+ virtual void SendTouchEvent(
+ const TouchEventWithLatencyInfo& touch_event) OVERRIDE;
+ virtual void SendMouseEventImmediately(
+ const MouseEventWithLatencyInfo& mouse_event) OVERRIDE;
+ virtual void SendTouchEventImmediately(
+ const TouchEventWithLatencyInfo& touch_event) OVERRIDE;
+ virtual void SendGestureEventImmediately(
+ const GestureEventWithLatencyInfo& gesture_event) OVERRIDE;
+ virtual const NativeWebKeyboardEvent* GetLastKeyboardEvent() const OVERRIDE;
+ virtual bool ShouldForwardTouchEvent() const OVERRIDE;
+ virtual bool ShouldForwardGestureEvent(
+ const GestureEventWithLatencyInfo& gesture_event) const OVERRIDE;
+ virtual bool HasQueuedGestureEvents() const OVERRIDE;
+
+ // InputQueueClient
+ virtual void Deliver(const EventPacket& packet) OVERRIDE;
+ virtual void DidFlush() OVERRIDE;
+ virtual void SetNeedsFlush() OVERRIDE;
+ virtual std::vector<InputEvent> OnInputEventAck(
+ const InputEvent& acked_event) OVERRIDE;
+
+ // IPC::Receiver
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
+protected:
+ void OnInputEventAck(int64 event_id,
+ const WebKit::WebInputEvent& web_event,
+ const ui::LatencyInfo& latency_info,
+ InputEventAckState acked_result,
+ bool ack_from_input_queue);
+ void OnEventPacketAck(const EventPacket& acked_packet);
+ void OnHasTouchEventHandlers(bool has_handlers);
+
+ // Returns the non-zero ID associated with the |InputEvent| added to the
+ // |input_queue_|. If the event was dropped or filtered, returns 0.
+ int64 QueueWebEvent(const WebKit::WebInputEvent& web_event,
+ const ui::LatencyInfo& latency_info,
+ bool is_keyboard_shortcut,
+ bool has_followup);
+ // Used by |QueueWebEvent()|; returns true if an event was filtered and should
+ // not be added to the |input_queue_|.
+ bool FilterWebEvent(const WebKit::WebInputEvent& web_event,
+ const ui::LatencyInfo& latency_info);
+
+ // Generates a monotonically increasing sequences of id's, starting with 1.
+ int64 NextInputID();
+
+ const InputQueue* input_queue() const { return input_queue_.get(); }
+
+private:
+ InputRouterClient* client_;
+ InputAckHandler* ack_handler_;
+ IPC::Sender* sender_;
+ int routing_id_;
+
+ scoped_ptr<InputQueue> input_queue_;
+
+ // TODO(jdduke): Remove when we can properly serialize NativeWebKeyboardEvent.
+ // Alternatively, attach WebInputEvents to InputEvents but don't serialize.
+ typedef std::map<int64, NativeWebKeyboardEvent> KeyMap;
+ KeyMap queued_key_map_;
+
+ // Necessary for |HasQueuedGestureEvents()|.
+ int queued_gesture_count_;
+
+ // Necessary for |ShouldForwardTouchEvent()|.
+ bool has_touch_handler_;
+ int queued_touch_count_;
+
+ // This is non-NULL ONLY in the scope of OnInputEventAck(event, injector).
+ std::vector<InputEvent>* input_queue_override_;
+
+ // Used to assign unique ID's to each InputEvent that is generated.
+ int64 next_input_id_;
+
+ // 0 if there no in-flight EventPacket.
+ int64 in_flight_packet_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(BufferedInputRouter);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_INPUT_RENDERER_HOST_BUFFERED_INPUT_ROUTER_H_

Powered by Google App Engine
This is Rietveld 408576698