| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // Nondecreasing number that can be used to determine what events happened | 73 // Nondecreasing number that can be used to determine what events happened |
| 74 // in the component at the time this struct was sent on to the next | 74 // in the component at the time this struct was sent on to the next |
| 75 // component. | 75 // component. |
| 76 int64 sequence_number; | 76 int64 sequence_number; |
| 77 // Average time of events that happened in this component. | 77 // Average time of events that happened in this component. |
| 78 base::TimeTicks event_time; | 78 base::TimeTicks event_time; |
| 79 // Count of events that happened in this component | 79 // Count of events that happened in this component |
| 80 uint32 event_count; | 80 uint32 event_count; |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 // Empirically determined constant based on a typical scroll sequence. |
| 84 enum { kTypicalMaxComponentsPerLatencyInfo = 6 }; |
| 85 |
| 83 // Map a Latency Component (with a component-specific int64 id) to a | 86 // Map a Latency Component (with a component-specific int64 id) to a |
| 84 // component info. | 87 // component info. |
| 85 typedef std::map<std::pair<LatencyComponentType, int64>, LatencyComponent> | 88 typedef base::SmallMap< |
| 86 LatencyMap; | 89 std::map<std::pair<LatencyComponentType, int64>, LatencyComponent>, |
| 90 kTypicalMaxComponentsPerLatencyInfo> LatencyMap; |
| 87 | 91 |
| 88 LatencyInfo(); | 92 LatencyInfo(); |
| 89 | 93 |
| 90 ~LatencyInfo(); | 94 ~LatencyInfo(); |
| 91 | 95 |
| 92 // Returns true if the vector |latency_info| is valid. Returns false | 96 // Returns true if the vector |latency_info| is valid. Returns false |
| 93 // if it is not valid and log the |referring_msg|. | 97 // if it is not valid and log the |referring_msg|. |
| 94 // This function is mainly used to check the latency_info vector that | 98 // This function is mainly used to check the latency_info vector that |
| 95 // is passed between processes using IPC message has reasonable size | 99 // is passed between processes using IPC message has reasonable size |
| 96 // so that we are confident the IPC message is not corrupted/compromised. | 100 // 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... |
| 136 LatencyMap latency_components; | 140 LatencyMap latency_components; |
| 137 // The unique id for matching the ASYNC_BEGIN/END trace event. | 141 // The unique id for matching the ASYNC_BEGIN/END trace event. |
| 138 int64 trace_id; | 142 int64 trace_id; |
| 139 // Whether a terminal component has been added. | 143 // Whether a terminal component has been added. |
| 140 bool terminated; | 144 bool terminated; |
| 141 }; | 145 }; |
| 142 | 146 |
| 143 } // namespace ui | 147 } // namespace ui |
| 144 | 148 |
| 145 #endif // UI_EVENTS_LATENCY_INFO_H_ | 149 #endif // UI_EVENTS_LATENCY_INFO_H_ |
| OLD | NEW |