| 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::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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 // TraceAnalyzer helps tests search for trace events. | 566 // TraceAnalyzer helps tests search for trace events. |
| 567 class TraceAnalyzer { | 567 class TraceAnalyzer { |
| 568 public: | 568 public: |
| 569 ~TraceAnalyzer(); | 569 ~TraceAnalyzer(); |
| 570 | 570 |
| 571 // Use trace events from JSON string generated by tracing API. | 571 // Use trace events from JSON string generated by tracing API. |
| 572 // Returns non-NULL if the JSON is successfully parsed. | 572 // Returns non-NULL if the JSON is successfully parsed. |
| 573 static TraceAnalyzer* Create(const std::string& json_events) | 573 static TraceAnalyzer* Create(const std::string& json_events) |
| 574 WARN_UNUSED_RESULT; | 574 WARN_UNUSED_RESULT; |
| 575 | 575 |
| 576 void SetIgnoreMetadataEvents(bool ignore) { ignore_metadata_events_ = true; } | 576 void SetIgnoreMetadataEvents(bool ignore) { |
| 577 ignore_metadata_events_ = ignore; |
| 578 } |
| 577 | 579 |
| 578 // Associate BEGIN and END events with each other. This allows Query(OTHER_*) | 580 // Associate BEGIN and END events with each other. This allows Query(OTHER_*) |
| 579 // to access the associated event and enables Query(EVENT_DURATION). | 581 // to access the associated event and enables Query(EVENT_DURATION). |
| 580 // An end event will match the most recent begin event with the same name, | 582 // An end event will match the most recent begin event with the same name, |
| 581 // category, process ID and thread ID. This matches what is shown in | 583 // category, process ID and thread ID. This matches what is shown in |
| 582 // about:tracing. After association, the BEGIN event will point to the | 584 // about:tracing. After association, the BEGIN event will point to the |
| 583 // matching END event, but the END event will not point to the BEGIN event. | 585 // matching END event, but the END event will not point to the BEGIN event. |
| 584 void AssociateBeginEndEvents(); | 586 void AssociateBeginEndEvents(); |
| 585 | 587 |
| 586 // Associate ASYNC_BEGIN, ASYNC_STEP and ASYNC_END events with each other. | 588 // Associate ASYNC_BEGIN, ASYNC_STEP and ASYNC_END events with each other. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 | 708 |
| 707 // Count all matches. | 709 // Count all matches. |
| 708 static inline size_t CountMatches(const TraceEventVector& events, | 710 static inline size_t CountMatches(const TraceEventVector& events, |
| 709 const Query& query) { | 711 const Query& query) { |
| 710 return CountMatches(events, query, 0u, events.size()); | 712 return CountMatches(events, query, 0u, events.size()); |
| 711 } | 713 } |
| 712 | 714 |
| 713 } // namespace trace_analyzer | 715 } // namespace trace_analyzer |
| 714 | 716 |
| 715 #endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_ | 717 #endif // BASE_TEST_TRACE_EVENT_ANALYZER_H_ |
| OLD | NEW |