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

Side by Side Diff: components/metrics/leak_detector/ranked_set.h

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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef COMPONENTS_METRICS_LEAK_DETECTOR_RANKED_SET_H_ 5 #ifndef COMPONENTS_METRICS_LEAK_DETECTOR_RANKED_SET_H_
6 #define COMPONENTS_METRICS_LEAK_DETECTOR_RANKED_SET_H_ 6 #define COMPONENTS_METRICS_LEAK_DETECTOR_RANKED_SET_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <functional> // for std::less 10 #include <functional> // for std::less
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // 65 //
66 // Time complexity is O(log n). 66 // Time complexity is O(log n).
67 void Add(const ValueType& value, int count); 67 void Add(const ValueType& value, int count);
68 68
69 // Helper functions to directly add a size or call stack to the RankedSet. 69 // Helper functions to directly add a size or call stack to the RankedSet.
70 void AddSize(size_t size, int count) { Add(ValueType(size), count); } 70 void AddSize(size_t size, int count) { Add(ValueType(size), count); }
71 void AddCallStack(const CallStack* call_stack, int count) { 71 void AddCallStack(const CallStack* call_stack, int count) {
72 Add(ValueType(call_stack), count); 72 Add(ValueType(call_stack), count);
73 } 73 }
74 74
75 // Helper functions to directly search for an element with |value| equal to a
76 // particular size or call stack.
77 const_iterator FindSize(size_t size) const { return Find(ValueType(size)); }
78 const_iterator FindCallStack(const CallStack* call_stack) const {
79 return Find(ValueType(call_stack));
80 }
81
75 private: 82 private:
83 // Returns an iterator to the element in |entries_| with value=|value|, or to
84 // entries_.end() if it was not found.
85 const_iterator Find(const ValueType& value) const;
86
76 // Max and min counts. Returns 0 if the list is empty. 87 // Max and min counts. Returns 0 if the list is empty.
77 int max_count() const { 88 int max_count() const {
78 return entries_.empty() ? 0 : entries_.begin()->count; 89 return entries_.empty() ? 0 : entries_.begin()->count;
79 } 90 }
80 int min_count() const { 91 int min_count() const {
81 return entries_.empty() ? 0 : entries_.rbegin()->count; 92 return entries_.empty() ? 0 : entries_.rbegin()->count;
82 } 93 }
83 94
84 // Max number of items that can be stored in the list. 95 // Max number of items that can be stored in the list.
85 size_t max_size_; 96 size_t max_size_;
86 97
87 // Actual storage container for entries. 98 // Actual storage container for entries.
88 EntrySet entries_; 99 EntrySet entries_;
89 100
90 DISALLOW_COPY_AND_ASSIGN(RankedSet); 101 DISALLOW_COPY_AND_ASSIGN(RankedSet);
91 }; 102 };
92 103
93 } // namespace leak_detector 104 } // namespace leak_detector
94 } // namespace metrics 105 } // namespace metrics
95 106
96 #endif // COMPONENTS_METRICS_LEAK_DETECTOR_RANKED_SET_H_ 107 #endif // COMPONENTS_METRICS_LEAK_DETECTOR_RANKED_SET_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698