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> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
13 #include "ui/events/events_base_export.h" | 14 #include "ui/events/events_base_export.h" |
14 | 15 |
15 namespace ui { | 16 namespace ui { |
16 | 17 |
17 enum LatencyComponentType { | 18 enum LatencyComponentType { |
18 // ---------------------------BEGIN COMPONENT------------------------------- | 19 // ---------------------------BEGIN COMPONENT------------------------------- |
19 // 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. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 | 81 |
81 // Map a Latency Component (with a component-specific int64 id) to a | 82 // Map a Latency Component (with a component-specific int64 id) to a |
82 // component info. | 83 // component info. |
83 typedef std::map<std::pair<LatencyComponentType, int64>, LatencyComponent> | 84 typedef std::map<std::pair<LatencyComponentType, int64>, LatencyComponent> |
84 LatencyMap; | 85 LatencyMap; |
85 | 86 |
86 LatencyInfo(); | 87 LatencyInfo(); |
87 | 88 |
88 ~LatencyInfo(); | 89 ~LatencyInfo(); |
89 | 90 |
91 // Returns true if the vector |latency_info| is valid. Returns false | |
92 // if it is not valid and log the |referring_msg|. | |
93 // This function is mainly used to check the latency_info vector that | |
94 // is passed between processes using IPC message has reasonable size | |
95 // so that we are confident the IPC message is not corrupted/compromised. | |
96 // This check will go away once the IPC system has better built-in scheme | |
97 // for corruption/compromise detection. | |
98 static bool Verify(const std::vector<LatencyInfo>& latency_info, | |
99 const char* referring_msg); | |
100 | |
90 // Merges the contents of another LatencyInfo into this one. | 101 // Merges the contents of another LatencyInfo into this one. |
91 void MergeWith(const LatencyInfo& other); | 102 void MergeWith(const LatencyInfo& other); |
92 | 103 |
93 // Add LatencyComponents that are in |other| but not in |this|. | 104 // Add LatencyComponents that are in |other| but not in |this|. |
94 void AddNewLatencyFrom(const LatencyInfo& other); | 105 void AddNewLatencyFrom(const LatencyInfo& other); |
95 | 106 |
96 // Modifies the current sequence number for a component, and adds a new | 107 // Modifies the current sequence number for a component, and adds a new |
97 // sequence number with the current timestamp. | 108 // sequence number with the current timestamp. |
98 void AddLatencyNumber(LatencyComponentType component, | 109 void AddLatencyNumber(LatencyComponentType component, |
99 int64 id, | 110 int64 id, |
(...skipping 21 matching lines...) Expand all Loading... | |
121 void Clear(); | 132 void Clear(); |
122 | 133 |
123 // Records the |event_type| in trace buffer as TRACE_EVENT_ASYNC_STEP. | 134 // Records the |event_type| in trace buffer as TRACE_EVENT_ASYNC_STEP. |
124 void TraceEventType(const char* event_type); | 135 void TraceEventType(const char* event_type); |
125 | 136 |
126 LatencyMap latency_components; | 137 LatencyMap latency_components; |
127 // The unique id for matching the ASYNC_BEGIN/END trace event. | 138 // The unique id for matching the ASYNC_BEGIN/END trace event. |
128 int64 trace_id; | 139 int64 trace_id; |
129 // Whether a terminal component has been added. | 140 // Whether a terminal component has been added. |
130 bool terminated; | 141 bool terminated; |
142 | |
143 static const unsigned int kMaxLatencyInfoNumber = 100; | |
Ken Russell (switch to Gerrit)
2014/01/16 02:05:14
This could just go into latency_info.cc.
Yufeng Shen (Slow to review)
2014/01/16 03:33:17
Done.
| |
144 | |
131 }; | 145 }; |
132 | 146 |
133 } // namespace ui | 147 } // namespace ui |
134 | 148 |
135 #endif // UI_EVENTS_LATENCY_INFO_H_ | 149 #endif // UI_EVENTS_LATENCY_INFO_H_ |
OLD | NEW |