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