| 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_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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 LatencyComponent* output) const; | 195 LatencyComponent* output) const; |
| 196 | 196 |
| 197 // Returns true if a component with |type| is found in the latency component. | 197 // Returns true if a component with |type| is found in the latency component. |
| 198 // The first such component (when iterating over latency_components_) is | 198 // The first such component (when iterating over latency_components_) is |
| 199 // stored to |output| if |output| is not NULL. Returns false if no such | 199 // stored to |output| if |output| is not NULL. Returns false if no such |
| 200 // component is found. | 200 // component is found. |
| 201 bool FindLatency(LatencyComponentType type, LatencyComponent* output) const; | 201 bool FindLatency(LatencyComponentType type, LatencyComponent* output) const; |
| 202 | 202 |
| 203 void RemoveLatency(LatencyComponentType type); | 203 void RemoveLatency(LatencyComponentType type); |
| 204 | 204 |
| 205 // Returns true if there is still room for keeping the |input_coordinate|, | |
| 206 // false otherwise. | |
| 207 bool AddInputCoordinate(const gfx::PointF& input_coordinate); | |
| 208 | |
| 209 uint32_t input_coordinates_size() const { return input_coordinates_size_; } | |
| 210 const gfx::PointF* input_coordinates() const { return input_coordinates_; } | |
| 211 | |
| 212 const LatencyMap& latency_components() const { return latency_components_; } | 205 const LatencyMap& latency_components() const { return latency_components_; } |
| 213 | 206 |
| 214 const SourceEventType& source_event_type() const { | 207 const SourceEventType& source_event_type() const { |
| 215 return source_event_type_; | 208 return source_event_type_; |
| 216 } | 209 } |
| 217 void set_source_event_type(SourceEventType type) { | 210 void set_source_event_type(SourceEventType type) { |
| 218 source_event_type_ = type; | 211 source_event_type_ = type; |
| 219 } | 212 } |
| 220 | 213 |
| 221 bool terminated() const { return terminated_; } | 214 bool terminated() const { return terminated_; } |
| 222 void set_coalesced() { coalesced_ = true; } | 215 void set_coalesced() { coalesced_ = true; } |
| 223 bool coalesced() const { return coalesced_; } | 216 bool coalesced() const { return coalesced_; } |
| 224 int64_t trace_id() const { return trace_id_; } | 217 int64_t trace_id() const { return trace_id_; } |
| 225 | 218 |
| 226 private: | 219 private: |
| 227 void AddLatencyNumberWithTimestampImpl(LatencyComponentType component, | 220 void AddLatencyNumberWithTimestampImpl(LatencyComponentType component, |
| 228 int64_t id, | 221 int64_t id, |
| 229 int64_t component_sequence_number, | 222 int64_t component_sequence_number, |
| 230 base::TimeTicks time, | 223 base::TimeTicks time, |
| 231 uint32_t event_count, | 224 uint32_t event_count, |
| 232 const char* trace_name_str); | 225 const char* trace_name_str); |
| 233 | 226 |
| 234 // Converts latencyinfo into format that can be dumped into trace buffer. | 227 // Converts latencyinfo into format that can be dumped into trace buffer. |
| 235 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | 228 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> |
| 236 AsTraceableData(); | 229 AsTraceableData(); |
| 237 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> | |
| 238 CoordinatesAsTraceableData(); | |
| 239 | 230 |
| 240 // 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. |
| 241 // String is empty if no tracing is enabled. | 232 // String is empty if no tracing is enabled. |
| 242 std::string trace_name_; | 233 std::string trace_name_; |
| 243 | 234 |
| 244 LatencyMap latency_components_; | 235 LatencyMap latency_components_; |
| 245 | 236 |
| 246 // These coordinates represent window coordinates of the original input event. | |
| 247 uint32_t input_coordinates_size_; | |
| 248 gfx::PointF input_coordinates_[kMaxInputCoordinates]; | |
| 249 | |
| 250 // The unique id for matching the ASYNC_BEGIN/END trace event. | 237 // The unique id for matching the ASYNC_BEGIN/END trace event. |
| 251 int64_t trace_id_; | 238 int64_t trace_id_; |
| 252 // Whether this event has been coalesced into another event. | 239 // Whether this event has been coalesced into another event. |
| 253 bool coalesced_; | 240 bool coalesced_; |
| 254 // Whether a terminal component has been added. | 241 // Whether a terminal component has been added. |
| 255 bool terminated_; | 242 bool terminated_; |
| 256 // Stores the type of the first source event. | 243 // Stores the type of the first source event. |
| 257 SourceEventType source_event_type_; | 244 SourceEventType source_event_type_; |
| 258 | 245 |
| 259 #if !defined(OS_IOS) | 246 #if !defined(OS_IOS) |
| 260 friend struct IPC::ParamTraits<ui::LatencyInfo>; | 247 friend struct IPC::ParamTraits<ui::LatencyInfo>; |
| 261 friend struct mojo::StructTraits<ui::mojom::LatencyInfoDataView, | 248 friend struct mojo::StructTraits<ui::mojom::LatencyInfoDataView, |
| 262 ui::LatencyInfo>; | 249 ui::LatencyInfo>; |
| 263 #endif | 250 #endif |
| 264 }; | 251 }; |
| 265 | 252 |
| 266 // This is declared here for use in gtest-based unit tests, but is defined in | 253 // This is declared here for use in gtest-based unit tests, but is defined in |
| 267 // //ui/latency:test_support target. | 254 // //ui/latency:test_support target. |
| 268 // Without this the default PrintTo template in gtest tries to pass LatencyInfo | 255 // Without this the default PrintTo template in gtest tries to pass LatencyInfo |
| 269 // by value, which leads to an alignment compile error on Windows. | 256 // by value, which leads to an alignment compile error on Windows. |
| 270 void PrintTo(const LatencyInfo& latency, ::std::ostream* os); | 257 void PrintTo(const LatencyInfo& latency, ::std::ostream* os); |
| 271 | 258 |
| 272 } // namespace ui | 259 } // namespace ui |
| 273 | 260 |
| 274 #endif // UI_LATENCY_LATENCY_INFO_H_ | 261 #endif // UI_LATENCY_LATENCY_INFO_H_ |
| OLD | NEW |