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 <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/containers/small_map.h" | 15 #include "base/containers/small_map.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
18 #include "ui/events/events_base_export.h" | 18 #include "ui/events/events_base_export.h" |
19 #include "ui/gfx/geometry/point_f.h" | |
20 | 19 |
21 #if !defined(OS_IOS) | 20 #if !defined(OS_IOS) |
22 #include "ipc/ipc_param_traits.h" // nogncheck | 21 #include "ipc/ipc_param_traits.h" // nogncheck |
23 #include "mojo/public/cpp/bindings/struct_traits.h" // nogncheck | 22 #include "mojo/public/cpp/bindings/struct_traits.h" // nogncheck |
24 #endif | 23 #endif |
25 | 24 |
26 namespace ui { | 25 namespace ui { |
27 | 26 |
28 #if !defined(OS_IOS) | 27 #if !defined(OS_IOS) |
29 namespace mojom { | 28 namespace mojom { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // Nondecreasing number that can be used to determine what events happened | 118 // Nondecreasing number that can be used to determine what events happened |
120 // in the component at the time this struct was sent on to the next | 119 // in the component at the time this struct was sent on to the next |
121 // component. | 120 // component. |
122 int64_t sequence_number; | 121 int64_t sequence_number; |
123 // Average time of events that happened in this component. | 122 // Average time of events that happened in this component. |
124 base::TimeTicks event_time; | 123 base::TimeTicks event_time; |
125 // Count of events that happened in this component | 124 // Count of events that happened in this component |
126 uint32_t event_count; | 125 uint32_t event_count; |
127 }; | 126 }; |
128 | 127 |
| 128 struct EVENTS_BASE_EXPORT InputCoordinate { |
| 129 InputCoordinate(); |
| 130 InputCoordinate(float x, float y); |
| 131 |
| 132 float x; |
| 133 float y; |
| 134 }; |
| 135 |
129 // Empirically determined constant based on a typical scroll sequence. | 136 // Empirically determined constant based on a typical scroll sequence. |
130 enum { kTypicalMaxComponentsPerLatencyInfo = 10 }; | 137 enum { kTypicalMaxComponentsPerLatencyInfo = 10 }; |
131 | 138 |
132 enum : size_t { kMaxInputCoordinates = 2 }; | 139 enum : size_t { kMaxInputCoordinates = 2 }; |
133 | 140 |
134 // Map a Latency Component (with a component-specific int64_t id) to a | 141 // Map a Latency Component (with a component-specific int64_t id) to a |
135 // component info. | 142 // component info. |
136 typedef base::SmallMap< | 143 typedef base::SmallMap< |
137 std::map<std::pair<LatencyComponentType, int64_t>, LatencyComponent>, | 144 std::map<std::pair<LatencyComponentType, int64_t>, LatencyComponent>, |
138 kTypicalMaxComponentsPerLatencyInfo> LatencyMap; | 145 kTypicalMaxComponentsPerLatencyInfo> LatencyMap; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // the latency_components and the component is stored to |output| if | 193 // the latency_components and the component is stored to |output| if |
187 // |output| is not NULL. Returns false if no such component is found. | 194 // |output| is not NULL. Returns false if no such component is found. |
188 bool FindLatency(LatencyComponentType type, | 195 bool FindLatency(LatencyComponentType type, |
189 int64_t id, | 196 int64_t id, |
190 LatencyComponent* output) const; | 197 LatencyComponent* output) const; |
191 | 198 |
192 void RemoveLatency(LatencyComponentType type); | 199 void RemoveLatency(LatencyComponentType type); |
193 | 200 |
194 // Returns true if there is still room for keeping the |input_coordinate|, | 201 // Returns true if there is still room for keeping the |input_coordinate|, |
195 // false otherwise. | 202 // false otherwise. |
196 bool AddInputCoordinate(const gfx::PointF& input_coordinate); | 203 bool AddInputCoordinate(const InputCoordinate& input_coordinate); |
197 | 204 |
198 uint32_t input_coordinates_size() const { return input_coordinates_size_; } | 205 uint32_t input_coordinates_size() const { return input_coordinates_size_; } |
199 const gfx::PointF* input_coordinates() const { return input_coordinates_; } | 206 const InputCoordinate* input_coordinates() const { |
| 207 return input_coordinates_; |
| 208 } |
200 | 209 |
201 const LatencyMap& latency_components() const { return latency_components_; } | 210 const LatencyMap& latency_components() const { return latency_components_; } |
202 | 211 |
203 bool terminated() const { return terminated_; } | 212 bool terminated() const { return terminated_; } |
204 void set_coalesced() { coalesced_ = true; } | 213 void set_coalesced() { coalesced_ = true; } |
205 bool coalesced() const { return coalesced_; } | 214 bool coalesced() const { return coalesced_; } |
206 int64_t trace_id() const { return trace_id_; } | 215 int64_t trace_id() const { return trace_id_; } |
207 | 216 |
208 private: | 217 private: |
209 void AddLatencyNumberWithTimestampImpl(LatencyComponentType component, | 218 void AddLatencyNumberWithTimestampImpl(LatencyComponentType component, |
(...skipping 10 matching lines...) Expand all Loading... |
220 CoordinatesAsTraceableData(); | 229 CoordinatesAsTraceableData(); |
221 | 230 |
222 // Shown as part of the name of the trace event for this LatencyInfo. | 231 // Shown as part of the name of the trace event for this LatencyInfo. |
223 // String is empty if no tracing is enabled. | 232 // String is empty if no tracing is enabled. |
224 std::string trace_name_; | 233 std::string trace_name_; |
225 | 234 |
226 LatencyMap latency_components_; | 235 LatencyMap latency_components_; |
227 | 236 |
228 // These coordinates represent window coordinates of the original input event. | 237 // These coordinates represent window coordinates of the original input event. |
229 uint32_t input_coordinates_size_; | 238 uint32_t input_coordinates_size_; |
230 gfx::PointF input_coordinates_[kMaxInputCoordinates]; | 239 InputCoordinate input_coordinates_[kMaxInputCoordinates]; |
231 | 240 |
232 // The unique id for matching the ASYNC_BEGIN/END trace event. | 241 // The unique id for matching the ASYNC_BEGIN/END trace event. |
233 int64_t trace_id_; | 242 int64_t trace_id_; |
234 // Whether this event has been coalesced into another event. | 243 // Whether this event has been coalesced into another event. |
235 bool coalesced_; | 244 bool coalesced_; |
236 // Whether a terminal component has been added. | 245 // Whether a terminal component has been added. |
237 bool terminated_; | 246 bool terminated_; |
238 | 247 |
239 #if !defined(OS_IOS) | 248 #if !defined(OS_IOS) |
240 friend struct IPC::ParamTraits<ui::LatencyInfo>; | 249 friend struct IPC::ParamTraits<ui::LatencyInfo>; |
241 friend struct mojo::StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>; | 250 friend struct mojo::StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>; |
242 #endif | 251 #endif |
243 }; | 252 }; |
244 | 253 |
245 } // namespace ui | 254 } // namespace ui |
246 | 255 |
247 #endif // UI_EVENTS_LATENCY_INFO_H_ | 256 #endif // UI_EVENTS_LATENCY_INFO_H_ |
OLD | NEW |