| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_LATENCY_INFO_H_ | 5 #ifndef UI_EVENTS_LATENCY_INFO_H_ |
| 6 #define UI_EVENTS_LATENCY_INFO_H_ | 6 #define UI_EVENTS_LATENCY_INFO_H_ |
| 7 | 7 |
| 8 #include <map> | |
| 9 #include <utility> | 8 #include <utility> |
| 10 #include <vector> | 9 #include <vector> |
| 11 | 10 |
| 12 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/containers/small_map.h" |
| 13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "ui/events/events_base_export.h" | 14 #include "ui/events/events_base_export.h" |
| 15 | 15 |
| 16 namespace ui { | 16 namespace ui { |
| 17 | 17 |
| 18 enum LatencyComponentType { | 18 enum LatencyComponentType { |
| 19 // ---------------------------BEGIN COMPONENT------------------------------- | 19 // ---------------------------BEGIN COMPONENT------------------------------- |
| 20 // BEGIN COMPONENT is when we show the latency begin in chrome://tracing. | 20 // BEGIN COMPONENT is when we show the latency begin in chrome://tracing. |
| 21 // Timestamp when the input event is sent from RenderWidgetHost to renderer. | 21 // Timestamp when the input event is sent from RenderWidgetHost to renderer. |
| 22 INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, | 22 INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // Nondecreasing number that can be used to determine what events happened | 72 // Nondecreasing number that can be used to determine what events happened |
| 73 // in the component at the time this struct was sent on to the next | 73 // in the component at the time this struct was sent on to the next |
| 74 // component. | 74 // component. |
| 75 int64 sequence_number; | 75 int64 sequence_number; |
| 76 // Average time of events that happened in this component. | 76 // Average time of events that happened in this component. |
| 77 base::TimeTicks event_time; | 77 base::TimeTicks event_time; |
| 78 // Count of events that happened in this component | 78 // Count of events that happened in this component |
| 79 uint32 event_count; | 79 uint32 event_count; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 // Empirically determined constant based on a typical scroll sequence. |
| 83 enum { kTypicalMaxComponentsPerLatencyInfo = 6 }; |
| 84 |
| 82 // Map a Latency Component (with a component-specific int64 id) to a | 85 // Map a Latency Component (with a component-specific int64 id) to a |
| 83 // component info. | 86 // component info. |
| 84 typedef std::map<std::pair<LatencyComponentType, int64>, LatencyComponent> | 87 typedef base::SmallMap< |
| 85 LatencyMap; | 88 std::map<std::pair<LatencyComponentType, int64>, LatencyComponent>, |
| 89 kTypicalMaxComponentsPerLatencyInfo> LatencyMap; |
| 86 | 90 |
| 87 LatencyInfo(); | 91 LatencyInfo(); |
| 88 | 92 |
| 89 ~LatencyInfo(); | 93 ~LatencyInfo(); |
| 90 | 94 |
| 91 // Returns true if the vector |latency_info| is valid. Returns false | 95 // Returns true if the vector |latency_info| is valid. Returns false |
| 92 // if it is not valid and log the |referring_msg|. | 96 // if it is not valid and log the |referring_msg|. |
| 93 // This function is mainly used to check the latency_info vector that | 97 // This function is mainly used to check the latency_info vector that |
| 94 // is passed between processes using IPC message has reasonable size | 98 // is passed between processes using IPC message has reasonable size |
| 95 // so that we are confident the IPC message is not corrupted/compromised. | 99 // so that we are confident the IPC message is not corrupted/compromised. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 LatencyMap latency_components; | 139 LatencyMap latency_components; |
| 136 // The unique id for matching the ASYNC_BEGIN/END trace event. | 140 // The unique id for matching the ASYNC_BEGIN/END trace event. |
| 137 int64 trace_id; | 141 int64 trace_id; |
| 138 // Whether a terminal component has been added. | 142 // Whether a terminal component has been added. |
| 139 bool terminated; | 143 bool terminated; |
| 140 }; | 144 }; |
| 141 | 145 |
| 142 } // namespace ui | 146 } // namespace ui |
| 143 | 147 |
| 144 #endif // UI_EVENTS_LATENCY_INFO_H_ | 148 #endif // UI_EVENTS_LATENCY_INFO_H_ |
| OLD | NEW |