Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1614)

Side by Side Diff: ui/latency/latency_info.h

Issue 2914023002: Remove LatencyInfo::sequence_number. (May break metrics).
Patch Set: Fix Windows. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_LATENCY_LATENCY_INFO_H_ 5 #ifndef UI_LATENCY_LATENCY_INFO_H_
6 #define UI_LATENCY_LATENCY_INFO_H_ 6 #define UI_LATENCY_LATENCY_INFO_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 WHEEL, 110 WHEEL,
111 TOUCH, 111 TOUCH,
112 KEY_PRESS, 112 KEY_PRESS,
113 OTHER, 113 OTHER,
114 SOURCE_EVENT_TYPE_LAST = OTHER, 114 SOURCE_EVENT_TYPE_LAST = OTHER,
115 }; 115 };
116 116
117 class LatencyInfo { 117 class LatencyInfo {
118 public: 118 public:
119 struct LatencyComponent { 119 struct LatencyComponent {
120 // Nondecreasing number that can be used to determine what events happened
121 // in the component at the time this struct was sent on to the next
122 // component.
123 int64_t sequence_number;
124 // Average time of events that happened in this component. 120 // Average time of events that happened in this component.
125 base::TimeTicks event_time; 121 base::TimeTicks event_time;
126 // Count of events that happened in this component 122 // Count of events that happened in this component
127 uint32_t event_count; 123 uint32_t event_count;
128 // Time of the oldest event that happened in this component. 124 // Time of the oldest event that happened in this component.
129 base::TimeTicks first_event_time; 125 base::TimeTicks first_event_time;
130 // Time of the most recent event that happened in this component. 126 // Time of the most recent event that happened in this component.
131 base::TimeTicks last_event_time; 127 base::TimeTicks last_event_time;
132 }; 128 };
133 129
134 enum : size_t { kMaxInputCoordinates = 2 };
135
136 // Map a Latency Component (with a component-specific int64_t id) to a 130 // Map a Latency Component (with a component-specific int64_t id) to a
137 // component info. 131 // component info.
138 using LatencyMap = base::flat_map<std::pair<LatencyComponentType, int64_t>, 132 using LatencyMap = base::flat_map<std::pair<LatencyComponentType, int64_t>,
139 LatencyComponent>; 133 LatencyComponent>;
140 134
141 LatencyInfo(); 135 LatencyInfo();
142 LatencyInfo(const LatencyInfo& other); 136 LatencyInfo(const LatencyInfo& other);
143 LatencyInfo(SourceEventType type); 137 LatencyInfo(SourceEventType type);
144 ~LatencyInfo(); 138 ~LatencyInfo();
145 139
(...skipping 11 matching lines...) Expand all
157 const char* referring_msg); 151 const char* referring_msg);
158 152
159 // Copy LatencyComponents with type |type| from |other| into |this|. 153 // Copy LatencyComponents with type |type| from |other| into |this|.
160 void CopyLatencyFrom(const LatencyInfo& other, LatencyComponentType type); 154 void CopyLatencyFrom(const LatencyInfo& other, LatencyComponentType type);
161 155
162 // Add LatencyComponents that are in |other| but not in |this|. 156 // Add LatencyComponents that are in |other| but not in |this|.
163 void AddNewLatencyFrom(const LatencyInfo& other); 157 void AddNewLatencyFrom(const LatencyInfo& other);
164 158
165 // Modifies the current sequence number for a component, and adds a new 159 // Modifies the current sequence number for a component, and adds a new
166 // sequence number with the current timestamp. 160 // sequence number with the current timestamp.
167 void AddLatencyNumber(LatencyComponentType component, 161 void AddLatencyNumber(LatencyComponentType component, int64_t id);
168 int64_t id,
169 int64_t component_sequence_number);
170 162
171 // Similar to |AddLatencyNumber|, and also appends |trace_name_str| to 163 // Similar to |AddLatencyNumber|, and also appends |trace_name_str| to
172 // the trace event's name. 164 // the trace event's name.
173 // This function should only be called when adding a BEGIN component. 165 // This function should only be called when adding a BEGIN component.
174 void AddLatencyNumberWithTraceName(LatencyComponentType component, 166 void AddLatencyNumberWithTraceName(LatencyComponentType component,
175 int64_t id, 167 int64_t id,
176 int64_t component_sequence_number,
177 const char* trace_name_str); 168 const char* trace_name_str);
178 169
179 // Modifies the current sequence number and adds a certain number of events 170 // Modifies the current sequence number and adds a certain number of events
180 // for a specific component. 171 // for a specific component.
181 void AddLatencyNumberWithTimestamp(LatencyComponentType component, 172 void AddLatencyNumberWithTimestamp(LatencyComponentType component,
182 int64_t id, 173 int64_t id,
183 int64_t component_sequence_number,
184 base::TimeTicks time, 174 base::TimeTicks time,
185 uint32_t event_count); 175 uint32_t event_count);
186 176
187 // Returns true if the a component with |type| and |id| is found in 177 // Returns true if the a component with |type| and |id| is found in
188 // the latency_components and the component is stored to |output| if 178 // the latency_components and the component is stored to |output| if
189 // |output| is not NULL. Returns false if no such component is found. 179 // |output| is not NULL. Returns false if no such component is found.
190 bool FindLatency(LatencyComponentType type, 180 bool FindLatency(LatencyComponentType type,
191 int64_t id, 181 int64_t id,
192 LatencyComponent* output) const; 182 LatencyComponent* output) const;
193 183
(...skipping 15 matching lines...) Expand all
209 } 199 }
210 200
211 bool terminated() const { return terminated_; } 201 bool terminated() const { return terminated_; }
212 void set_coalesced() { coalesced_ = true; } 202 void set_coalesced() { coalesced_ = true; }
213 bool coalesced() const { return coalesced_; } 203 bool coalesced() const { return coalesced_; }
214 int64_t trace_id() const { return trace_id_; } 204 int64_t trace_id() const { return trace_id_; }
215 205
216 private: 206 private:
217 void AddLatencyNumberWithTimestampImpl(LatencyComponentType component, 207 void AddLatencyNumberWithTimestampImpl(LatencyComponentType component,
218 int64_t id, 208 int64_t id,
219 int64_t component_sequence_number,
220 base::TimeTicks time, 209 base::TimeTicks time,
221 uint32_t event_count, 210 uint32_t event_count,
222 const char* trace_name_str); 211 const char* trace_name_str);
223 212
224 // Converts latencyinfo into format that can be dumped into trace buffer. 213 // Converts latencyinfo into format that can be dumped into trace buffer.
225 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 214 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
226 AsTraceableData(); 215 AsTraceableData();
227 216
228 // Shown as part of the name of the trace event for this LatencyInfo. 217 // Shown as part of the name of the trace event for this LatencyInfo.
229 // String is empty if no tracing is enabled. 218 // String is empty if no tracing is enabled.
(...skipping 19 matching lines...) Expand all
249 238
250 // This is declared here for use in gtest-based unit tests, but is defined in 239 // This is declared here for use in gtest-based unit tests, but is defined in
251 // //ui/latency:test_support target. 240 // //ui/latency:test_support target.
252 // Without this the default PrintTo template in gtest tries to pass LatencyInfo 241 // Without this the default PrintTo template in gtest tries to pass LatencyInfo
253 // by value, which leads to an alignment compile error on Windows. 242 // by value, which leads to an alignment compile error on Windows.
254 void PrintTo(const LatencyInfo& latency, ::std::ostream* os); 243 void PrintTo(const LatencyInfo& latency, ::std::ostream* os);
255 244
256 } // namespace ui 245 } // namespace ui
257 246
258 #endif // UI_LATENCY_LATENCY_INFO_H_ 247 #endif // UI_LATENCY_LATENCY_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698