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

Unified Diff: base/trace_event/heap_profiler_allocation_register.h

Issue 2797603002: heap-profiler: Clean up some comments and C++. (Closed)
Patch Set: Enum are great Created 3 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
« no previous file with comments | « no previous file | base/trace_event/heap_profiler_allocation_register.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/heap_profiler_allocation_register.h
diff --git a/base/trace_event/heap_profiler_allocation_register.h b/base/trace_event/heap_profiler_allocation_register.h
index 6d63923f4c164e7a51a2eaf6686d94a87de1f4a9..ac9872f001c218e7e82262d3522ce6c012a2770f 100644
--- a/base/trace_event/heap_profiler_allocation_register.h
+++ b/base/trace_event/heap_profiler_allocation_register.h
@@ -52,7 +52,7 @@ class FixedHashMap {
// Capacity controls how many items this hash map can hold, and largely
// affects memory footprint.
- FixedHashMap(size_t capacity)
+ explicit FixedHashMap(size_t capacity)
: num_cells_(capacity),
num_inserts_dropped_(0),
cells_(static_cast<Cell*>(
@@ -252,6 +252,8 @@ class TraceEventMemoryOverhead;
// freed. Internally it has two hashtables: one for Backtraces and one for
// actual allocations. Sizes of both hashtables are fixed, and this class
// allocates (mmaps) only in its constructor.
+//
+// When either hash table hits max size, new inserts are dropped.
class BASE_EXPORT AllocationRegister {
public:
// Details about an allocation.
@@ -366,8 +368,13 @@ class BASE_EXPORT AllocationRegister {
AllocationMap allocations_;
BacktraceMap backtraces_;
- // Sentinel used when we run out of backtraces_ storage.
- BacktraceMap::KVIndex out_of_storage_backtrace_index_;
+ // Sentinel used when the |backtraces_| table is full.
+ //
+ // This is a slightly abstraction to allow for constant propagation. It
+ // knows that the sentinel will be the first item inserted into the table
+ // and that the first index retuned will be 0. The constructor DCHECKs
+ // this assumption.
+ enum : BacktraceMap::KVIndex { kOutOfStorageBacktraceIndex = 0 };
DISALLOW_COPY_AND_ASSIGN(AllocationRegister);
};
« no previous file with comments | « no previous file | base/trace_event/heap_profiler_allocation_register.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698