Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ | |
| 6 #define UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ | |
| 7 | |
| 8 #include "ui/events/latency_info.h" | |
| 9 #include "ui/events/mojo/latency_info.mojom.h" | |
| 10 | |
| 11 namespace mojo { | |
| 12 | |
| 13 template <> | |
| 14 struct StructTraits<ui::mojom::InputCoordinate, | |
| 15 ui::LatencyInfo::InputCoordinate> { | |
| 16 static float x(const ui::LatencyInfo::InputCoordinate& input); | |
| 17 static float y(const ui::LatencyInfo::InputCoordinate& input); | |
| 18 static bool Read(ui::mojom::InputCoordinateDataView data, | |
| 19 ui::LatencyInfo::InputCoordinate* out); | |
| 20 }; | |
| 21 | |
| 22 // A buffer used to read bytes directly from LatencyInfoDataView into | |
| 23 // ui::LatencyInfo's input_coordinates_. | |
| 24 struct InputCoordinateArray { | |
| 25 uint32_t size; | |
| 26 ui::LatencyInfo::InputCoordinate* data; | |
| 27 }; | |
| 28 | |
| 29 template <> | |
| 30 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
| |
| 31 using Element = ui::LatencyInfo::InputCoordinate; | |
| 32 static size_t GetSize(const InputCoordinateArray& b); | |
| 33 static Element* GetData(InputCoordinateArray& b); | |
| 34 static const Element* GetData(const InputCoordinateArray& b); | |
| 35 static Element& GetAt(InputCoordinateArray& b, size_t i); | |
| 36 static const Element& GetAt(const InputCoordinateArray& b, size_t i); | |
| 37 static void Resize(InputCoordinateArray& b, size_t size); | |
| 38 }; | |
| 39 | |
| 40 template <> | |
| 41 struct StructTraits<ui::mojom::LatencyComponent, | |
| 42 ui::LatencyInfo::LatencyComponent> { | |
| 43 static int64_t sequence_number( | |
| 44 const ui::LatencyInfo::LatencyComponent& component); | |
| 45 static base::TimeTicks event_time( | |
| 46 const ui::LatencyInfo::LatencyComponent& component); | |
| 47 static uint32_t event_count( | |
| 48 const ui::LatencyInfo::LatencyComponent& component); | |
| 49 static bool Read(ui::mojom::LatencyComponentDataView data, | |
| 50 ui::LatencyInfo::LatencyComponent* out); | |
| 51 }; | |
| 52 | |
| 53 template <> | |
| 54 struct StructTraits<ui::mojom::LatencyComponentId, | |
| 55 std::pair<ui::LatencyComponentType, int64_t>> { | |
| 56 static ui::mojom::LatencyComponentType type( | |
| 57 const std::pair<ui::LatencyComponentType, int64_t>& id); | |
| 58 static int64_t id(const std::pair<ui::LatencyComponentType, int64_t>& id); | |
| 59 static bool Read(ui::mojom::LatencyComponentIdDataView data, | |
| 60 std::pair<ui::LatencyComponentType, int64_t>* out); | |
| 61 }; | |
| 62 | |
| 63 template <> | |
| 64 struct StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo> { | |
| 65 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
| |
| 66 static mojo::Array<ui::mojom::LatencyComponentPairPtr> latency_components( | |
| 67 const ui::LatencyInfo& info); | |
| 68 static uint32_t input_coordinates_size(const ui::LatencyInfo& info); | |
| 69 static InputCoordinateArray input_coordinates(const ui::LatencyInfo& info); | |
| 70 static int64_t trace_id(const ui::LatencyInfo& info); | |
| 71 static bool coalesced(const ui::LatencyInfo& info); | |
| 72 static bool terminated(const ui::LatencyInfo& info); | |
| 73 static bool Read(ui::mojom::LatencyInfoDataView data, ui::LatencyInfo* out); | |
| 74 }; | |
| 75 | |
| 76 } // namespace mojo | |
| 77 | |
| 78 #endif // UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ | |
| OLD | NEW |