| OLD | NEW | 
|    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::debug::TraceLog. |    9 // - Get trace events JSON string from base::debug::TraceLog. | 
|   10 // - Create TraceAnalyzer with JSON string. |   10 // - Create TraceAnalyzer with JSON string. | 
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  145   int GetKnownArgAsInt(const std::string& name) const; |  145   int GetKnownArgAsInt(const std::string& name) const; | 
|  146   bool GetKnownArgAsBool(const std::string& name) const; |  146   bool GetKnownArgAsBool(const std::string& name) const; | 
|  147  |  147  | 
|  148   // Process ID and Thread ID. |  148   // Process ID and Thread ID. | 
|  149   ProcessThreadID thread; |  149   ProcessThreadID thread; | 
|  150  |  150  | 
|  151   // Time since epoch in microseconds. |  151   // Time since epoch in microseconds. | 
|  152   // Stored as double to match its JSON representation. |  152   // Stored as double to match its JSON representation. | 
|  153   double timestamp; |  153   double timestamp; | 
|  154  |  154  | 
|  155   base::debug::TraceEventPhase phase; |  155   char phase; | 
|  156  |  156  | 
|  157   std::string category; |  157   std::string category; | 
|  158  |  158  | 
|  159   std::string name; |  159   std::string name; | 
|  160  |  160  | 
|  161   std::string id; |  161   std::string id; | 
|  162  |  162  | 
|  163   // All numbers and bool values from TraceEvent args are cast to double. |  163   // All numbers and bool values from TraceEvent args are cast to double. | 
|  164   // bool becomes 1.0 (true) or 0.0 (false). |  164   // bool becomes 1.0 (true) or 0.0 (false). | 
|  165   std::map<std::string, double> arg_numbers; |  165   std::map<std::string, double> arg_numbers; | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
|  186  |  186  | 
|  187   // Compare with the given number. |  187   // Compare with the given number. | 
|  188   static Query Double(double num); |  188   static Query Double(double num); | 
|  189   static Query Int(int32 num); |  189   static Query Int(int32 num); | 
|  190   static Query Uint(uint32 num); |  190   static Query Uint(uint32 num); | 
|  191  |  191  | 
|  192   // Compare with the given bool. |  192   // Compare with the given bool. | 
|  193   static Query Bool(bool boolean); |  193   static Query Bool(bool boolean); | 
|  194  |  194  | 
|  195   // Compare with the given phase. |  195   // Compare with the given phase. | 
|  196   static Query Phase(base::debug::TraceEventPhase phase); |  196   static Query Phase(char phase); | 
|  197  |  197  | 
|  198   // Compare with the given string pattern. Only works with == and != operators. |  198   // Compare with the given string pattern. Only works with == and != operators. | 
|  199   // Example: Query(EVENT_NAME) == Query::Pattern("MyEvent*") |  199   // Example: Query(EVENT_NAME) == Query::Pattern("MyEvent*") | 
|  200   static Query Pattern(const std::string& pattern); |  200   static Query Pattern(const std::string& pattern); | 
|  201  |  201  | 
|  202   //////////////////////////////////////////////////////////////// |  202   //////////////////////////////////////////////////////////////// | 
|  203   // Query event members |  203   // Query event members | 
|  204  |  204  | 
|  205   static Query EventPid() { return Query(EVENT_PID); } |  205   static Query EventPid() { return Query(EVENT_PID); } | 
|  206  |  206  | 
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  417   bool GetAsDouble(const TraceEvent& event, double* num) const; |  417   bool GetAsDouble(const TraceEvent& event, double* num) const; | 
|  418  |  418  | 
|  419   // Attempt to convert this Query to a string. On success, true is returned |  419   // Attempt to convert this Query to a string. On success, true is returned | 
|  420   // and the string value is stored in |str|. |  420   // and the string value is stored in |str|. | 
|  421   bool GetAsString(const TraceEvent& event, std::string* str) const; |  421   bool GetAsString(const TraceEvent& event, std::string* str) const; | 
|  422  |  422  | 
|  423   // Evaluate this Query as an arithmetic operator on left_ and right_. |  423   // Evaluate this Query as an arithmetic operator on left_ and right_. | 
|  424   bool EvaluateArithmeticOperator(const TraceEvent& event, |  424   bool EvaluateArithmeticOperator(const TraceEvent& event, | 
|  425                                   double* num) const; |  425                                   double* num) const; | 
|  426  |  426  | 
|  427   // For QUERY_EVENT_MEMBER Query: attempt to get the value of the Query. |  427   // For QUERY_EVENT_MEMBER Query: attempt to get the double value of the Query. | 
|  428   // The TraceValue will either be TRACE_TYPE_DOUBLE, TRACE_TYPE_STRING, |  428   bool GetMemberValueAsDouble(const TraceEvent& event, double* num) const; | 
|  429   // or if requested member does not exist, it will be TRACE_TYPE_UNDEFINED. |  429  | 
|  430   base::debug::TraceValue GetMemberValue(const TraceEvent& event) const; |  430   // For QUERY_EVENT_MEMBER Query: attempt to get the string value of the Query. | 
 |  431   bool GetMemberValueAsString(const TraceEvent& event, std::string* num) const; | 
|  431  |  432  | 
|  432   // Does this Query represent a value? |  433   // Does this Query represent a value? | 
|  433   bool is_value() const { return type_ != QUERY_BOOLEAN_OPERATOR; } |  434   bool is_value() const { return type_ != QUERY_BOOLEAN_OPERATOR; } | 
|  434  |  435  | 
|  435   bool is_unary_operator() const { |  436   bool is_unary_operator() const { | 
|  436     return operator_ == OP_NOT || operator_ == OP_NEGATE; |  437     return operator_ == OP_NOT || operator_ == OP_NEGATE; | 
|  437   } |  438   } | 
|  438  |  439  | 
|  439   bool is_comparison_operator() const { |  440   bool is_comparison_operator() const { | 
|  440     return operator_ != OP_INVALID && operator_ < OP_AND; |  441     return operator_ != OP_INVALID && operator_ < OP_AND; | 
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  590  |  591  | 
|  591 // Count all matches. |  592 // Count all matches. | 
|  592 static inline size_t CountMatches(const TraceEventVector& events, |  593 static inline size_t CountMatches(const TraceEventVector& events, | 
|  593                                   const Query& query) { |  594                                   const Query& query) { | 
|  594   return CountMatches(events, query, 0u, events.size()); |  595   return CountMatches(events, query, 0u, events.size()); | 
|  595 } |  596 } | 
|  596  |  597  | 
|  597 }  // namespace trace_analyzer |  598 }  // namespace trace_analyzer | 
|  598  |  599  | 
|  599 #endif  // BASE_TEST_TRACE_EVENT_ANALYZER_H_ |  600 #endif  // BASE_TEST_TRACE_EVENT_ANALYZER_H_ | 
| OLD | NEW |