Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_INPUT_RENDER_WIDGET_HOST_LATENCY_TRACKER_H _ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_RENDER_WIDGET_HOST_LATENCY_TRACKER_H _ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_RENDER_WIDGET_HOST_LATENCY_TRACKER_H _ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_RENDER_WIDGET_HOST_LATENCY_TRACKER_H _ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "content/browser/renderer_host/event_with_latency_info.h" | 13 #include "content/browser/renderer_host/event_with_latency_info.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "ui/events/latency_info.h" | 15 #include "ui/events/latency_info.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 // Utility class for tracking the latency of events passing through | 19 // Utility class for tracking the latency of events passing through |
| 20 // a given RenderWidgetHost. | 20 // a given RenderWidgetHost. |
| 21 class CONTENT_EXPORT RenderWidgetHostLatencyTracker { | 21 class CONTENT_EXPORT RenderWidgetHostLatencyTracker { |
| 22 public: | 22 public: |
| 23 RenderWidgetHostLatencyTracker(); | 23 RenderWidgetHostLatencyTracker(); |
| 24 ~RenderWidgetHostLatencyTracker(); | 24 ~RenderWidgetHostLatencyTracker(); |
| 25 | 25 |
| 26 // Associates the latency tracker with a given route and process. | 26 // Associates the latency tracker with a given route and process. |
| 27 // Called once after the RenderWidgetHost is fully initialized. | 27 // Called once after the RenderWidgetHost is fully initialized. |
| 28 void Initialize(int routing_id, int process_id); | 28 void Initialize(int routing_id, int process_id); |
| 29 | 29 |
| 30 void ComputeInputLatencyHistograms(blink::WebInputEvent::Type type, | |
| 31 int64_t latency_component_id, | |
| 32 const ui::LatencyInfo& latency, | |
| 33 bool default_prevented); | |
| 34 | |
| 30 // Populates the LatencyInfo with relevant entries for latency tracking. | 35 // Populates the LatencyInfo with relevant entries for latency tracking. |
| 31 // Called when an event is received by the RenderWidgetHost, prior to | 36 // Called when an event is received by the RenderWidgetHost, prior to |
| 32 // that event being forwarded to the renderer (via the InputRouter). | 37 // that event being forwarded to the renderer (via the InputRouter). |
| 33 void OnInputEvent(const blink::WebInputEvent& event, | 38 void OnInputEvent(const blink::WebInputEvent& event, |
| 34 ui::LatencyInfo* latency); | 39 ui::LatencyInfo* latency); |
| 35 | 40 |
| 41 // Populates the LatencyInfo with relevant entries for latency | |
| 42 // tracking. Called when an event is about to be forwarded to the renderer. | |
| 43 void OnForwardEventToRenderer(const blink::WebInputEvent& event, | |
| 44 ui::LatencyInfo* latency); | |
| 45 | |
| 36 // Populates the LatencyInfo with relevant entries for latency tracking, also | 46 // Populates the LatencyInfo with relevant entries for latency tracking, also |
| 37 // terminating latency tracking for events that did not trigger rendering and | 47 // terminating latency tracking for events that did not trigger rendering and |
| 38 // performing relevant UMA latency reporting. Called when an event is ack'ed | 48 // performing relevant UMA latency reporting. Called when an event is ack'ed |
| 39 // to the RenderWidgetHost (from the InputRouter). | 49 // to the RenderWidgetHost (from the InputRouter). |
| 40 void OnInputEventAck(const blink::WebInputEvent& event, | 50 void OnInputEventAck(const blink::WebInputEvent& event, |
| 41 ui::LatencyInfo* latency); | 51 ui::LatencyInfo* latency, |
| 52 bool defaultPrevented); | |
|
aelias_OOO_until_Jul13
2016/04/05 18:35:18
I think it might be useful to have a way to break
| |
| 42 | 53 |
| 43 // Populates renderer-created LatencyInfo entries with the appropriate latency | 54 // Populates renderer-created LatencyInfo entries with the appropriate latency |
| 44 // component id. Called when the RenderWidgetHost receives a compositor swap | 55 // component id. Called when the RenderWidgetHost receives a compositor swap |
| 45 // update from the renderer. | 56 // update from the renderer. |
| 46 void OnSwapCompositorFrame(std::vector<ui::LatencyInfo>* latencies); | 57 void OnSwapCompositorFrame(std::vector<ui::LatencyInfo>* latencies); |
| 47 | 58 |
| 48 // Terminates latency tracking for events that triggered rendering, also | 59 // Terminates latency tracking for events that triggered rendering, also |
| 49 // performing relevant UMA latency reporting. | 60 // performing relevant UMA latency reporting. |
| 50 // Called when the RenderWidgetHost receives a swap update from the GPU. | 61 // Called when the RenderWidgetHost receives a swap update from the GPU. |
| 51 void OnFrameSwapped(const ui::LatencyInfo& latency); | 62 void OnFrameSwapped(const ui::LatencyInfo& latency); |
| 52 | 63 |
| 53 // WebInputEvent coordinates are in DPIs, while LatencyInfo expects | 64 // WebInputEvent coordinates are in DPIs, while LatencyInfo expects |
| 54 // coordinates in device pixels. | 65 // coordinates in device pixels. |
| 55 void set_device_scale_factor(float device_scale_factor) { | 66 void set_device_scale_factor(float device_scale_factor) { |
| 56 device_scale_factor_ = device_scale_factor; | 67 device_scale_factor_ = device_scale_factor; |
| 57 } | 68 } |
| 58 | 69 |
| 59 // Returns the ID that uniquely describes this component to the latency | 70 // Returns the ID that uniquely describes this component to the latency |
| 60 // subsystem. | 71 // subsystem. |
| 61 int64_t latency_component_id() const { return latency_component_id_; } | 72 int64_t latency_component_id() const { return latency_component_id_; } |
| 62 | 73 |
| 63 private: | 74 private: |
| 64 int64_t last_event_id_; | 75 int64_t last_event_id_; |
| 65 int64_t latency_component_id_; | 76 int64_t latency_component_id_; |
| 66 float device_scale_factor_; | 77 float device_scale_factor_; |
| 67 bool has_seen_first_gesture_scroll_update_; | 78 bool has_seen_first_gesture_scroll_update_; |
| 79 // Whether the current stream of touch events has ever included more than one | |
| 80 // touch point. | |
| 81 bool multi_finger_gesture_; | |
| 82 // Whether the touch start for the current stream of touch events had its | |
| 83 // default action prevented. Only valid for single finger gestures. | |
| 84 bool touch_start_default_prevented_; | |
| 68 | 85 |
| 69 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostLatencyTracker); | 86 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostLatencyTracker); |
| 70 }; | 87 }; |
| 71 | 88 |
| 72 } // namespace content | 89 } // namespace content |
| 73 | 90 |
| 74 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_RENDER_WIDGET_HOST_LATENCY_TRACKE R_H_ | 91 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_RENDER_WIDGET_HOST_LATENCY_TRACKE R_H_ |
| OLD | NEW |