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

Unified Diff: base/test/trace_event_analyzer.h

Issue 9187015: Remove usage of using namespace, and cleanup trace_analyzer namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile Created 8 years, 11 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 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 8f25cd8f2483b863e43ed2958d2f255f8ded9cf3..21444400c060aaf07cac525b89c4ca1be1cefac1 100644
--- a/base/test/trace_event_analyzer.h
+++ b/base/test/trace_event_analyzer.h
@@ -172,70 +172,15 @@ struct TraceEvent {
typedef std::vector<const TraceEvent*> TraceEventVector;
-// Pass these values to Query to compare with the corresponding member of a
-// TraceEvent. Unless otherwise specfied, the usage is Query(ENUM_MEMBER).
-enum TraceEventMember {
- EVENT_INVALID,
- // Use these to access the event members:
- EVENT_PID,
- EVENT_TID,
- // Return the timestamp of the event in microseconds since epoch.
- EVENT_TIME,
- // Return the absolute time between event and other event in microseconds.
- // Only works for events with associated BEGIN/END: Query(EVENT_HAS_OTHER).
- EVENT_DURATION,
- EVENT_PHASE,
- EVENT_CATEGORY,
- EVENT_NAME,
- EVENT_ID,
-
- // 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,
-
- // Access the associated other_event's members:
- OTHER_PID,
- OTHER_TID,
- OTHER_TIME,
- OTHER_PHASE,
- OTHER_CATEGORY,
- OTHER_NAME,
- OTHER_ID,
-
- // 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 {
public:
- // Compare with the given member.
- Query(TraceEventMember member);
-
- // Compare with the given member argument value.
- Query(TraceEventMember member, const std::string& arg_name);
-
Query(const Query& query);
~Query();
+ ////////////////////////////////////////////////////////////////
+ // Query literal values
+
// Compare with the given string.
static Query String(const std::string& str);
@@ -254,6 +199,76 @@ class Query {
// Example: Query(EVENT_NAME) == Query::Pattern("MyEvent*")
static Query Pattern(const std::string& pattern);
+ ////////////////////////////////////////////////////////////////
+ // Query event members
+
+ static Query EventPid() { return Query(EVENT_PID); }
+
+ static Query EventTid() { return Query(EVENT_TID); }
+
+ // Return the timestamp of the event in microseconds since epoch.
+ static Query EventTime() { return Query(EVENT_TIME); }
+
+ // Return the absolute time between event and other event in microseconds.
+ // Only works if Query::EventHasOther() == true.
+ static Query EventDuration() { return Query(EVENT_DURATION); }
+
+ static Query EventPhase() { return Query(EVENT_PHASE); }
+
+ static Query EventCategory() { return Query(EVENT_CATEGORY); }
+
+ static Query EventName() { return Query(EVENT_NAME); }
+
+ static Query EventId() { return Query(EVENT_ID); }
+
+ // Evaluates to true if arg exists and is a string.
+ static Query EventHasStringArg(const std::string& arg_name) {
+ return Query(EVENT_HAS_STRING_ARG, arg_name);
+ }
+
+ // Evaluates to true if arg exists and is a number.
+ // Number arguments include types double, int and bool.
+ static Query EventHasNumberArg(const std::string& arg_name) {
+ return Query(EVENT_HAS_NUMBER_ARG, arg_name);
+ }
+
+ // Evaluates to arg value (string or number).
+ static Query EventArg(const std::string& arg_name) {
+ return Query(EVENT_ARG, arg_name);
+ }
+
+ // Return true if associated event exists.
+ static Query EventHasOther() { return Query(EVENT_HAS_OTHER); }
+
+ // Access the associated other_event's members:
+
+ static Query OtherPid() { return Query(OTHER_PID); }
+
+ static Query OtherTid() { return Query(OTHER_TID); }
+
+ static Query OtherTime() { return Query(OTHER_TIME); }
+
+ static Query OtherPhase() { return Query(OTHER_PHASE); }
+
+ static Query OtherCategory() { return Query(OTHER_CATEGORY); }
+
+ static Query OtherName() { return Query(OTHER_NAME); }
+
+ static Query OtherId() { return Query(OTHER_ID); }
+
+ static Query OtherHasStringArg(const std::string& arg_name) {
+ return Query(OTHER_HAS_STRING_ARG, arg_name);
+ }
+
+ static Query OtherHasNumberArg(const std::string& arg_name) {
+ return Query(OTHER_HAS_NUMBER_ARG, arg_name);
+ }
+
+ static Query OtherArg(const std::string& arg_name) {
+ return Query(OTHER_ARG, arg_name);
+ }
+
+ ////////////////////////////////////////////////////////////////
// Common queries:
// Find BEGIN events that have a corresponding END event.
@@ -285,6 +300,9 @@ class Query {
(Query(EVENT_TID) != Query(OTHER_TID));
}
+ ////////////////////////////////////////////////////////////////
+ // Operators:
+
// Boolean operators:
Query operator==(const Query& rhs) const;
Query operator!=(const Query& rhs) const;
@@ -311,6 +329,32 @@ class Query {
bool Evaluate(const TraceEvent& event) const;
private:
+ enum TraceEventMember {
+ EVENT_INVALID,
+ EVENT_PID,
+ EVENT_TID,
+ EVENT_TIME,
+ EVENT_DURATION,
+ EVENT_PHASE,
+ EVENT_CATEGORY,
+ EVENT_NAME,
+ EVENT_ID,
+ EVENT_HAS_STRING_ARG,
+ EVENT_HAS_NUMBER_ARG,
+ EVENT_ARG,
+ EVENT_HAS_OTHER,
+ OTHER_PID,
+ OTHER_TID,
+ OTHER_TIME,
+ OTHER_PHASE,
+ OTHER_CATEGORY,
+ OTHER_NAME,
+ OTHER_ID,
+ OTHER_HAS_STRING_ARG,
+ OTHER_HAS_NUMBER_ARG,
+ OTHER_ARG,
+ };
+
enum Operator {
OP_INVALID,
// Boolean operators:
@@ -340,6 +384,12 @@ class Query {
QUERY_STRING
};
+ // Compare with the given member.
+ Query(TraceEventMember member);
+
+ // Compare with the given member argument value.
+ Query(TraceEventMember member, const std::string& arg_name);
+
// Compare with the given string.
Query(const std::string& str);
« 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