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

Unified Diff: base/test/trace_event_analyzer.h

Issue 8438058: Clean up some API in trace_event_analyzer.h and add some getters. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added test for new APIs Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/test/trace_event_analyzer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/trace_event_analyzer.h
diff --git a/base/test/trace_event_analyzer.h b/base/test/trace_event_analyzer.h
index 4bf48845eb1dcd027fc0843b780a955b2b510dd2..577b1856df8ea4006117436374a0d297a733803c 100644
--- a/base/test/trace_event_analyzer.h
+++ b/base/test/trace_event_analyzer.h
@@ -123,14 +123,28 @@ struct TraceEvent {
bool has_other_event() const { return other_event; }
// Returns absolute duration in microseconds between this event and other
- // event. Returns false if has_other_event() is false.
- bool GetAbsTimeToOtherEvent(double* duration) const;
+ // event. Must have already verified that other_event exists by
+ // Query(EVENT_HAS_OTHER) or by calling has_other_event().
+ double GetAbsTimeToOtherEvent() const;
nduca 2011/11/03 19:05:53 What happens if you forget to do this? DCHECK or a
jbates 2011/11/03 19:34:39 The behavior is to crash when other_event doesn't
// Return the argument value if it exists and it is a string.
bool GetArgAsString(const std::string& name, std::string* arg) const;
// Return the argument value if it exists and it is a number.
bool GetArgAsNumber(const std::string& name, double* arg) const;
+ // Check if argument exists and is string.
+ bool HasStringArg(const std::string& name) const;
+ // Check if argument exists and is number (double, int or bool).
+ bool HasNumberArg(const std::string& name) const;
+
+ // Get known existing arguments as specific types.
+ // Useful when you have already queried the argument with
+ // Query(HAS_NUMBER_ARG) or Query(HAS_STRING_ARG).
+ std::string GetKnownArgAsString(const std::string& name) const;
+ double GetKnownArgAsDouble(const std::string& name) const;
+ int GetKnownArgAsInt(const std::string& name) const;
+ bool GetKnownArgAsBool(const std::string& name) const;
+
nduca 2011/11/03 19:05:53 I guess by moving to this CL, I didn't get your re
jbates 2011/11/03 19:34:39 What I realized (tried to explain it in the commen
// Process ID and Thread ID.
ProcessThreadID thread;
@@ -155,7 +169,7 @@ struct TraceEvent {
};
// Pass these values to Query to compare with the corresponding member of a
-// TraceEvent.
+// TraceEvent. Unless otherwise specfied, the usage is Query(ENUM_MEMBER).
enum TraceEventMember {
EVENT_INVALID,
// Use these to access the event members:
@@ -169,20 +183,39 @@ enum TraceEventMember {
EVENT_PHASE,
EVENT_CATEGORY,
EVENT_NAME,
- EVENT_HAS_ARG,
+
+ // Evaluates to true if arg exists and is a string.
+ // Usage: Query(EVENT_HAS_STRING_ARG, "arg_name")
+ EVENT_HAS_STRING_ARG,
+ // Evaluates to true if arg exists and is a number.
+ // Number arguments include types double, int and bool.
+ // Usage: Query(EVENT_HAS_NUMBER_ARG, "arg_name")
+ EVENT_HAS_NUMBER_ARG,
+ // Evaluates to arg value (string or number).
+ // Usage: Query(EVENT_ARG, "arg_name")
EVENT_ARG,
// Return true if associated event exists.
// (Typically BEGIN for END or END for BEGIN).
EVENT_HAS_OTHER,
- // Use these to access the associated event's members:
+
+ // Access the associated other_event's members:
OTHER_PID,
OTHER_TID,
OTHER_TIME,
OTHER_PHASE,
OTHER_CATEGORY,
OTHER_NAME,
- OTHER_HAS_ARG,
- OTHER_ARG
+
+ // Evaluates to true if arg exists and is a string.
+ // Usage: Query(EVENT_HAS_STRING_ARG, "arg_name")
+ OTHER_HAS_STRING_ARG,
+ // Evaluates to true if arg exists and is a number.
+ // Number arguments include types double, int and bool.
+ // Usage: Query(EVENT_HAS_NUMBER_ARG, "arg_name")
+ OTHER_HAS_NUMBER_ARG,
+ // Evaluates to arg value (string or number).
+ // Usage: Query(EVENT_ARG, "arg_name")
+ OTHER_ARG,
};
class Query {
« no previous file with comments | « no previous file | base/test/trace_event_analyzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698