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

Unified Diff: components/metrics/leak_detector/ranked_set.cc

Issue 1870233003: Record call site history in LeakDetectorImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
Index: components/metrics/leak_detector/ranked_set.cc
diff --git a/components/metrics/leak_detector/ranked_set.cc b/components/metrics/leak_detector/ranked_set.cc
index 5725fb5c01c83cb6f2a0c456096402375c032355..d2cbd64e15d50deb17c60c60d96789f6330682c6 100644
--- a/components/metrics/leak_detector/ranked_set.cc
+++ b/components/metrics/leak_detector/ranked_set.cc
@@ -48,5 +48,17 @@ void RankedSet::Add(const ValueType& value, int count) {
entries_.erase(--entries_.end());
}
+RankedSet::const_iterator RankedSet::Find(const ValueType& value) const {
+ // Due to the unusual way the entries are stored, it is best to manually
+ // iterate through them until an entry with a matching value is found.
+ // e.g. std::find() would not work because it depends on exact matching by the
+ // whole Entry struct.
+ for (const_iterator iter = begin(); iter != end(); ++iter) {
+ if (iter->value == value)
+ return iter;
+ }
+ return end();
+}
+
} // namespace leak_detector
} // namespace metrics

Powered by Google App Engine
This is Rietveld 408576698