Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 UI_EVENTS_LATENCY_INFO_H_ | 5 #ifndef UI_EVENTS_LATENCY_INFO_H_ |
| 6 #define UI_EVENTS_LATENCY_INFO_H_ | 6 #define UI_EVENTS_LATENCY_INFO_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "ui/events/events_export.h" | 13 #include "ui/events/events_export.h" |
| 14 | 14 |
| 15 namespace ui { | 15 namespace ui { |
| 16 | 16 |
| 17 enum LatencyComponentType { | 17 enum LatencyComponentType { |
| 18 // ---------------------------BEGIN COMPONENT------------------------------- | |
| 19 // BEGIN COMPONENT is when we show the latency begin in chrome://tracing. | |
| 18 // Timestamp when the input event is sent from RenderWidgetHost to renderer. | 20 // Timestamp when the input event is sent from RenderWidgetHost to renderer. |
| 19 INPUT_EVENT_LATENCY_RWH_COMPONENT, | 21 INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| 22 // ---------------------------NORMAL COMPONENT------------------------------- | |
| 20 // Timestamp when the scroll update gesture event is sent from RWH to | 23 // Timestamp when the scroll update gesture event is sent from RWH to |
| 21 // renderer. In Aura, touch event's LatencyInfo is carried over to the gesture | 24 // renderer. In Aura, touch event's LatencyInfo is carried over to the gesture |
| 22 // event. So gesture event's INPUT_EVENT_LATENCY_RWH_COMPONENT is the | 25 // event. So gesture event's INPUT_EVENT_LATENCY_RWH_COMPONENT is the |
| 23 // timestamp when its original touch events is sent from RWH to renderer. | 26 // timestamp when its original touch events is sent from RWH to renderer. |
| 24 // In non-aura platform, INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT | 27 // In non-aura platform, INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT |
| 25 // is the same as INPUT_EVENT_LATENCY_RWH_COMPONENT. | 28 // is the same as INPUT_EVENT_LATENCY_RWH_COMPONENT. |
| 26 INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT, | 29 INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT, |
| 27 // The original timestamp of the touch event which converts to scroll update. | 30 // The original timestamp of the touch event which converts to scroll update. |
| 28 INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 31 INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| 29 // Original timestamp for input event (e.g. timestamp from kernel). | 32 // Original timestamp for input event (e.g. timestamp from kernel). |
| 30 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, | 33 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, |
| 31 // Timestamp when the UI event is created. | 34 // Timestamp when the UI event is created. |
| 32 INPUT_EVENT_LATENCY_UI_COMPONENT, | 35 INPUT_EVENT_LATENCY_UI_COMPONENT, |
| 33 // Timestamp when the event is acked from renderer. This is currently set | 36 // This is special component indicating there is rendering scheduled for |
| 34 // only for touch events. | 37 // the event associated with this LatencyInfo. |
| 35 INPUT_EVENT_LATENCY_ACKED_COMPONENT | 38 INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, |
| 39 // Timestamp when the touch event is acked. | |
| 40 INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT, | |
| 41 // ---------------------------TERMINAL COMPONENT----------------------------- | |
| 42 // TERMINAL COMPONENT is when we show the latency end in chrome://tracing. | |
| 43 // Timestamp when the mouse event is acked from renderer and it does not | |
| 44 // cause any rendering scheduled. | |
| 45 INPUT_EVENT_LATENCY_TERMINATED_MOUSE_COMPONENT, | |
| 46 // Timestamp when the touch event is acked from renderer and it does not | |
| 47 // cause any rendering schedueld and does not generate any gesture event. | |
| 48 INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, | |
| 49 // Timestamp when the gesture event is acked from renderer, and it does not | |
| 50 // cause any rendering schedueld. | |
| 51 INPUT_EVENT_LATENCY_TERMINATED_GESTURE_COMPONENT, | |
| 52 // Timestamp when the frame is swapped (i.e. when the rendering caused by | |
| 53 // input event actually takes effect). | |
| 54 INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT, | |
| 36 }; | 55 }; |
| 37 | 56 |
| 38 struct EVENTS_EXPORT LatencyInfo { | 57 struct EVENTS_EXPORT LatencyInfo { |
| 39 struct LatencyComponent { | 58 struct LatencyComponent { |
| 40 // Nondecreasing number that can be used to determine what events happened | 59 // Nondecreasing number that can be used to determine what events happened |
| 41 // in the component at the time this struct was sent on to the next | 60 // in the component at the time this struct was sent on to the next |
| 42 // component. | 61 // component. |
| 43 int64 sequence_number; | 62 int64 sequence_number; |
| 44 // Average time of events that happened in this component. | 63 // Average time of events that happened in this component. |
| 45 base::TimeTicks event_time; | 64 base::TimeTicks event_time; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 67 void AddLatencyNumber(LatencyComponentType component, | 86 void AddLatencyNumber(LatencyComponentType component, |
| 68 int64 id, | 87 int64 id, |
| 69 int64 component_sequence_number); | 88 int64 component_sequence_number); |
| 70 | 89 |
| 71 // Modifies the current sequence number and adds a certain number of events | 90 // Modifies the current sequence number and adds a certain number of events |
| 72 // for a specific component. | 91 // for a specific component. |
| 73 void AddLatencyNumberWithTimestamp(LatencyComponentType component, | 92 void AddLatencyNumberWithTimestamp(LatencyComponentType component, |
| 74 int64 id, | 93 int64 id, |
| 75 int64 component_sequence_number, | 94 int64 component_sequence_number, |
| 76 base::TimeTicks time, | 95 base::TimeTicks time, |
| 77 uint32 event_count); | 96 uint32 event_count, |
| 97 bool dump_to_trace); | |
|
sadrul
2013/10/10 21:58:38
Adding a boolean param like this in a public API i
Yufeng Shen (Slow to review)
2013/10/10 22:52:15
Yes. I am planning to remove the MergeWith() funct
| |
| 78 | 98 |
| 79 // Returns true if the a component with |type| and |id| is found in | 99 // Returns true if the a component with |type| and |id| is found in |
| 80 // the latency_components and the component is stored to |output| if | 100 // the latency_components and the component is stored to |output| if |
| 81 // |output| is not NULL. Returns false if no such component is found. | 101 // |output| is not NULL. Returns false if no such component is found. |
| 82 bool FindLatency(LatencyComponentType type, | 102 bool FindLatency(LatencyComponentType type, |
| 83 int64 id, | 103 int64 id, |
| 84 LatencyComponent* output) const; | 104 LatencyComponent* output) const; |
| 85 | 105 |
| 86 void Clear(); | 106 void Clear(); |
| 87 | 107 |
| 88 LatencyMap latency_components; | 108 LatencyMap latency_components; |
| 89 | 109 // The unique id for matching the ASYNC_BEGIN/END trace event. |
| 90 // This represents the final time that a frame is displayed it. | 110 int64 trace_id; |
| 91 base::TimeTicks swap_timestamp; | 111 // Whether a terminal component has been added. |
| 112 bool terminated; | |
| 92 }; | 113 }; |
| 93 | 114 |
| 94 } // namespace ui | 115 } // namespace ui |
| 95 | 116 |
| 96 #endif // UI_EVENTS_LATENCY_INFO_H_ | 117 #endif // UI_EVENTS_LATENCY_INFO_H_ |
| OLD | NEW |