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

Unified Diff: base/debug/trace_memory.h

Issue 15418002: Record Chrome trace events in tcmalloc heap profiles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: json output, but no green dots on trace Created 7 years, 7 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
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..760477b31920160f5548cd2e260d72e0e6d3ad5b
--- /dev/null
+++ b/base/debug/trace_memory.h
@@ -0,0 +1,39 @@
+// 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);
+
+#endif // BASE_DEBUG_TRACE_MEMORY_H_

Powered by Google App Engine
This is Rietveld 408576698