Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: base/test/trace_event_analyzer.h

Issue 1776673002: base: Add blame context (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Use trace_analyzer::Query and trace_analyzer::TraceAnalyzer to search for 5 // Use trace_analyzer::Query and trace_analyzer::TraceAnalyzer to search for
6 // specific trace events that were generated by the trace_event.h API. 6 // specific trace events that were generated by the trace_event.h API.
7 // 7 //
8 // Basic procedure: 8 // Basic procedure:
9 // - Get trace events JSON string from base::trace_event::TraceLog. 9 // - Get trace events JSON string from base::trace_event::TraceLog.
10 // - Create TraceAnalyzer with JSON string. 10 // - Create TraceAnalyzer with JSON string.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 if (process_id != rhs.process_id) 105 if (process_id != rhs.process_id)
106 return process_id < rhs.process_id; 106 return process_id < rhs.process_id;
107 return thread_id < rhs.thread_id; 107 return thread_id < rhs.thread_id;
108 } 108 }
109 int process_id; 109 int process_id;
110 int thread_id; 110 int thread_id;
111 }; 111 };
112 112
113 TraceEvent(); 113 TraceEvent();
114 TraceEvent(const TraceEvent& other); 114 TraceEvent(const TraceEvent& other);
115 TraceEvent(TraceEvent&& other);
115 ~TraceEvent(); 116 ~TraceEvent();
116 117
117 bool SetFromJSON(const base::Value* event_value) WARN_UNUSED_RESULT; 118 bool SetFromJSON(const base::Value* event_value) WARN_UNUSED_RESULT;
118 119
119 bool operator< (const TraceEvent& rhs) const { 120 bool operator< (const TraceEvent& rhs) const {
120 return timestamp < rhs.timestamp; 121 return timestamp < rhs.timestamp;
121 } 122 }
122 123
124 TraceEvent& operator=(const TraceEvent& rhs);
125 TraceEvent& operator=(TraceEvent&& rhs);
126
123 bool has_other_event() const { return other_event; } 127 bool has_other_event() const { return other_event; }
124 128
125 // Returns absolute duration in microseconds between this event and other 129 // Returns absolute duration in microseconds between this event and other
126 // event. Must have already verified that other_event exists by 130 // event. Must have already verified that other_event exists by
127 // Query(EVENT_HAS_OTHER) or by calling has_other_event(). 131 // Query(EVENT_HAS_OTHER) or by calling has_other_event().
128 double GetAbsTimeToOtherEvent() const; 132 double GetAbsTimeToOtherEvent() const;
129 133
130 // Return the argument value if it exists and it is a string. 134 // Return the argument value if it exists and it is a string.
131 bool GetArgAsString(const std::string& name, std::string* arg) const; 135 bool GetArgAsString(const std::string& name, std::string* arg) const;
132 // Return the argument value if it exists and it is a number. 136 // Return the argument value if it exists and it is a number.
133 bool GetArgAsNumber(const std::string& name, double* arg) const; 137 bool GetArgAsNumber(const std::string& name, double* arg) const;
138 // Return the argument value if it exists.
139 bool GetArgAsValue(const std::string& name,
140 scoped_ptr<base::Value>* arg) const;
134 141
135 // Check if argument exists and is string. 142 // Check if argument exists and is string.
136 bool HasStringArg(const std::string& name) const; 143 bool HasStringArg(const std::string& name) const;
137 // Check if argument exists and is number (double, int or bool). 144 // Check if argument exists and is number (double, int or bool).
138 bool HasNumberArg(const std::string& name) const; 145 bool HasNumberArg(const std::string& name) const;
146 // Check if argument exists.
147 bool HasArg(const std::string& name) const;
139 148
140 // Get known existing arguments as specific types. 149 // Get known existing arguments as specific types.
141 // Useful when you have already queried the argument with 150 // Useful when you have already queried the argument with
142 // Query(HAS_NUMBER_ARG) or Query(HAS_STRING_ARG). 151 // Query(HAS_NUMBER_ARG) or Query(HAS_STRING_ARG).
143 std::string GetKnownArgAsString(const std::string& name) const; 152 std::string GetKnownArgAsString(const std::string& name) const;
144 double GetKnownArgAsDouble(const std::string& name) const; 153 double GetKnownArgAsDouble(const std::string& name) const;
145 int GetKnownArgAsInt(const std::string& name) const; 154 int GetKnownArgAsInt(const std::string& name) const;
146 bool GetKnownArgAsBool(const std::string& name) const; 155 bool GetKnownArgAsBool(const std::string& name) const;
156 scoped_ptr<base::Value> GetKnownArgAsValue(const std::string& name) const;
147 157
148 // Process ID and Thread ID. 158 // Process ID and Thread ID.
149 ProcessThreadID thread; 159 ProcessThreadID thread;
150 160
151 // Time since epoch in microseconds. 161 // Time since epoch in microseconds.
152 // Stored as double to match its JSON representation. 162 // Stored as double to match its JSON representation.
153 double timestamp; 163 double timestamp;
154
155 double duration; 164 double duration;
156
157 char phase; 165 char phase;
158
159 std::string category; 166 std::string category;
160
161 std::string name; 167 std::string name;
162
163 std::string id; 168 std::string id;
164 169
165 // All numbers and bool values from TraceEvent args are cast to double. 170 // All numbers and bool values from TraceEvent args are cast to double.
166 // bool becomes 1.0 (true) or 0.0 (false). 171 // bool becomes 1.0 (true) or 0.0 (false).
167 std::map<std::string, double> arg_numbers; 172 std::map<std::string, double> arg_numbers;
168
169 std::map<std::string, std::string> arg_strings; 173 std::map<std::string, std::string> arg_strings;
174 std::map<std::string, scoped_ptr<base::Value>> arg_values;
170 175
171 // The other event associated with this event (or NULL). 176 // The other event associated with this event (or NULL).
172 const TraceEvent* other_event; 177 const TraceEvent* other_event;
173 }; 178 };
174 179
175 typedef std::vector<const TraceEvent*> TraceEventVector; 180 typedef std::vector<const TraceEvent*> TraceEventVector;
176 181
177 class Query { 182 class Query {
178 public: 183 public:
179 Query(const Query& query); 184 Query(const Query& query);
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 707
703 // Count all matches. 708 // Count all matches.
704 static inline size_t CountMatches(const TraceEventVector& events, 709 static inline size_t CountMatches(const TraceEventVector& events,
705 const Query& query) { 710 const Query& query) {
706 return CountMatches(events, query, 0u, events.size()); 711 return CountMatches(events, query, 0u, events.size());
707 } 712 }
708 713
709 } // namespace trace_analyzer 714 } // namespace trace_analyzer
710 715
711 #endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_ 716 #endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698