| 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 #ifndef UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ | 5 #ifndef UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ |
| 6 #define UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ | 6 #define UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ |
| 7 | 7 |
| 8 #include "ui/events/latency_info.h" | 8 #include "ui/events/latency_info.h" |
| 9 #include "ui/events/mojo/latency_info.mojom.h" | 9 #include "ui/events/mojo/latency_info.mojom.h" |
| 10 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h" | 10 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 static const Element& GetValue(ConstIterator& iterator) { return *iterator; } | 32 static const Element& GetValue(ConstIterator& iterator) { return *iterator; } |
| 33 static Element& GetValue(Iterator& iterator) { return *iterator; } | 33 static Element& GetValue(Iterator& iterator) { return *iterator; } |
| 34 | 34 |
| 35 static size_t GetSize(const ui::LatencyInfo::LatencyMap& input) { | 35 static size_t GetSize(const ui::LatencyInfo::LatencyMap& input) { |
| 36 return input.size(); | 36 return input.size(); |
| 37 } | 37 } |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 template <> | 40 template <> |
| 41 struct StructTraits<ui::mojom::LatencyComponent, | 41 struct StructTraits<ui::mojom::LatencyComponentDataView, |
| 42 ui::LatencyInfo::LatencyComponent> { | 42 ui::LatencyInfo::LatencyComponent> { |
| 43 static int64_t sequence_number( | 43 static int64_t sequence_number( |
| 44 const ui::LatencyInfo::LatencyComponent& component); | 44 const ui::LatencyInfo::LatencyComponent& component); |
| 45 static base::TimeTicks event_time( | 45 static base::TimeTicks event_time( |
| 46 const ui::LatencyInfo::LatencyComponent& component); | 46 const ui::LatencyInfo::LatencyComponent& component); |
| 47 static uint32_t event_count( | 47 static uint32_t event_count( |
| 48 const ui::LatencyInfo::LatencyComponent& component); | 48 const ui::LatencyInfo::LatencyComponent& component); |
| 49 static bool Read(ui::mojom::LatencyComponentDataView data, | 49 static bool Read(ui::mojom::LatencyComponentDataView data, |
| 50 ui::LatencyInfo::LatencyComponent* out); | 50 ui::LatencyInfo::LatencyComponent* out); |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 template <> | 53 template <> |
| 54 struct StructTraits<ui::mojom::LatencyComponentPair, | 54 struct StructTraits<ui::mojom::LatencyComponentPairDataView, |
| 55 ui::LatencyInfo::LatencyMap::value_type> { | 55 ui::LatencyInfo::LatencyMap::value_type> { |
| 56 static const std::pair<ui::LatencyComponentType, int64_t>& key( | 56 static const std::pair<ui::LatencyComponentType, int64_t>& key( |
| 57 const ui::LatencyInfo::LatencyMap::value_type& input) { | 57 const ui::LatencyInfo::LatencyMap::value_type& input) { |
| 58 return input.first; | 58 return input.first; |
| 59 } | 59 } |
| 60 | 60 |
| 61 static const ui::LatencyInfo::LatencyComponent& value( | 61 static const ui::LatencyInfo::LatencyComponent& value( |
| 62 const ui::LatencyInfo::LatencyMap::value_type& input) { | 62 const ui::LatencyInfo::LatencyMap::value_type& input) { |
| 63 return input.second; | 63 return input.second; |
| 64 } | 64 } |
| 65 | 65 |
| 66 // TODO(fsamuel): Figure out how to optimize deserialization. | 66 // TODO(fsamuel): Figure out how to optimize deserialization. |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 template <> | 69 template <> |
| 70 struct StructTraits<ui::mojom::LatencyComponentId, | 70 struct StructTraits<ui::mojom::LatencyComponentIdDataView, |
| 71 std::pair<ui::LatencyComponentType, int64_t>> { | 71 std::pair<ui::LatencyComponentType, int64_t>> { |
| 72 static ui::mojom::LatencyComponentType type( | 72 static ui::mojom::LatencyComponentType type( |
| 73 const std::pair<ui::LatencyComponentType, int64_t>& id); | 73 const std::pair<ui::LatencyComponentType, int64_t>& id); |
| 74 static int64_t id(const std::pair<ui::LatencyComponentType, int64_t>& id); | 74 static int64_t id(const std::pair<ui::LatencyComponentType, int64_t>& id); |
| 75 static bool Read(ui::mojom::LatencyComponentIdDataView data, | 75 static bool Read(ui::mojom::LatencyComponentIdDataView data, |
| 76 std::pair<ui::LatencyComponentType, int64_t>* out); | 76 std::pair<ui::LatencyComponentType, int64_t>* out); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 template <> | 79 template <> |
| 80 struct StructTraits<ui::mojom::LatencyInfo, ui::LatencyInfo> { | 80 struct StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo> { |
| 81 static const std::string& trace_name(const ui::LatencyInfo& info); | 81 static const std::string& trace_name(const ui::LatencyInfo& info); |
| 82 static const ui::LatencyInfo::LatencyMap& latency_components( | 82 static const ui::LatencyInfo::LatencyMap& latency_components( |
| 83 const ui::LatencyInfo& info); | 83 const ui::LatencyInfo& info); |
| 84 static uint32_t input_coordinates_size(const ui::LatencyInfo& info); | 84 static uint32_t input_coordinates_size(const ui::LatencyInfo& info); |
| 85 static InputCoordinateArray input_coordinates(const ui::LatencyInfo& info); | 85 static InputCoordinateArray input_coordinates(const ui::LatencyInfo& info); |
| 86 static int64_t trace_id(const ui::LatencyInfo& info); | 86 static int64_t trace_id(const ui::LatencyInfo& info); |
| 87 static bool coalesced(const ui::LatencyInfo& info); | 87 static bool coalesced(const ui::LatencyInfo& info); |
| 88 static bool terminated(const ui::LatencyInfo& info); | 88 static bool terminated(const ui::LatencyInfo& info); |
| 89 static bool Read(ui::mojom::LatencyInfoDataView data, ui::LatencyInfo* out); | 89 static bool Read(ui::mojom::LatencyInfoDataView data, ui::LatencyInfo* out); |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 } // namespace mojo | 92 } // namespace mojo |
| 93 | 93 |
| 94 #endif // UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ | 94 #endif // UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ |
| OLD | NEW |