Chromium Code Reviews| 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/events/mojo/latency_info_struct_traits.h" | 5 #include "ui/events/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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 269 const ui::LatencyInfo& info) { | 269 const ui::LatencyInfo& info) { |
| 270 return info.terminated(); | 270 return info.terminated(); |
| 271 } | 271 } |
| 272 | 272 |
| 273 bool StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::Read( | 273 bool StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo>::Read( |
| 274 ui::mojom::LatencyInfoDataView data, | 274 ui::mojom::LatencyInfoDataView data, |
| 275 ui::LatencyInfo* out) { | 275 ui::LatencyInfo* out) { |
| 276 if (!data.ReadTraceName(&out->trace_name_)) | 276 if (!data.ReadTraceName(&out->trace_name_)) |
| 277 return false; | 277 return false; |
| 278 | 278 |
| 279 // TODO(fsamuel): Figure out how to optimize deserialization. | 279 mojo::ArrayDataView<ui::mojom::LatencyComponentPairDataView> components; |
| 280 mojo::Array<ui::mojom::LatencyComponentPairPtr> components; | 280 data.GetLatencyComponentsDataView(&components); |
| 281 if (!data.ReadLatencyComponents(&components)) | 281 for (uint32_t i = 0; i < components.size(); ++i) { |
| 282 return false; | 282 ui::mojom::LatencyComponentPairDataView component_pair; |
| 283 for (uint32_t i = 0; i < components.size(); ++i) | 283 components.GetDataView(i, &component_pair); |
|
yzshen1
2016/08/23 21:23:05
This change itself LGTM.
Performance fyi: It woul
| |
| 284 out->latency_components_[components[i]->key] = components[i]->value; | 284 ui::LatencyInfo::LatencyMap::key_type key; |
| 285 if (!component_pair.ReadKey(&key)) | |
| 286 return false; | |
| 287 auto& value = out->latency_components_[key]; | |
| 288 if (!component_pair.ReadValue(&value)) | |
| 289 return false; | |
| 290 } | |
| 285 | 291 |
| 286 InputCoordinateArray input_coordinate_array = { | 292 InputCoordinateArray input_coordinate_array = { |
| 287 0, ui::LatencyInfo::kMaxInputCoordinates, out->input_coordinates_}; | 293 0, ui::LatencyInfo::kMaxInputCoordinates, out->input_coordinates_}; |
| 288 if (!data.ReadInputCoordinates(&input_coordinate_array)) | 294 if (!data.ReadInputCoordinates(&input_coordinate_array)) |
| 289 return false; | 295 return false; |
| 290 // TODO(fsamuel): ui::LatencyInfo::input_coordinates_size_ should be a size_t. | 296 // TODO(fsamuel): ui::LatencyInfo::input_coordinates_size_ should be a size_t. |
| 291 out->input_coordinates_size_ = | 297 out->input_coordinates_size_ = |
| 292 static_cast<uint32_t>(input_coordinate_array.size); | 298 static_cast<uint32_t>(input_coordinate_array.size); |
| 293 | 299 |
| 294 out->trace_id_ = data.trace_id(); | 300 out->trace_id_ = data.trace_id(); |
| 295 out->coalesced_ = data.coalesced(); | 301 out->coalesced_ = data.coalesced(); |
| 296 out->terminated_ = data.terminated(); | 302 out->terminated_ = data.terminated(); |
| 297 return true; | 303 return true; |
| 298 } | 304 } |
| 299 | 305 |
| 300 } // namespace mojo | 306 } // namespace mojo |
| OLD | NEW |