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

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

Issue 2317253005: SourceEventType added to LatencyInfo (Closed)
Patch Set: Changed the patch to only contain source event type plumbing. Created 4 years, 3 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_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>
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // This component indicates that the input causes a commit to be scheduled 111 // This component indicates that the input causes a commit to be scheduled
112 // but the commit was aborted since it carried no new information. 112 // but the commit was aborted since it carried no new information.
113 INPUT_EVENT_LATENCY_TERMINATED_COMMIT_NO_UPDATE_COMPONENT, 113 INPUT_EVENT_LATENCY_TERMINATED_COMMIT_NO_UPDATE_COMPONENT,
114 // This component indicates that the input causes a swap to be scheduled 114 // This component indicates that the input causes a swap to be scheduled
115 // but the swap failed. 115 // but the swap failed.
116 INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT, 116 INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT,
117 LATENCY_COMPONENT_TYPE_LAST = 117 LATENCY_COMPONENT_TYPE_LAST =
118 INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT, 118 INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT,
119 }; 119 };
120 120
121 enum SourceEventType {
122 UNKOWN,
123 WHEEL,
124 TOUCH,
125 OTHER,
126 SOURCE_EVENT_TYPE_LAST = OTHER,
127 };
128
121 class EVENTS_BASE_EXPORT LatencyInfo { 129 class EVENTS_BASE_EXPORT LatencyInfo {
122 public: 130 public:
123 struct LatencyComponent { 131 struct LatencyComponent {
124 // Nondecreasing number that can be used to determine what events happened 132 // Nondecreasing number that can be used to determine what events happened
125 // in the component at the time this struct was sent on to the next 133 // in the component at the time this struct was sent on to the next
126 // component. 134 // component.
127 int64_t sequence_number; 135 int64_t sequence_number;
128 // Average time of events that happened in this component. 136 // Average time of events that happened in this component.
129 base::TimeTicks event_time; 137 base::TimeTicks event_time;
130 // Count of events that happened in this component 138 // Count of events that happened in this component
131 uint32_t event_count; 139 uint32_t event_count;
132 }; 140 };
133 141
134 // Empirically determined constant based on a typical scroll sequence. 142 // Empirically determined constant based on a typical scroll sequence.
135 enum { kTypicalMaxComponentsPerLatencyInfo = 10 }; 143 enum { kTypicalMaxComponentsPerLatencyInfo = 10 };
136 144
137 enum : size_t { kMaxInputCoordinates = 2 }; 145 enum : size_t { kMaxInputCoordinates = 2 };
138 146
139 // Map a Latency Component (with a component-specific int64_t id) to a 147 // Map a Latency Component (with a component-specific int64_t id) to a
140 // component info. 148 // component info.
141 typedef base::SmallMap< 149 typedef base::SmallMap<
142 std::map<std::pair<LatencyComponentType, int64_t>, LatencyComponent>, 150 std::map<std::pair<LatencyComponentType, int64_t>, LatencyComponent>,
143 kTypicalMaxComponentsPerLatencyInfo> LatencyMap; 151 kTypicalMaxComponentsPerLatencyInfo> LatencyMap;
144 152
145 LatencyInfo(); 153 LatencyInfo();
146 LatencyInfo(const LatencyInfo& other); 154 LatencyInfo(const LatencyInfo& other);
155 LatencyInfo(SourceEventType type);
147 ~LatencyInfo(); 156 ~LatencyInfo();
148 157
149 // For test only. 158 // For test only.
150 LatencyInfo(int64_t trace_id, bool terminated); 159 LatencyInfo(int64_t trace_id, bool terminated);
151 160
152 // Returns true if the vector |latency_info| is valid. Returns false 161 // Returns true if the vector |latency_info| is valid. Returns false
153 // if it is not valid and log the |referring_msg|. 162 // if it is not valid and log the |referring_msg|.
154 // This function is mainly used to check the latency_info vector that 163 // This function is mainly used to check the latency_info vector that
155 // is passed between processes using IPC message has reasonable size 164 // is passed between processes using IPC message has reasonable size
156 // so that we are confident the IPC message is not corrupted/compromised. 165 // so that we are confident the IPC message is not corrupted/compromised.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 207
199 // Returns true if there is still room for keeping the |input_coordinate|, 208 // Returns true if there is still room for keeping the |input_coordinate|,
200 // false otherwise. 209 // false otherwise.
201 bool AddInputCoordinate(const gfx::PointF& input_coordinate); 210 bool AddInputCoordinate(const gfx::PointF& input_coordinate);
202 211
203 uint32_t input_coordinates_size() const { return input_coordinates_size_; } 212 uint32_t input_coordinates_size() const { return input_coordinates_size_; }
204 const gfx::PointF* input_coordinates() const { return input_coordinates_; } 213 const gfx::PointF* input_coordinates() const { return input_coordinates_; }
205 214
206 const LatencyMap& latency_components() const { return latency_components_; } 215 const LatencyMap& latency_components() const { return latency_components_; }
207 216
217 const SourceEventType& source_event_type() const {
218 return source_event_type_;
219 }
220 void set_source_event_type(SourceEventType type) {
221 source_event_type_ = type;
222 }
223
208 bool terminated() const { return terminated_; } 224 bool terminated() const { return terminated_; }
209 void set_coalesced() { coalesced_ = true; } 225 void set_coalesced() { coalesced_ = true; }
210 bool coalesced() const { return coalesced_; } 226 bool coalesced() const { return coalesced_; }
211 int64_t trace_id() const { return trace_id_; } 227 int64_t trace_id() const { return trace_id_; }
212 228
213 private: 229 private:
214 void AddLatencyNumberWithTimestampImpl(LatencyComponentType component, 230 void AddLatencyNumberWithTimestampImpl(LatencyComponentType component,
215 int64_t id, 231 int64_t id,
216 int64_t component_sequence_number, 232 int64_t component_sequence_number,
217 base::TimeTicks time, 233 base::TimeTicks time,
(...skipping 16 matching lines...) Expand all
234 uint32_t input_coordinates_size_; 250 uint32_t input_coordinates_size_;
235 gfx::PointF input_coordinates_[kMaxInputCoordinates]; 251 gfx::PointF input_coordinates_[kMaxInputCoordinates];
236 252
237 // The unique id for matching the ASYNC_BEGIN/END trace event. 253 // The unique id for matching the ASYNC_BEGIN/END trace event.
238 int64_t trace_id_; 254 int64_t trace_id_;
239 // Whether this event has been coalesced into another event. 255 // Whether this event has been coalesced into another event.
240 bool coalesced_; 256 bool coalesced_;
241 // Whether a terminal component has been added. 257 // Whether a terminal component has been added.
242 bool terminated_; 258 bool terminated_;
243 259
260 SourceEventType source_event_type_;
tdresser 2016/09/12 14:23:09 Add comment.
sahel 2016/09/12 17:02:26 Done.
261
244 #if !defined(OS_IOS) 262 #if !defined(OS_IOS)
245 friend struct IPC::ParamTraits<ui::LatencyInfo>; 263 friend struct IPC::ParamTraits<ui::LatencyInfo>;
246 friend struct mojo::StructTraits<ui::mojom::LatencyInfoDataView, 264 friend struct mojo::StructTraits<ui::mojom::LatencyInfoDataView,
247 ui::LatencyInfo>; 265 ui::LatencyInfo>;
248 #endif 266 #endif
249 }; 267 };
250 268
251 } // namespace ui 269 } // namespace ui
252 270
253 #endif // UI_EVENTS_LATENCY_INFO_H_ 271 #endif // UI_EVENTS_LATENCY_INFO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698