| Index: chrome/profiling/allocation_tracker.h
|
| diff --git a/chrome/profiling/allocation_tracker.h b/chrome/profiling/allocation_tracker.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..337a999bdbbbc2e933cf7e0e48e315834e0d423b
|
| --- /dev/null
|
| +++ b/chrome/profiling/allocation_tracker.h
|
| @@ -0,0 +1,50 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CHROME_PROFILING_ALLOCATION_TRACKER_H_
|
| +#define CHROME_PROFILING_ALLOCATION_TRACKER_H_
|
| +
|
| +#include <map>
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/macros.h"
|
| +#include "chrome/profiling/memlog_receiver.h"
|
| +#include "chrome/profiling/stack_storage.h"
|
| +
|
| +namespace profiling {
|
| +
|
| +// Tracks live allocations in one process.
|
| +class AllocationTracker : public MemlogReceiver {
|
| + public:
|
| + using CompleteCallback = base::OnceClosure;
|
| +
|
| + explicit AllocationTracker(CompleteCallback complete_cb);
|
| + ~AllocationTracker() override;
|
| +
|
| + void OnHeader(const StreamHeader& header) override;
|
| + void OnAlloc(const AllocPacket& alloc_packet, Stack&& stack) override;
|
| + void OnFree(const FreePacket& free_packet) override;
|
| + void OnComplete() override;
|
| +
|
| + private:
|
| + CompleteCallback complete_callback_;
|
| +
|
| + struct Alloc {
|
| + Alloc(size_t sz, StackStorage::Key key);
|
| +
|
| + size_t size;
|
| + StackStorage::Key stack_key;
|
| + };
|
| +
|
| + // Cached pointer to the global singleton.
|
| + StackStorage* stack_storage_;
|
| +
|
| + std::map<Address, Alloc> live_allocs_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AllocationTracker);
|
| +};
|
| +
|
| +} // namespace profiling
|
| +
|
| +#endif // CHROME_PROFILING_ALLOCATION_TRACKER_H_
|
|
|