Chromium Code Reviews| Index: ui/events/mojo/latency_info_struct_traits.h |
| diff --git a/ui/events/mojo/latency_info_struct_traits.h b/ui/events/mojo/latency_info_struct_traits.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..92e2d22d166a235cf181e12d0b68eee5d5f08cf7 |
| --- /dev/null |
| +++ b/ui/events/mojo/latency_info_struct_traits.h |
| @@ -0,0 +1,78 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ |
| +#define UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ |
| + |
| +#include "ui/events/latency_info.h" |
| +#include "ui/events/mojo/latency_info.mojom.h" |
| + |
| +namespace mojo { |
| + |
| +template <> |
| +struct StructTraits<ui::mojom::InputCoordinate, |
| + ui::LatencyInfo::InputCoordinate> { |
| + static float x(const ui::LatencyInfo::InputCoordinate& input); |
| + static float y(const ui::LatencyInfo::InputCoordinate& input); |
| + static bool Read(ui::mojom::InputCoordinateDataView data, |
| + ui::LatencyInfo::InputCoordinate* out); |
| +}; |
| + |
| +// A buffer used to read bytes directly from LatencyInfoDataView into |
| +// ui::LatencyInfo's input_coordinates_. |
| +struct InputCoordinateArray { |
| + uint32_t size; |
| + ui::LatencyInfo::InputCoordinate* data; |
| +}; |
| + |
| +template <> |
| +struct ArrayTraits<InputCoordinateArray> { |
|
yzshen1
2016/06/06 16:15:22
Now that we have seen C array used in multiple pla
Fady Samuel
2016/06/06 18:00:23
I'll do this in a follow-on CL. I added a TODO. Th
|
| + using Element = ui::LatencyInfo::InputCoordinate; |
| + static size_t GetSize(const InputCoordinateArray& b); |
| + static Element* GetData(InputCoordinateArray& b); |
| + static const Element* GetData(const InputCoordinateArray& b); |
| + static Element& GetAt(InputCoordinateArray& b, size_t i); |
| + static const Element& GetAt(const InputCoordinateArray& b, size_t i); |
| + static void Resize(InputCoordinateArray& b, size_t size); |
| +}; |
| + |
| +template <> |
| +struct StructTraits<ui::mojom::LatencyComponent, |
| + ui::LatencyInfo::LatencyComponent> { |
| + static int64_t sequence_number( |
| + const ui::LatencyInfo::LatencyComponent& component); |
| + static base::TimeTicks event_time( |
| + const ui::LatencyInfo::LatencyComponent& component); |
| + static uint32_t event_count( |
| + const ui::LatencyInfo::LatencyComponent& component); |
| + static bool Read(ui::mojom::LatencyComponentDataView data, |
| + ui::LatencyInfo::LatencyComponent* out); |
| +}; |
| + |
| +template <> |
| +struct StructTraits<ui::mojom::LatencyComponentId, |
| + std::pair<ui::LatencyComponentType, int64_t>> { |
| + static ui::mojom::LatencyComponentType type( |
| + const std::pair<ui::LatencyComponentType, int64_t>& id); |
| + static int64_t id(const std::pair<ui::LatencyComponentType, int64_t>& id); |
| + static bool Read(ui::mojom::LatencyComponentIdDataView data, |
| + std::pair<ui::LatencyComponentType, int64_t>* out); |
| +}; |
| + |
| +template <> |
| +struct StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo> { |
| + static std::string trace_name(const ui::LatencyInfo& info); |
|
yzshen1
2016/06/06 16:15:22
Getter for object fields will be called twice. Ret
Fady Samuel
2016/06/06 18:00:23
Done. Please let me know if I did this right for l
|
| + static mojo::Array<ui::mojom::LatencyComponentPairPtr> latency_components( |
| + const ui::LatencyInfo& info); |
| + static uint32_t input_coordinates_size(const ui::LatencyInfo& info); |
| + static InputCoordinateArray input_coordinates(const ui::LatencyInfo& info); |
| + static int64_t trace_id(const ui::LatencyInfo& info); |
| + static bool coalesced(const ui::LatencyInfo& info); |
| + static bool terminated(const ui::LatencyInfo& info); |
| + static bool Read(ui::mojom::LatencyInfoDataView data, ui::LatencyInfo* out); |
| +}; |
| + |
| +} // namespace mojo |
| + |
| +#endif // UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ |