| 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" |
| 11 | 11 |
| 12 namespace mojo { | 12 namespace mojo { |
| 13 | 13 |
| 14 // A buffer used to read bytes directly from LatencyInfoDataView into | 14 using InputCoordinateArray = CArray<gfx::PointF>; |
| 15 // ui::LatencyInfo's input_coordinates_. | |
| 16 struct InputCoordinateArray { | |
| 17 size_t size; | |
| 18 gfx::PointF* data; | |
| 19 }; | |
| 20 | |
| 21 // TODO(fsamuel): We should add a common ArrayTraits<CArray<T>> utility struct. | |
| 22 template <> | |
| 23 struct ArrayTraits<InputCoordinateArray> { | |
| 24 using Element = gfx::PointF; | |
| 25 static size_t GetSize(const InputCoordinateArray& b); | |
| 26 static Element* GetData(InputCoordinateArray& b); | |
| 27 static const Element* GetData(const InputCoordinateArray& b); | |
| 28 static Element& GetAt(InputCoordinateArray& b, size_t i); | |
| 29 static const Element& GetAt(const InputCoordinateArray& b, size_t i); | |
| 30 static bool Resize(InputCoordinateArray& b, size_t size); | |
| 31 }; | |
| 32 | 15 |
| 33 template <> | 16 template <> |
| 34 struct StructTraits<ui::mojom::LatencyComponent, | 17 struct StructTraits<ui::mojom::LatencyComponent, |
| 35 ui::LatencyInfo::LatencyComponent> { | 18 ui::LatencyInfo::LatencyComponent> { |
| 36 static int64_t sequence_number( | 19 static int64_t sequence_number( |
| 37 const ui::LatencyInfo::LatencyComponent& component); | 20 const ui::LatencyInfo::LatencyComponent& component); |
| 38 static base::TimeTicks event_time( | 21 static base::TimeTicks event_time( |
| 39 const ui::LatencyInfo::LatencyComponent& component); | 22 const ui::LatencyInfo::LatencyComponent& component); |
| 40 static uint32_t event_count( | 23 static uint32_t event_count( |
| 41 const ui::LatencyInfo::LatencyComponent& component); | 24 const ui::LatencyInfo::LatencyComponent& component); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 65 static InputCoordinateArray input_coordinates(const ui::LatencyInfo& info); | 48 static InputCoordinateArray input_coordinates(const ui::LatencyInfo& info); |
| 66 static int64_t trace_id(const ui::LatencyInfo& info); | 49 static int64_t trace_id(const ui::LatencyInfo& info); |
| 67 static bool coalesced(const ui::LatencyInfo& info); | 50 static bool coalesced(const ui::LatencyInfo& info); |
| 68 static bool terminated(const ui::LatencyInfo& info); | 51 static bool terminated(const ui::LatencyInfo& info); |
| 69 static bool Read(ui::mojom::LatencyInfoDataView data, ui::LatencyInfo* out); | 52 static bool Read(ui::mojom::LatencyInfoDataView data, ui::LatencyInfo* out); |
| 70 }; | 53 }; |
| 71 | 54 |
| 72 } // namespace mojo | 55 } // namespace mojo |
| 73 | 56 |
| 74 #endif // UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ | 57 #endif // UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ |
| OLD | NEW |