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

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

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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
« no previous file with comments | « base/test/test_support_ios.mm ('k') | base/test/trace_event_analyzer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // event. Must have already verified that other_event exists by 128 // event. Must have already verified that other_event exists by
129 // Query(EVENT_HAS_OTHER) or by calling has_other_event(). 129 // Query(EVENT_HAS_OTHER) or by calling has_other_event().
130 double GetAbsTimeToOtherEvent() const; 130 double GetAbsTimeToOtherEvent() const;
131 131
132 // Return the argument value if it exists and it is a string. 132 // Return the argument value if it exists and it is a string.
133 bool GetArgAsString(const std::string& name, std::string* arg) const; 133 bool GetArgAsString(const std::string& name, std::string* arg) const;
134 // Return the argument value if it exists and it is a number. 134 // Return the argument value if it exists and it is a number.
135 bool GetArgAsNumber(const std::string& name, double* arg) const; 135 bool GetArgAsNumber(const std::string& name, double* arg) const;
136 // Return the argument value if it exists. 136 // Return the argument value if it exists.
137 bool GetArgAsValue(const std::string& name, 137 bool GetArgAsValue(const std::string& name,
138 scoped_ptr<base::Value>* arg) const; 138 std::unique_ptr<base::Value>* arg) const;
139 139
140 // Check if argument exists and is string. 140 // Check if argument exists and is string.
141 bool HasStringArg(const std::string& name) const; 141 bool HasStringArg(const std::string& name) const;
142 // Check if argument exists and is number (double, int or bool). 142 // Check if argument exists and is number (double, int or bool).
143 bool HasNumberArg(const std::string& name) const; 143 bool HasNumberArg(const std::string& name) const;
144 // Check if argument exists. 144 // Check if argument exists.
145 bool HasArg(const std::string& name) const; 145 bool HasArg(const std::string& name) const;
146 146
147 // Get known existing arguments as specific types. 147 // Get known existing arguments as specific types.
148 // Useful when you have already queried the argument with 148 // Useful when you have already queried the argument with
149 // Query(HAS_NUMBER_ARG) or Query(HAS_STRING_ARG). 149 // Query(HAS_NUMBER_ARG) or Query(HAS_STRING_ARG).
150 std::string GetKnownArgAsString(const std::string& name) const; 150 std::string GetKnownArgAsString(const std::string& name) const;
151 double GetKnownArgAsDouble(const std::string& name) const; 151 double GetKnownArgAsDouble(const std::string& name) const;
152 int GetKnownArgAsInt(const std::string& name) const; 152 int GetKnownArgAsInt(const std::string& name) const;
153 bool GetKnownArgAsBool(const std::string& name) const; 153 bool GetKnownArgAsBool(const std::string& name) const;
154 scoped_ptr<base::Value> GetKnownArgAsValue(const std::string& name) const; 154 std::unique_ptr<base::Value> GetKnownArgAsValue(
155 const std::string& name) const;
155 156
156 // Process ID and Thread ID. 157 // Process ID and Thread ID.
157 ProcessThreadID thread; 158 ProcessThreadID thread;
158 159
159 // Time since epoch in microseconds. 160 // Time since epoch in microseconds.
160 // Stored as double to match its JSON representation. 161 // Stored as double to match its JSON representation.
161 double timestamp; 162 double timestamp;
162 double duration; 163 double duration;
163 char phase; 164 char phase;
164 std::string category; 165 std::string category;
165 std::string name; 166 std::string name;
166 std::string id; 167 std::string id;
167 168
168 // All numbers and bool values from TraceEvent args are cast to double. 169 // All numbers and bool values from TraceEvent args are cast to double.
169 // bool becomes 1.0 (true) or 0.0 (false). 170 // bool becomes 1.0 (true) or 0.0 (false).
170 std::map<std::string, double> arg_numbers; 171 std::map<std::string, double> arg_numbers;
171 std::map<std::string, std::string> arg_strings; 172 std::map<std::string, std::string> arg_strings;
172 std::map<std::string, scoped_ptr<base::Value>> arg_values; 173 std::map<std::string, std::unique_ptr<base::Value>> arg_values;
173 174
174 // The other event associated with this event (or NULL). 175 // The other event associated with this event (or NULL).
175 const TraceEvent* other_event; 176 const TraceEvent* other_event;
176 }; 177 };
177 178
178 typedef std::vector<const TraceEvent*> TraceEventVector; 179 typedef std::vector<const TraceEvent*> TraceEventVector;
179 180
180 class Query { 181 class Query {
181 public: 182 public:
182 Query(const Query& query); 183 Query(const Query& query);
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 706
706 // Count all matches. 707 // Count all matches.
707 static inline size_t CountMatches(const TraceEventVector& events, 708 static inline size_t CountMatches(const TraceEventVector& events,
708 const Query& query) { 709 const Query& query) {
709 return CountMatches(events, query, 0u, events.size()); 710 return CountMatches(events, query, 0u, events.size());
710 } 711 }
711 712
712 } // namespace trace_analyzer 713 } // namespace trace_analyzer
713 714
714 #endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_ 715 #endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_
OLDNEW
« no previous file with comments | « base/test/test_support_ios.mm ('k') | base/test/trace_event_analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698