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); |
}; |