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/debug/trace_event.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 13 #include "ui/events/events_export.h" | 15 #include "ui/events/events_export.h" |
| 14 | 16 |
| 15 namespace ui { | 17 namespace ui { |
| 16 | 18 |
| 19 // This class is for converting latency info to trace buffer friendly format. | |
| 20 class LatencyInfoTracedValue : public base::debug::ConvertableToTraceFormat { | |
|
nduca
2013/10/01 21:43:44
i think you can put this implementation in the cc
Yufeng Shen (Slow to review)
2013/10/04 00:29:51
Done.
| |
| 21 public: | |
| 22 static scoped_ptr<ConvertableToTraceFormat> FromValue( | |
| 23 base::Value* value); | |
| 24 | |
| 25 virtual ~LatencyInfoTracedValue(); | |
| 26 | |
| 27 virtual void AppendAsTraceFormat(std::string* out) const OVERRIDE; | |
| 28 | |
| 29 private: | |
| 30 explicit LatencyInfoTracedValue(base::Value* value); | |
| 31 | |
| 32 scoped_ptr<base::Value> value_; | |
| 33 | |
| 34 DISALLOW_COPY_AND_ASSIGN(LatencyInfoTracedValue); | |
| 35 }; | |
| 36 | |
| 17 enum LatencyComponentType { | 37 enum LatencyComponentType { |
| 18 // Timestamp when the input event is sent from RenderWidgetHost to renderer. | 38 // Timestamp when the input event is sent from RenderWidgetHost to renderer. |
| 19 INPUT_EVENT_LATENCY_RWH_COMPONENT, | 39 INPUT_EVENT_LATENCY_RWH_COMPONENT, |
|
nduca
2013/10/01 21:43:44
lets prefix this with a name to indicate that it b
Yufeng Shen (Slow to review)
2013/10/04 00:29:51
Done.
| |
| 20 // Timestamp when the scroll update gesture event is sent from RWH to | 40 // 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 | 41 // 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 | 42 // 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. | 43 // timestamp when its original touch events is sent from RWH to renderer. |
| 24 // In non-aura platform, INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT | 44 // In non-aura platform, INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT |
| 25 // is the same as INPUT_EVENT_LATENCY_RWH_COMPONENT. | 45 // is the same as INPUT_EVENT_LATENCY_RWH_COMPONENT. |
| 26 INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT, | 46 INPUT_EVENT_LATENCY_SCROLL_UPDATE_RWH_COMPONENT, |
| 27 // The original timestamp of the touch event which converts to scroll update. | 47 // The original timestamp of the touch event which converts to scroll update. |
| 28 INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, | 48 INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT, |
| 29 // Original timestamp for input event (e.g. timestamp from kernel). | 49 // Original timestamp for input event (e.g. timestamp from kernel). |
| 30 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, | 50 INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, |
| 31 // Timestamp when the UI event is created. | 51 // Timestamp when the UI event is created. |
| 32 INPUT_EVENT_LATENCY_UI_COMPONENT, | 52 INPUT_EVENT_LATENCY_UI_COMPONENT, |
| 33 // Timestamp when the event is acked from renderer. This is currently set | 53 // Timestamp when the mouse event is acked from renderer. |
| 34 // only for touch events. | 54 INPUT_EVENT_LATENCY_ACKED_MOUSE_COMPONENT, |
|
nduca
2013/10/01 21:43:44
lets try calling these FINISH_ or TERMINAL ... lat
Rick Byers
2013/10/03 13:12:41
Is the idea that these will always be terminal? W
Yufeng Shen (Slow to review)
2013/10/04 00:29:51
Done.
Yufeng Shen (Slow to review)
2013/10/04 00:29:51
As offline talk, we will only allow one terminal c
| |
| 35 INPUT_EVENT_LATENCY_ACKED_COMPONENT | 55 // Timestamp when the touch event is acked from renderer. |
| 56 INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT, | |
| 57 // Timestamp when the gesture event is acked from renderer. | |
| 58 INPUT_EVENT_LATENCY_ACKED_GESTURE_COMPONENT, | |
| 59 // Timestamp when the frame is swapped. | |
| 60 INPUT_EVENT_LATENCY_FRAME_SWAP_COMPONENT, | |
| 36 }; | 61 }; |
| 37 | 62 |
| 38 struct EVENTS_EXPORT LatencyInfo { | 63 struct EVENTS_EXPORT LatencyInfo { |
| 39 struct LatencyComponent { | 64 struct LatencyComponent { |
| 40 // Nondecreasing number that can be used to determine what events happened | 65 // 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 | 66 // in the component at the time this struct was sent on to the next |
| 42 // component. | 67 // component. |
| 43 int64 sequence_number; | 68 int64 sequence_number; |
| 44 // Average time of events that happened in this component. | 69 // Average time of events that happened in this component. |
| 45 base::TimeTicks event_time; | 70 base::TimeTicks event_time; |
| 46 // Count of events that happened in this component | 71 // Count of events that happened in this component |
| 47 uint32 event_count; | 72 uint32 event_count; |
| 48 }; | 73 }; |
| 49 | 74 |
| 50 // Map a Latency Component (with a component-specific int64 id) to a | 75 // Map a Latency Component (with a component-specific int64 id) to a |
| 51 // component info. | 76 // component info. |
| 52 typedef std::map<std::pair<LatencyComponentType, int64>, LatencyComponent> | 77 typedef std::map<std::pair<LatencyComponentType, int64>, LatencyComponent> |
| 53 LatencyMap; | 78 LatencyMap; |
| 54 | 79 |
| 55 LatencyInfo(); | 80 LatencyInfo(); |
| 56 | 81 |
| 57 ~LatencyInfo(); | 82 ~LatencyInfo(); |
| 58 | 83 |
| 84 // When the LatencyInfo is considered to have finished its lifetime, call | |
| 85 // this function. |terminal_component| is added to indicate when & why | |
| 86 // this function is called. And then the whole latency info is reported | |
| 87 // to system (i.e. dumped to trace buffer). | |
| 88 void Report(LatencyComponentType terminal_component); | |
| 89 scoped_ptr<base::debug::ConvertableToTraceFormat> AsTraceableData() const; | |
|
jdduke (slow)
2013/10/01 23:45:31
AsTraceableData() appears to be used only be Repor
Yufeng Shen (Slow to review)
2013/10/04 00:29:51
moved into cc file as a global function.
| |
| 90 | |
| 59 // Merges the contents of another LatencyInfo into this one. | 91 // Merges the contents of another LatencyInfo into this one. |
| 60 void MergeWith(const LatencyInfo& other); | 92 void MergeWith(const LatencyInfo& other); |
| 61 | 93 |
| 62 // Add LatencyComponents that are in |other| but not in |this|. | 94 // Add LatencyComponents that are in |other| but not in |this|. |
| 63 void AddNewLatencyFrom(const LatencyInfo& other); | 95 void AddNewLatencyFrom(const LatencyInfo& other); |
| 64 | 96 |
| 65 // Modifies the current sequence number for a component, and adds a new | 97 // Modifies the current sequence number for a component, and adds a new |
| 66 // sequence number with the current timestamp. | 98 // sequence number with the current timestamp. |
| 67 void AddLatencyNumber(LatencyComponentType component, | 99 void AddLatencyNumber(LatencyComponentType component, |
| 68 int64 id, | 100 int64 id, |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 79 // Returns true if the a component with |type| and |id| is found in | 111 // 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 | 112 // the latency_components and the component is stored to |output| if |
| 81 // |output| is not NULL. Returns false if no such component is found. | 113 // |output| is not NULL. Returns false if no such component is found. |
| 82 bool FindLatency(LatencyComponentType type, | 114 bool FindLatency(LatencyComponentType type, |
| 83 int64 id, | 115 int64 id, |
| 84 LatencyComponent* output) const; | 116 LatencyComponent* output) const; |
| 85 | 117 |
| 86 void Clear(); | 118 void Clear(); |
| 87 | 119 |
| 88 LatencyMap latency_components; | 120 LatencyMap latency_components; |
| 89 | |
| 90 // This represents the final time that a frame is displayed it. | |
| 91 base::TimeTicks swap_timestamp; | |
| 92 }; | 121 }; |
| 93 | 122 |
| 94 } // namespace ui | 123 } // namespace ui |
| 95 | 124 |
| 96 #endif // UI_EVENTS_LATENCY_INFO_H_ | 125 #endif // UI_EVENTS_LATENCY_INFO_H_ |
| OLD | NEW |