OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "ui/latency/mojo/latency_info_struct_traits.h" | 5 #include "ui/latency/mojo/latency_info_struct_traits.h" |
6 | 6 |
7 #include "ipc/ipc_message_utils.h" | 7 #include "ipc/ipc_message_utils.h" |
8 | 8 |
9 namespace mojo { | 9 namespace mojo { |
10 | 10 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 INPUT_EVENT_LATENCY_TERMINATED_COMMIT_NO_UPDATE_COMPONENT: | 145 INPUT_EVENT_LATENCY_TERMINATED_COMMIT_NO_UPDATE_COMPONENT: |
146 return ui::INPUT_EVENT_LATENCY_TERMINATED_COMMIT_NO_UPDATE_COMPONENT; | 146 return ui::INPUT_EVENT_LATENCY_TERMINATED_COMMIT_NO_UPDATE_COMPONENT; |
147 case ui::mojom::LatencyComponentType:: | 147 case ui::mojom::LatencyComponentType:: |
148 INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT: | 148 INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT: |
149 return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT; | 149 return ui::INPUT_EVENT_LATENCY_TERMINATED_SWAP_FAILED_COMPONENT; |
150 } | 150 } |
151 NOTREACHED(); | 151 NOTREACHED(); |
152 return ui::LATENCY_COMPONENT_TYPE_LAST; | 152 return ui::LATENCY_COMPONENT_TYPE_LAST; |
153 } | 153 } |
154 | 154 |
| 155 ui::mojom::SourceEventType UISourceEventTypeToMojo(ui::SourceEventType type) { |
| 156 switch (type) { |
| 157 case ui::UNKNOWN: |
| 158 return ui::mojom::SourceEventType::UNKNOWN; |
| 159 case ui::WHEEL: |
| 160 return ui::mojom::SourceEventType::WHEEL; |
| 161 case ui::TOUCH: |
| 162 return ui::mojom::SourceEventType::TOUCH; |
| 163 case ui::OTHER: |
| 164 return ui::mojom::SourceEventType::OTHER; |
| 165 } |
| 166 NOTREACHED(); |
| 167 return ui::mojom::SourceEventType::UNKNOWN; |
| 168 } |
| 169 |
| 170 ui::SourceEventType MojoSourceEventTypeToUI(ui::mojom::SourceEventType type) { |
| 171 switch (type) { |
| 172 case ui::mojom::SourceEventType::UNKNOWN: |
| 173 return ui::UNKNOWN; |
| 174 case ui::mojom::SourceEventType::WHEEL: |
| 175 return ui::WHEEL; |
| 176 case ui::mojom::SourceEventType::TOUCH: |
| 177 return ui::TOUCH; |
| 178 case ui::mojom::SourceEventType::OTHER: |
| 179 return ui::OTHER; |
| 180 } |
| 181 NOTREACHED(); |
| 182 return ui::SourceEventType::UNKNOWN; |
| 183 } |
| 184 |
155 } // namespace | 185 } // namespace |
156 | 186 |
157 // static | 187 // static |
158 int64_t StructTraits<ui::mojom::LatencyComponentDataView, | 188 int64_t StructTraits<ui::mojom::LatencyComponentDataView, |
159 ui::LatencyInfo::LatencyComponent>:: | 189 ui::LatencyInfo::LatencyComponent>:: |
160 sequence_number(const ui::LatencyInfo::LatencyComponent& component) { | 190 sequence_number(const ui::LatencyInfo::LatencyComponent& component) { |
161 return component.sequence_number; | 191 return component.sequence_number; |
162 } | 192 } |
163 | 193 |
164 // static | 194 // static |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 return true; | 260 return true; |
231 } | 261 } |
232 | 262 |
233 // static | 263 // static |
234 const std::string& | 264 const std::string& |
235 StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::trace_name( | 265 StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::trace_name( |
236 const ui::LatencyInfo& info) { | 266 const ui::LatencyInfo& info) { |
237 return info.trace_name_; | 267 return info.trace_name_; |
238 } | 268 } |
239 | 269 |
| 270 // static |
240 const ui::LatencyInfo::LatencyMap& | 271 const ui::LatencyInfo::LatencyMap& |
241 StructTraits<ui::mojom::LatencyInfoDataView, | 272 StructTraits<ui::mojom::LatencyInfoDataView, |
242 ui::LatencyInfo>::latency_components(const ui::LatencyInfo& info) { | 273 ui::LatencyInfo>::latency_components(const ui::LatencyInfo& info) { |
243 return info.latency_components(); | 274 return info.latency_components(); |
244 } | 275 } |
245 | 276 |
| 277 // static |
246 int64_t StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::trace_id( | 278 int64_t StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::trace_id( |
247 const ui::LatencyInfo& info) { | 279 const ui::LatencyInfo& info) { |
248 return info.trace_id(); | 280 return info.trace_id(); |
249 } | 281 } |
250 | 282 |
| 283 // static |
251 bool StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::coalesced( | 284 bool StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::coalesced( |
252 const ui::LatencyInfo& info) { | 285 const ui::LatencyInfo& info) { |
253 return info.coalesced(); | 286 return info.coalesced(); |
254 } | 287 } |
255 | 288 |
| 289 // static |
256 bool StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::terminated( | 290 bool StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::terminated( |
257 const ui::LatencyInfo& info) { | 291 const ui::LatencyInfo& info) { |
258 return info.terminated(); | 292 return info.terminated(); |
259 } | 293 } |
260 | 294 |
| 295 // static |
| 296 ui::mojom::SourceEventType |
| 297 StructTraits<ui::mojom::LatencyInfoDataView, |
| 298 ui::LatencyInfo>::source_event_type(const ui::LatencyInfo& info) { |
| 299 return UISourceEventTypeToMojo(info.source_event_type()); |
| 300 } |
| 301 |
| 302 // static |
261 bool StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::Read( | 303 bool StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::Read( |
262 ui::mojom::LatencyInfoDataView data, | 304 ui::mojom::LatencyInfoDataView data, |
263 ui::LatencyInfo* out) { | 305 ui::LatencyInfo* out) { |
264 if (!data.ReadTraceName(&out->trace_name_)) | 306 if (!data.ReadTraceName(&out->trace_name_)) |
265 return false; | 307 return false; |
266 | 308 |
267 mojo::ArrayDataView<ui::mojom::LatencyComponentPairDataView> components; | 309 mojo::ArrayDataView<ui::mojom::LatencyComponentPairDataView> components; |
268 data.GetLatencyComponentsDataView(&components); | 310 data.GetLatencyComponentsDataView(&components); |
269 for (uint32_t i = 0; i < components.size(); ++i) { | 311 for (uint32_t i = 0; i < components.size(); ++i) { |
270 ui::mojom::LatencyComponentPairDataView component_pair; | 312 ui::mojom::LatencyComponentPairDataView component_pair; |
271 components.GetDataView(i, &component_pair); | 313 components.GetDataView(i, &component_pair); |
272 ui::LatencyInfo::LatencyMap::key_type key; | 314 ui::LatencyInfo::LatencyMap::key_type key; |
273 if (!component_pair.ReadKey(&key)) | 315 if (!component_pair.ReadKey(&key)) |
274 return false; | 316 return false; |
275 auto& value = out->latency_components_[key]; | 317 auto& value = out->latency_components_[key]; |
276 if (!component_pair.ReadValue(&value)) | 318 if (!component_pair.ReadValue(&value)) |
277 return false; | 319 return false; |
278 } | 320 } |
279 | 321 |
280 out->trace_id_ = data.trace_id(); | 322 out->trace_id_ = data.trace_id(); |
281 out->coalesced_ = data.coalesced(); | 323 out->coalesced_ = data.coalesced(); |
282 out->terminated_ = data.terminated(); | 324 out->terminated_ = data.terminated(); |
| 325 out->source_event_type_ = MojoSourceEventTypeToUI(data.source_event_type()); |
283 return true; | 326 return true; |
284 } | 327 } |
285 | 328 |
286 } // namespace mojo | 329 } // namespace mojo |
OLD | NEW |