OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_LATENCY_TRACKER_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_LATENCY_TRACKER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "content/browser/renderer_host/event_with_latency_info.h" |
| 12 #include "ui/events/latency_info.h" |
| 13 |
| 14 namespace content { |
| 15 |
| 16 // Utility class for tracking the latency of events passing through |
| 17 // a given RenderWidgetHost. |
| 18 class RenderWidgetHostLatencyTracker { |
| 19 public: |
| 20 RenderWidgetHostLatencyTracker(); |
| 21 ~RenderWidgetHostLatencyTracker(); |
| 22 |
| 23 // Associates the latency tracker with a given route and process. |
| 24 // Called once after the RenderWidgetHost is fully initialized. |
| 25 void Initialize(int routing_id, int process_id); |
| 26 |
| 27 // Populates the LatencyInfo with relevant entries for latency tracking. |
| 28 // Called when an event is received by the RenderWidgetHost, prior to |
| 29 // that event being forwarded to the renderer (via the InputRouter). |
| 30 void OnInputEvent(const blink::WebInputEvent& event, |
| 31 float device_scale_factor, |
| 32 ui::LatencyInfo* latency); |
| 33 |
| 34 // Populates the LatencyInfo with relevant entries for latency tracking, also |
| 35 // terminating latency tracking for events that did not trigger rendering and |
| 36 // performing relevant UMA latency reporting. Called when an event is ack'ed |
| 37 // to the RenderWidgetHost (from the InputRouter). |
| 38 void OnInputEventAck(const blink::WebInputEvent& event, |
| 39 ui::LatencyInfo* latency); |
| 40 |
| 41 // Populates renderer-created LatencyInfo entries with the appropriate latency |
| 42 // component id. Called when the RenderWidgetHost receives a compositor swap |
| 43 // update from the renderer. |
| 44 void OnSwapCompositorFrame(std::vector<ui::LatencyInfo>* latencies); |
| 45 |
| 46 // Terminates latency tracking for events that triggered rendering, also |
| 47 // performing relevant UMA latency reporting. |
| 48 // Called when the RenderWidgetHost receives a swap update from the GPU. |
| 49 void OnFrameSwapped(const ui::LatencyInfo& latency); |
| 50 |
| 51 // Returns the ID that uniquely describes this component to the latency |
| 52 // subsystem. |
| 53 int64 latency_component_id() const { return latency_component_id_; } |
| 54 |
| 55 private: |
| 56 int64 last_event_id_; |
| 57 int64 latency_component_id_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostLatencyTracker); |
| 60 }; |
| 61 |
| 62 } // namespace content |
| 63 |
| 64 #endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_LATENCY_TRACKER_H_ |
OLD | NEW |