| 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/backtrace_storage.h" | 
|  | 13 #include "chrome/profiling/memlog_receiver.h" | 
|  | 14 | 
|  | 15 namespace profiling { | 
|  | 16 | 
|  | 17 // Tracks live allocations in one process. This is an analogue to memory-infra | 
|  | 18 // allocation register and needs to be merged/deduped. | 
|  | 19 class AllocationTracker : public MemlogReceiver { | 
|  | 20  public: | 
|  | 21   using CompleteCallback = base::OnceClosure; | 
|  | 22 | 
|  | 23   explicit AllocationTracker(CompleteCallback complete_cb); | 
|  | 24   ~AllocationTracker() override; | 
|  | 25 | 
|  | 26   void OnHeader(const StreamHeader& header) override; | 
|  | 27   void OnAlloc(const AllocPacket& alloc_packet, | 
|  | 28                std::vector<Address>&& bt) override; | 
|  | 29   void OnFree(const FreePacket& free_packet) override; | 
|  | 30   void OnComplete() override; | 
|  | 31 | 
|  | 32  private: | 
|  | 33   CompleteCallback complete_callback_; | 
|  | 34 | 
|  | 35   struct Alloc { | 
|  | 36     Alloc(size_t sz, BacktraceStorage::Key key); | 
|  | 37 | 
|  | 38     size_t size; | 
|  | 39     BacktraceStorage::Key backtrace_key; | 
|  | 40   }; | 
|  | 41 | 
|  | 42   // Cached pointer to the global singleton. | 
|  | 43   BacktraceStorage* backtrace_storage_; | 
|  | 44 | 
|  | 45   std::map<Address, Alloc> live_allocs_; | 
|  | 46 | 
|  | 47   DISALLOW_COPY_AND_ASSIGN(AllocationTracker); | 
|  | 48 }; | 
|  | 49 | 
|  | 50 }  // namespace profiling | 
|  | 51 | 
|  | 52 #endif  // CHROME_PROFILING_ALLOCATION_TRACKER_H_ | 
| OLD | NEW | 
|---|