Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4311)

Unified Diff: chrome/profiling/allocation_tracker.h

Issue 2943733002: Add out-of-process memory logging stream parsing. (Closed)
Patch Set: Add TODO Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/profiling/address.h ('k') | chrome/profiling/allocation_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5aa8ea4718f01e4f60b4a70f8758c94c1185a147
--- /dev/null
+++ b/chrome/profiling/allocation_tracker.h
@@ -0,0 +1,52 @@
+// 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/backtrace_storage.h"
+#include "chrome/profiling/memlog_receiver.h"
+
+namespace profiling {
+
+// Tracks live allocations in one process. This is an analogue to memory-infra
+// allocation register and needs to be merged/deduped.
+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,
+ std::vector<Address>&& bt) override;
+ void OnFree(const FreePacket& free_packet) override;
+ void OnComplete() override;
+
+ private:
+ CompleteCallback complete_callback_;
+
+ struct Alloc {
+ Alloc(size_t sz, BacktraceStorage::Key key);
+
+ size_t size;
+ BacktraceStorage::Key backtrace_key;
+ };
+
+ // Cached pointer to the global singleton.
+ BacktraceStorage* backtrace_storage_;
+
+ std::map<Address, Alloc> live_allocs_;
+
+ DISALLOW_COPY_AND_ASSIGN(AllocationTracker);
+};
+
+} // namespace profiling
+
+#endif // CHROME_PROFILING_ALLOCATION_TRACKER_H_
« no previous file with comments | « chrome/profiling/address.h ('k') | chrome/profiling/allocation_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698