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

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.h

Issue 13931009: Add latency info to input events sent to RenderWidget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
11 #include <queue> 11 #include <queue>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/gtest_prod_util.h" 17 #include "base/gtest_prod_util.h"
18 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/observer_list.h" 20 #include "base/observer_list.h"
21 #include "base/process_util.h" 21 #include "base/process_util.h"
22 #include "base/string16.h" 22 #include "base/string16.h"
23 #include "base/time.h" 23 #include "base/time.h"
24 #include "base/timer.h" 24 #include "base/timer.h"
25 #include "build/build_config.h" 25 #include "build/build_config.h"
26 #include "cc/debug/latency_info.h"
26 #include "content/common/view_message_enums.h" 27 #include "content/common/view_message_enums.h"
27 #include "content/port/common/input_event_ack_state.h" 28 #include "content/port/common/input_event_ack_state.h"
28 #include "content/public/browser/render_widget_host.h" 29 #include "content/public/browser/render_widget_host.h"
29 #include "content/public/common/page_zoom.h" 30 #include "content/public/common/page_zoom.h"
30 #include "ipc/ipc_listener.h" 31 #include "ipc/ipc_listener.h"
31 #include "ui/base/ime/text_input_type.h" 32 #include "ui/base/ime/text_input_type.h"
32 #include "ui/gfx/native_widget_types.h" 33 #include "ui/gfx/native_widget_types.h"
33 34
34 class WebCursor; 35 class WebCursor;
35 struct AcceleratedSurfaceMsg_BufferPresented_Params; 36 struct AcceleratedSurfaceMsg_BufferPresented_Params;
(...skipping 24 matching lines...) Expand all
60 61
61 #if defined(OS_ANDROID) 62 #if defined(OS_ANDROID)
62 namespace WebKit { 63 namespace WebKit {
63 class WebLayer; 64 class WebLayer;
64 } 65 }
65 #endif 66 #endif
66 67
67 namespace content { 68 namespace content {
68 class BackingStore; 69 class BackingStore;
69 class GestureEventFilter; 70 class GestureEventFilter;
71 class GestureEventLatency;
70 class MockRenderWidgetHost; 72 class MockRenderWidgetHost;
71 class OverscrollController; 73 class OverscrollController;
72 class RenderWidgetHostDelegate; 74 class RenderWidgetHostDelegate;
73 class RenderWidgetHostViewPort; 75 class RenderWidgetHostViewPort;
74 class SmoothScrollGesture; 76 class SmoothScrollGesture;
75 class TouchEventQueue; 77 class TouchEventQueue;
76 struct EditCommand; 78 struct EditCommand;
77 79
78 // This implements the RenderWidgetHost interface that is exposed to 80 // This implements the RenderWidgetHost interface that is exposed to
79 // embedders of content, and adds things only visible to content. 81 // embedders of content, and adds things only visible to content.
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 // Stops all existing hang monitor timeouts and assumes the renderer is 248 // Stops all existing hang monitor timeouts and assumes the renderer is
247 // responsive. 249 // responsive.
248 void StopHangMonitorTimeout(); 250 void StopHangMonitorTimeout();
249 251
250 // Forwards the given message to the renderer. These are called by the view 252 // Forwards the given message to the renderer. These are called by the view
251 // when it has received a message. 253 // when it has received a message.
252 void ForwardGestureEvent(const WebKit::WebGestureEvent& gesture_event); 254 void ForwardGestureEvent(const WebKit::WebGestureEvent& gesture_event);
253 virtual void ForwardTouchEvent(const WebKit::WebTouchEvent& touch_event); 255 virtual void ForwardTouchEvent(const WebKit::WebTouchEvent& touch_event);
254 256
255 // Forwards the given event immediately to the renderer. 257 // Forwards the given event immediately to the renderer.
256 void ForwardMouseEventImmediately(const WebKit::WebMouseEvent& mouse_event); 258 void ForwardMouseEventImmediately(const WebKit::WebMouseEvent& mouse_event,
259 const cc::LatencyInfo& latency_info);
257 void ForwardTouchEventImmediately(const WebKit::WebTouchEvent& touch_event); 260 void ForwardTouchEventImmediately(const WebKit::WebTouchEvent& touch_event);
258 void ForwardGestureEventImmediately( 261 void ForwardGestureEventImmediately(
259 const WebKit::WebGestureEvent& gesture_event); 262 const WebKit::WebGestureEvent& gesture_event);
260 263
261 void CancelUpdateTextDirection(); 264 void CancelUpdateTextDirection();
262 265
263 // Called when a mouse click/gesture tap activates the renderer. 266 // Called when a mouse click/gesture tap activates the renderer.
264 virtual void OnPointerEventActivate(); 267 virtual void OnPointerEventActivate();
265 268
266 // Notifies the renderer whether or not the input method attached to this 269 // Notifies the renderer whether or not the input method attached to this
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 455
453 int SyntheticScrollMessageInterval() const; 456 int SyntheticScrollMessageInterval() const;
454 457
455 // Sets whether the overscroll controller should be enabled for this page. 458 // Sets whether the overscroll controller should be enabled for this page.
456 void SetOverscrollControllerEnabled(bool enabled); 459 void SetOverscrollControllerEnabled(bool enabled);
457 460
458 // Suppreses future char events until a keydown. See 461 // Suppreses future char events until a keydown. See
459 // suppress_next_char_events_. 462 // suppress_next_char_events_.
460 void SuppressNextCharEvents(); 463 void SuppressNextCharEvents();
461 464
465 void FrameSwapped(const cc::LatencyInfo& latency_info);
466
467 // Returns the ID that uniquely describes this component to the latency
468 // subsystem.
469 int64 GetLatencyComponentId();
470
471 class FrameSwappedObserver {
piman 2013/04/22 20:46:38 There doesn't seem to be any implementation of thi
472 public:
473 virtual void OnFrameSwapped(RenderWidgetHostImpl* rwhi,
474 const cc::LatencyInfo& latency_info) = 0;
475 };
476
477 void AddFrameSwappedObserver(FrameSwappedObserver* observer);
478 void RemoveFrameSwappedObserver(FrameSwappedObserver* observer);
479
462 protected: 480 protected:
463 virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() OVERRIDE; 481 virtual RenderWidgetHostImpl* AsRenderWidgetHostImpl() OVERRIDE;
464 482
465 // Transmits the given input event. This is an internal helper for 483 // Transmits the given input event. This is an internal helper for
466 // |ForwardInputEvent()| and should not be used directly from elsewhere. 484 // |ForwardInputEvent()| and should not be used directly from elsewhere.
467 void SendInputEvent(const WebKit::WebInputEvent& input_event, 485 void SendInputEvent(const WebKit::WebInputEvent& input_event,
468 int event_size, bool is_keyboard_shortcut); 486 int event_size, const cc::LatencyInfo& latency_info,
487 bool is_keyboard_shortcut);
469 488
470 // Internal implementation of the public Forward*Event() methods. 489 // Internal implementation of the public Forward*Event() methods.
471 void ForwardInputEvent(const WebKit::WebInputEvent& input_event, 490 void ForwardInputEvent(const WebKit::WebInputEvent& input_event,
472 int event_size, bool is_keyboard_shortcut); 491 int event_size, const cc::LatencyInfo& latency_info,
492 bool is_keyboard_shortcut);
493
494 // Internal forwarding implementations that take a LatencyInfo.
495 virtual void ForwardMouseEventWithLatencyInfo(
496 const WebKit::WebMouseEvent& mouse_event,
497 const cc::LatencyInfo& latency_info);
498 virtual void ForwardWheelEventWithLatencyInfo(
499 const WebKit::WebMouseWheelEvent& wheel_event,
500 const cc::LatencyInfo& latency_info);
501
502 // Create a LatencyInfo struct for a new input event that was just received.
503 cc::LatencyInfo NewInputLatencyInfo();
473 504
474 // Called when we receive a notification indicating that the renderer 505 // Called when we receive a notification indicating that the renderer
475 // process has gone. This will reset our state so that our state will be 506 // process has gone. This will reset our state so that our state will be
476 // consistent if a new renderer is created. 507 // consistent if a new renderer is created.
477 void RendererExited(base::TerminationStatus status, int exit_code); 508 void RendererExited(base::TerminationStatus status, int exit_code);
478 509
479 // Retrieves an id the renderer can use to refer to its view. 510 // Retrieves an id the renderer can use to refer to its view.
480 // This is used for various IPC messages, including plugins. 511 // This is used for various IPC messages, including plugins.
481 gfx::NativeViewId GetNativeViewId() const; 512 gfx::NativeViewId GetNativeViewId() const;
482 513
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 gfx::Rect last_view_screen_rect_; 764 gfx::Rect last_view_screen_rect_;
734 gfx::Rect last_window_screen_rect_; 765 gfx::Rect last_window_screen_rect_;
735 766
736 // True if a mouse move event was sent to the render view and we are waiting 767 // True if a mouse move event was sent to the render view and we are waiting
737 // for a corresponding ViewHostMsg_HandleInputEvent_ACK message. 768 // for a corresponding ViewHostMsg_HandleInputEvent_ACK message.
738 bool mouse_move_pending_; 769 bool mouse_move_pending_;
739 770
740 // The next mouse move event to send (only non-null while mouse_move_pending_ 771 // The next mouse move event to send (only non-null while mouse_move_pending_
741 // is true). 772 // is true).
742 scoped_ptr<WebKit::WebMouseEvent> next_mouse_move_; 773 scoped_ptr<WebKit::WebMouseEvent> next_mouse_move_;
774 cc::LatencyInfo next_mouse_move_latency_info_;
743 775
744 // (Similar to |mouse_move_pending_|.) True if a mouse wheel event was sent 776 // (Similar to |mouse_move_pending_|.) True if a mouse wheel event was sent
745 // and we are waiting for a corresponding ack. 777 // and we are waiting for a corresponding ack.
746 bool mouse_wheel_pending_; 778 bool mouse_wheel_pending_;
747 WebKit::WebMouseWheelEvent current_wheel_event_; 779 WebKit::WebMouseWheelEvent current_wheel_event_;
748 780
749 typedef std::deque<WebKit::WebMouseWheelEvent> WheelEventQueue; 781 typedef std::deque<std::pair<WebKit::WebMouseWheelEvent, cc::LatencyInfo> >
piman 2013/04/22 20:46:38 nit: rather than a std::pair, an explicit struct i
782 WheelEventQueue;
750 783
751 // (Similar to |next_mouse_move_|.) The next mouse wheel events to send. 784 // (Similar to |next_mouse_move_|.) The next mouse wheel events to send.
752 // Unlike mouse moves, mouse wheel events received while one is pending are 785 // Unlike mouse moves, mouse wheel events received while one is pending are
753 // coalesced (by accumulating deltas) if they match the previous event in 786 // coalesced (by accumulating deltas) if they match the previous event in
754 // modifiers. On the Mac, in particular, mouse wheel events are received at a 787 // modifiers. On the Mac, in particular, mouse wheel events are received at a
755 // high rate; not waiting for the ack results in jankiness, and using the same 788 // high rate; not waiting for the ack results in jankiness, and using the same
756 // mechanism as for mouse moves (just dropping old events when multiple ones 789 // mechanism as for mouse moves (just dropping old events when multiple ones
757 // would be queued) results in very slow scrolling. 790 // would be queued) results in very slow scrolling.
758 WheelEventQueue coalesced_mouse_wheel_events_; 791 WheelEventQueue coalesced_mouse_wheel_events_;
759 792
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 scoped_ptr<GestureEventFilter> gesture_event_filter_; 904 scoped_ptr<GestureEventFilter> gesture_event_filter_;
872 scoped_ptr<OverscrollController> overscroll_controller_; 905 scoped_ptr<OverscrollController> overscroll_controller_;
873 906
874 #if defined(OS_WIN) 907 #if defined(OS_WIN)
875 std::list<HWND> dummy_windows_for_activation_; 908 std::list<HWND> dummy_windows_for_activation_;
876 #endif 909 #endif
877 910
878 // List of callbacks for pending snapshot requests to the renderer. 911 // List of callbacks for pending snapshot requests to the renderer.
879 std::queue<base::Callback<void(bool, const SkBitmap&)> > pending_snapshots_; 912 std::queue<base::Callback<void(bool, const SkBitmap&)> > pending_snapshots_;
880 913
914 int64 last_input_number_;
915
916 ObserverList<FrameSwappedObserver> frame_swapped_observer_list_;
917
881 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl); 918 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostImpl);
882 }; 919 };
883 920
884 } // namespace content 921 } // namespace content
885 922
886 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_ 923 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698