Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_PROFILING_ALLOCATION_TRACKER_H_ | |
| 6 #define CHROME_PROFILING_ALLOCATION_TRACKER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/callback.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "chrome/profiling/memlog_receiver.h" | |
| 13 #include "chrome/profiling/stack_storage.h" | |
| 14 | |
| 15 namespace profiling { | |
| 16 | |
| 17 // Tracks live allocations in one process. | |
|
awong
2017/06/19 20:00:13
Can you add a TODO() comment staying this is an an
| |
| 18 class AllocationTracker : public MemlogReceiver { | |
| 19 public: | |
| 20 using CompleteCallback = base::OnceClosure; | |
| 21 | |
| 22 explicit AllocationTracker(CompleteCallback complete_cb); | |
| 23 ~AllocationTracker() override; | |
| 24 | |
| 25 void OnHeader(const StreamHeader& header) override; | |
| 26 void OnAlloc(const AllocPacket& alloc_packet, Stack&& stack) override; | |
| 27 void OnFree(const FreePacket& free_packet) override; | |
| 28 void OnComplete() override; | |
| 29 | |
| 30 private: | |
| 31 CompleteCallback complete_callback_; | |
| 32 | |
| 33 struct Alloc { | |
| 34 Alloc(size_t sz, StackStorage::Key key); | |
| 35 | |
| 36 size_t size; | |
| 37 StackStorage::Key stack_key; | |
| 38 }; | |
| 39 | |
| 40 // Cached pointer to the global singleton. | |
| 41 StackStorage* stack_storage_; | |
| 42 | |
| 43 std::map<Address, Alloc> live_allocs_; | |
| 44 | |
| 45 DISALLOW_COPY_AND_ASSIGN(AllocationTracker); | |
| 46 }; | |
| 47 | |
| 48 } // namespace profiling | |
| 49 | |
| 50 #endif // CHROME_PROFILING_ALLOCATION_TRACKER_H_ | |
| OLD | NEW |