Index: base/debug/trace_memory.h |
diff --git a/base/debug/trace_memory.h b/base/debug/trace_memory.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7792e7aef31c4e5162663b9dad8a8e19fb07fcc2 |
--- /dev/null |
+++ b/base/debug/trace_memory.h |
@@ -0,0 +1,44 @@ |
+// Copyright 2013 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 BASE_DEBUG_TRACE_MEMORY_H_ |
+#define BASE_DEBUG_TRACE_MEMORY_H_ |
+ |
+#include "base/base_export.h" |
+ |
+namespace base { |
+ |
+class BASE_EXPORT ScopedTraceMemory { |
+ public: |
+ ScopedTraceMemory(const char* category); |
+ ~ScopedTraceMemory(); |
+ |
+ static int GetStackIndexForTest(); |
+}; |
+ |
+BASE_EXPORT void TraceMemoryStart(); |
+BASE_EXPORT void TraceMemoryDump(); |
+// Caller owns the char* and must release it with free(). |
+BASE_EXPORT char* TraceMemoryDumpAsString(); |
+BASE_EXPORT void TraceMemoryStop(); |
+ |
+} // namespace base |
+ |
+// Make local variables with unique names based on the line number. Note that |
+// the extra level of redirection is needed. |
+#define INTERNAL_TRACE_MEMORY_ID3(line) trace_memory_unique_##line |
+#define INTERNAL_TRACE_MEMORY_ID2(line) INTERNAL_TRACE_MEMORY_ID3(line) |
+#define INTERNAL_TRACE_MEMORY_ID INTERNAL_TRACE_MEMORY_ID2(__LINE__) |
+ |
+// Generates a unique local variable name. |
+// TODO(jamescook): Make it record both category and name. |
+#define TRACE_MEMORY(category, name) \ |
+ base::ScopedTraceMemory INTERNAL_TRACE_MEMORY_ID(name); |
+ |
+// A special trace name that allows us to ignore memory allocations inside |
+// the memory dump system itself. The allocations are recorded, but the |
+// visualizer skips them. Must match the value in heap.js. |
+#define TRACE_MEMORY_IGNORE "trace-memory-ignore" |
+ |
+#endif // BASE_DEBUG_TRACE_MEMORY_H_ |