Index: base/allocator/allocated_type_profiler_tcmalloc.cc |
diff --git a/base/allocator/allocated_type_profiler_tcmalloc.cc b/base/allocator/allocated_type_profiler_tcmalloc.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..12515d7fd5f0e88934752e7fd9154be8ba915130 |
--- /dev/null |
+++ b/base/allocator/allocated_type_profiler_tcmalloc.cc |
@@ -0,0 +1,42 @@ |
+// Copyright 2012 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. |
+ |
+#include "base/allocator/allocated_type_profiler_tcmalloc.h" |
+ |
+#if defined(PROFILING_ALLOCATED_TYPE) |
+ |
+#include <gperftools/allocated_type_map.h> |
+#include <gperftools/heap-profiler.h> |
+ |
+#include "base/allocator/allocated_type_profiler_control.h" |
+ |
+namespace base { |
+namespace allocated_type { |
+ |
+void* NewInterceptForTCMalloc(void* ptr, |
+ size_t size, |
+ const std::type_info& type) { |
+ if (base::allocated_type::IsProfilingAllocatedType()) { |
jar (doing other things)
2012/08/23 19:55:25
nit: no need to qualify the namespace here.
Dai Mikurube (NOT FULLTIME)
2012/08/24 02:47:27
Done.
|
+ if (IsHeapProfilerRunning()) { |
jar (doing other things)
2012/08/23 19:55:25
nit: consider use of && to combine if statements.
Dai Mikurube (NOT FULLTIME)
2012/08/24 02:47:27
Done.
|
+ InsertAllocatedType(ptr, size, type); |
+ } |
+ } |
+ return ptr; |
+} |
+ |
+void* DeleteInterceptForTCMalloc(void* ptr, |
+ size_t size, |
+ const std::type_info& type) { |
+ if (base::allocated_type::IsProfilingAllocatedType()) { |
+ if (IsHeapProfilerRunning()) { |
+ EraseAllocatedType(ptr); |
+ } |
+ } |
+ return ptr; |
+} |
+ |
+} // namespace allocated_type |
+} // namespace base |
+ |
+#endif // defined(PROFILING_ALLOCATED_TYPE) |