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_LATENCY_INFO_LATENCY_INFO_H_ |
6 #define UI_EVENTS_LATENCY_INFO_H_ | 6 #define UI_LATENCY_INFO_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/latency_info/latency_info_export.h" |
19 | 19 |
20 #if !defined(OS_IOS) | 20 #if !defined(OS_IOS) |
21 #include "ipc/ipc_param_traits.h" // nogncheck | 21 #include "ipc/ipc_param_traits.h" // nogncheck |
22 #endif | 22 #endif |
23 | 23 |
24 namespace ui { | 24 namespace ui { |
25 | 25 |
26 // When adding new components, or new metrics based on LatencyInfo, | 26 // When adding new components, or new metrics based on LatencyInfo, |
27 // please update latency_info.dot. | 27 // please update latency_info.dot. |
28 enum LatencyComponentType { | 28 enum LatencyComponentType { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // This component indicates that the input causes a commit to be scheduled | 98 // This component indicates that the input causes a commit to be scheduled |
99 // but the commit was aborted since it carried no new information. | 99 // but the commit was aborted since it carried no new information. |
100 INPUT_EVENT_LATENCY_TERMINATED_COMMIT_NO_UPDATE_COMPONENT, | 100 INPUT_EVENT_LATENCY_TERMINATED_COMMIT_NO_UPDATE_COMPONENT, |
101 // This component indicates that the input causes a swap to be scheduled | 101 // This component indicates that the input causes a swap to be scheduled |
102 // but the swap failed. | 102 // but the swap failed. |
103 INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT, | 103 INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT, |
104 LATENCY_COMPONENT_TYPE_LAST = | 104 LATENCY_COMPONENT_TYPE_LAST = |
105 INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT, | 105 INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT, |
106 }; | 106 }; |
107 | 107 |
108 class EVENTS_BASE_EXPORT LatencyInfo { | 108 class LATENCY_INFO_EXPORT LatencyInfo { |
109 public: | 109 public: |
110 struct LatencyComponent { | 110 struct LatencyComponent { |
111 // Nondecreasing number that can be used to determine what events happened | 111 // Nondecreasing number that can be used to determine what events happened |
112 // in the component at the time this struct was sent on to the next | 112 // in the component at the time this struct was sent on to the next |
113 // component. | 113 // component. |
114 int64_t sequence_number; | 114 int64_t sequence_number; |
115 // Average time of events that happened in this component. | 115 // Average time of events that happened in this component. |
116 base::TimeTicks event_time; | 116 base::TimeTicks event_time; |
117 // Count of events that happened in this component | 117 // Count of events that happened in this component |
118 uint32_t event_count; | 118 uint32_t event_count; |
119 }; | 119 }; |
120 | 120 |
121 struct EVENTS_BASE_EXPORT InputCoordinate { | 121 struct LATENCY_INFO_EXPORT InputCoordinate { |
122 InputCoordinate(); | 122 InputCoordinate(); |
123 InputCoordinate(float x, float y); | 123 InputCoordinate(float x, float y); |
124 | 124 |
125 float x; | 125 float x; |
126 float y; | 126 float y; |
127 }; | 127 }; |
128 | 128 |
129 // Empirically determined constant based on a typical scroll sequence. | 129 // Empirically determined constant based on a typical scroll sequence. |
130 enum { kTypicalMaxComponentsPerLatencyInfo = 10 }; | 130 enum { kTypicalMaxComponentsPerLatencyInfo = 10 }; |
131 | 131 |
132 enum { kMaxInputCoordinates = 2 }; | 132 enum { kMaxInputCoordinates = 2 }; |
133 | 133 |
134 // Map a Latency Component (with a component-specific int64_t id) to a | 134 // Map a Latency Component (with a component-specific int64_t id) to a |
135 // component info. | 135 // component info. |
136 typedef base::SmallMap< | 136 typedef base::SmallMap< |
137 std::map<std::pair<LatencyComponentType, int64_t>, LatencyComponent>, | 137 std::map<std::pair<LatencyComponentType, int64_t>, LatencyComponent>, |
138 kTypicalMaxComponentsPerLatencyInfo> LatencyMap; | 138 kTypicalMaxComponentsPerLatencyInfo> |
| 139 LatencyMap; |
139 | 140 |
140 LatencyInfo(); | 141 LatencyInfo(); |
141 LatencyInfo(const LatencyInfo& other); | 142 LatencyInfo(const LatencyInfo& other); |
142 ~LatencyInfo(); | 143 ~LatencyInfo(); |
143 | 144 |
144 // For test only. | 145 // For test only. |
145 LatencyInfo(int64_t trace_id, bool terminated); | 146 LatencyInfo(int64_t trace_id, bool terminated); |
146 | 147 |
147 // Returns true if the vector |latency_info| is valid. Returns false | 148 // Returns true if the vector |latency_info| is valid. Returns false |
148 // if it is not valid and log the |referring_msg|. | 149 // if it is not valid and log the |referring_msg|. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 // Whether a terminal component has been added. | 239 // Whether a terminal component has been added. |
239 bool terminated_; | 240 bool terminated_; |
240 | 241 |
241 #if !defined(OS_IOS) | 242 #if !defined(OS_IOS) |
242 friend struct IPC::ParamTraits<ui::LatencyInfo>; | 243 friend struct IPC::ParamTraits<ui::LatencyInfo>; |
243 #endif | 244 #endif |
244 }; | 245 }; |
245 | 246 |
246 } // namespace ui | 247 } // namespace ui |
247 | 248 |
248 #endif // UI_EVENTS_LATENCY_INFO_H_ | 249 #endif // UI_LATENCY_INFO_LATENCY_INFO_H_ |
OLD | NEW |