Chromium Code Reviews| Index: base/trace_event/heap_profiler_allocation_context_tracker.h |
| diff --git a/base/trace_event/heap_profiler_allocation_context_tracker.h b/base/trace_event/heap_profiler_allocation_context_tracker.h |
| index 9c9a3132abab1e395a94d5632dc253845f43efa4..83912ce3cc232434fa2c937d9e21a958152b9c61 100644 |
| --- a/base/trace_event/heap_profiler_allocation_context_tracker.h |
| +++ b/base/trace_event/heap_profiler_allocation_context_tracker.h |
| @@ -23,11 +23,23 @@ namespace trace_event { |
| // details. |
| class BASE_EXPORT AllocationContextTracker { |
| public: |
| + enum InitializationState { kNotInitialized = 0, kInitializing, kInitialized }; |
| + |
| // Globally enables capturing allocation context. |
| // TODO(ruuda): Should this be replaced by |EnableCapturing| in the future? |
| // Or at least have something that guards agains enable -> disable -> enable? |
| static void SetCaptureEnabled(bool enabled); |
| + // Exposes the initialization state of the tracker. This is to avoid |
| + // re-entrancy in the malloc heap profiler, that will lazy initialize the |
|
petrcermak
2016/03/11 11:09:23
nit: s/that/which/ (you can't have "that" after a
petrcermak
2016/03/11 11:09:23
nit: s/lazy/lazily/
Primiano Tucci (use gerrit)
2016/03/11 13:57:57
Done.
Primiano Tucci (use gerrit)
2016/03/11 13:57:57
Done.
|
| + // thread-local context trackes on the first malloc seen, causing a nested |
|
petrcermak
2016/03/11 11:09:23
s/trackes/trackers/
petrcermak
2016/03/11 11:09:23
supernit: wouldn't "first encountered malloc" read
Primiano Tucci (use gerrit)
2016/03/11 13:57:57
Done.
Primiano Tucci (use gerrit)
2016/03/11 13:57:57
actually was "tracker" , just typoed r/s
|
| + // allocation. |
| + static InitializationState GetStateForCurrentThread(); |
| + |
| + // Enforces the initialization of the tracker. Subsequent calls to the other |
| + // methods of this class are supposed to not cause any further malloc/new. |
| + static AllocationContextTracker* InitializeForCurrentThread(); |
| + |
| // Returns whether capturing allocation context is enabled globally. |
| inline static bool capture_enabled() { |
| // A little lag after heap profiling is enabled or disabled is fine, it is |