tp: Add TrackTracker::InternCounterTrack()
Change-Id: I8d779c4837884ce24d89ce6fcf86a4c728c1c60b
diff --git a/src/trace_processor/importers/common/track_tracker.cc b/src/trace_processor/importers/common/track_tracker.cc
index 2386453..85313ed 100644
--- a/src/trace_processor/importers/common/track_tracker.cc
+++ b/src/trace_processor/importers/common/track_tracker.cc
@@ -257,6 +257,18 @@
return id;
}
+TrackId TrackTracker::InternCounterTrack(TrackClassification classification,
+ std::optional<Dimensions> dimensions,
+ StringId name) {
+ auto it = tracks_.Find({classification, dimensions});
+ if (it)
+ return *it;
+
+ TrackId id = CreateCounterTrack(classification, dimensions, name);
+ tracks_[{classification, dimensions}] = id;
+ return id;
+}
+
TrackId TrackTracker::InternProcessTrack(TrackClassification classification,
UniquePid upid,
std::optional<Dimensions> dims,
diff --git a/src/trace_processor/importers/common/track_tracker.h b/src/trace_processor/importers/common/track_tracker.h
index a2bd592..0986929 100644
--- a/src/trace_processor/importers/common/track_tracker.h
+++ b/src/trace_processor/importers/common/track_tracker.h
@@ -213,6 +213,12 @@
std::optional<Dimensions>,
StringId name);
+ // Interns counter track into TrackTable. If the track created with below
+ // arguments already exists, returns the TrackTable::Id of the track.
+ TrackId InternCounterTrack(TrackClassification,
+ std::optional<Dimensions>,
+ StringId name);
+
// Interns a unique track into the storage.
TrackId InternGlobalTrack(TrackClassification);