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 <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/containers/small_map.h" | 14 #include "base/containers/small_map.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // This component indicates that the input causes a commit to be scheduled | 90 // This component indicates that the input causes a commit to be scheduled |
91 // but the commit failed. | 91 // but the commit failed. |
92 INPUT_EVENT_LATENCY_TERMINATED_COMMIT_FAILED_COMPONENT, | 92 INPUT_EVENT_LATENCY_TERMINATED_COMMIT_FAILED_COMPONENT, |
93 // This component indicates that the input causes a commit to be scheduled | 93 // This component indicates that the input causes a commit to be scheduled |
94 // but the commit was aborted since it carried no new information. | 94 // but the commit was aborted since it carried no new information. |
95 INPUT_EVENT_LATENCY_TERMINATED_COMMIT_NO_UPDATE_COMPONENT, | 95 INPUT_EVENT_LATENCY_TERMINATED_COMMIT_NO_UPDATE_COMPONENT, |
96 // This component indicates that the input causes a swap to be scheduled | 96 // This component indicates that the input causes a swap to be scheduled |
97 // but the swap failed. | 97 // but the swap failed. |
98 INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT, | 98 INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT, |
99 LATENCY_COMPONENT_TYPE_LAST = | 99 LATENCY_COMPONENT_TYPE_LAST = |
100 INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT, | 100 INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT, |
101 }; | 101 }; |
102 | 102 |
103 class EVENTS_BASE_EXPORT LatencyInfo { | 103 class LATENCY_INFO_EXPORT LatencyInfo { |
104 public: | 104 public: |
105 struct LatencyComponent { | 105 struct LatencyComponent { |
106 // Nondecreasing number that can be used to determine what events happened | 106 // Nondecreasing number that can be used to determine what events happened |
107 // in the component at the time this struct was sent on to the next | 107 // in the component at the time this struct was sent on to the next |
108 // component. | 108 // component. |
109 int64_t sequence_number; | 109 int64_t sequence_number; |
110 // Average time of events that happened in this component. | 110 // Average time of events that happened in this component. |
111 base::TimeTicks event_time; | 111 base::TimeTicks event_time; |
112 // Count of events that happened in this component | 112 // Count of events that happened in this component |
113 uint32_t event_count; | 113 uint32_t event_count; |
114 }; | 114 }; |
115 | 115 |
116 struct EVENTS_BASE_EXPORT InputCoordinate { | 116 struct LATENCY_INFO_EXPORT InputCoordinate { |
117 InputCoordinate(); | 117 InputCoordinate(); |
118 InputCoordinate(float x, float y); | 118 InputCoordinate(float x, float y); |
119 | 119 |
120 float x; | 120 float x; |
121 float y; | 121 float y; |
122 }; | 122 }; |
123 | 123 |
124 // Empirically determined constant based on a typical scroll sequence. | 124 // Empirically determined constant based on a typical scroll sequence. |
125 enum { kTypicalMaxComponentsPerLatencyInfo = 10 }; | 125 enum { kTypicalMaxComponentsPerLatencyInfo = 10 }; |
126 | 126 |
127 enum { kMaxInputCoordinates = 2 }; | 127 enum { kMaxInputCoordinates = 2 }; |
128 | 128 |
129 // Map a Latency Component (with a component-specific int64_t id) to a | 129 // Map a Latency Component (with a component-specific int64_t id) to a |
130 // component info. | 130 // component info. |
131 typedef base::SmallMap< | 131 typedef base::SmallMap< |
132 std::map<std::pair<LatencyComponentType, int64_t>, LatencyComponent>, | 132 std::map<std::pair<LatencyComponentType, int64_t>, LatencyComponent>, |
133 kTypicalMaxComponentsPerLatencyInfo> LatencyMap; | 133 kTypicalMaxComponentsPerLatencyInfo> |
| 134 LatencyMap; |
134 | 135 |
135 LatencyInfo(); | 136 LatencyInfo(); |
136 LatencyInfo(const LatencyInfo& other); | 137 LatencyInfo(const LatencyInfo& other); |
137 ~LatencyInfo(); | 138 ~LatencyInfo(); |
138 | 139 |
139 // For test only. | 140 // For test only. |
140 LatencyInfo(int64_t trace_id, bool terminated); | 141 LatencyInfo(int64_t trace_id, bool terminated); |
141 | 142 |
142 // Returns true if the vector |latency_info| is valid. Returns false | 143 // Returns true if the vector |latency_info| is valid. Returns false |
143 // if it is not valid and log the |referring_msg|. | 144 // if it is not valid and log the |referring_msg|. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // Whether a terminal component has been added. | 233 // Whether a terminal component has been added. |
233 bool terminated_; | 234 bool terminated_; |
234 | 235 |
235 #if !defined(OS_IOS) | 236 #if !defined(OS_IOS) |
236 friend struct IPC::ParamTraits<ui::LatencyInfo>; | 237 friend struct IPC::ParamTraits<ui::LatencyInfo>; |
237 #endif | 238 #endif |
238 }; | 239 }; |
239 | 240 |
240 } // namespace ui | 241 } // namespace ui |
241 | 242 |
242 #endif // UI_EVENTS_LATENCY_INFO_H_ | 243 #endif // UI_LATENCY_INFO_LATENCY_INFO_H_ |
OLD | NEW |