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

Unified Diff: base/test/trace_event_analyzer.cc

Issue 10911268: Add some TraceAnalyzer utility methods to simplify test code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | « base/test/trace_event_analyzer.h ('k') | base/test/trace_event_analyzer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/trace_event_analyzer.cc
diff --git a/base/test/trace_event_analyzer.cc b/base/test/trace_event_analyzer.cc
index ad507252749579784f0b07407d0c70eb905d3a16..d4ebb042907540bd1e47ebcb77e548419d13bbca 100644
--- a/base/test/trace_event_analyzer.cc
+++ b/base/test/trace_event_analyzer.cc
@@ -694,8 +694,8 @@ bool TraceAnalyzer::SetEvents(const std::string& json_events) {
void TraceAnalyzer::AssociateBeginEndEvents() {
using trace_analyzer::Query;
- Query begin(Query::EventPhase() == Query::Phase(TRACE_EVENT_PHASE_BEGIN));
- Query end(Query::EventPhase() == Query::Phase(TRACE_EVENT_PHASE_END));
+ Query begin(Query::EventPhaseIs(TRACE_EVENT_PHASE_BEGIN));
+ Query end(Query::EventPhaseIs(TRACE_EVENT_PHASE_END));
Query match(Query::EventName() == Query::OtherName() &&
Query::EventCategory() == Query::OtherCategory() &&
Query::EventTid() == Query::OtherTid() &&
@@ -708,10 +708,10 @@ void TraceAnalyzer::AssociateAsyncBeginEndEvents() {
using trace_analyzer::Query;
Query begin(
- Query::EventPhase() == Query::Phase(TRACE_EVENT_PHASE_ASYNC_BEGIN) ||
- Query::EventPhase() == Query::Phase(TRACE_EVENT_PHASE_ASYNC_STEP));
- Query end(Query::EventPhase() == Query::Phase(TRACE_EVENT_PHASE_ASYNC_END) ||
- Query::EventPhase() == Query::Phase(TRACE_EVENT_PHASE_ASYNC_STEP));
+ Query::EventPhaseIs(TRACE_EVENT_PHASE_ASYNC_BEGIN) ||
+ Query::EventPhaseIs(TRACE_EVENT_PHASE_ASYNC_STEP));
+ Query end(Query::EventPhaseIs(TRACE_EVENT_PHASE_ASYNC_END) ||
+ Query::EventPhaseIs(TRACE_EVENT_PHASE_ASYNC_STEP));
Query match(Query::EventName() == Query::OtherName() &&
Query::EventCategory() == Query::OtherCategory() &&
Query::EventId() == Query::OtherId());
@@ -788,13 +788,20 @@ size_t TraceAnalyzer::FindEvents(const Query& query, TraceEventVector* output) {
return FindMatchingEvents(raw_events_, query, output);
}
-const TraceEvent* TraceAnalyzer::FindOneEvent(const Query& query) {
+const TraceEvent* TraceAnalyzer::FindFirstOf(const Query& query) {
TraceEventVector output;
if (FindEvents(query, &output) > 0)
return output.front();
return NULL;
}
+const TraceEvent* TraceAnalyzer::FindLastOf(const Query& query) {
+ TraceEventVector output;
+ if (FindEvents(query, &output) > 0)
+ return output.back();
+ return NULL;
+}
+
const std::string& TraceAnalyzer::GetThreadName(
const TraceEvent::ProcessThreadID& thread) {
// If thread is not found, just add and return empty string.
« no previous file with comments | « base/test/trace_event_analyzer.h ('k') | base/test/trace_event_analyzer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698