Index: skia/ext/skia_memory_dump_provider.h |
diff --git a/skia/ext/skia_memory_dump_provider.h b/skia/ext/skia_memory_dump_provider.h |
index d9557d8b431b6da53a2cc56afd04050b3d685f24..3874a5a5db8ca8be06bd77ed5c8d02281dd324aa 100644 |
--- a/skia/ext/skia_memory_dump_provider.h |
+++ b/skia/ext/skia_memory_dump_provider.h |
@@ -7,11 +7,42 @@ |
#include "base/macros.h" |
#include "base/memory/singleton.h" |
+#include "base/trace_event/heap_profiler_allocation_register.h" |
#include "base/trace_event/memory_dump_provider.h" |
#include "third_party/skia/include/core/SkTypes.h" |
namespace skia { |
+class SkiaAllocHooks { |
+ public: |
+ typedef void AllocationHook(void* address, size_t size, |
+ const char* type_name); |
+ typedef void FreeHook(void* address); |
+ static void SetAllocationHook(AllocationHook* hook) { |
+ allocation_hook_ = hook; |
+ } |
+ static void SetFreeHook(FreeHook* hook) { |
+ free_hook_ = hook; |
+ } |
+ static void AllocationHookIfEnabled(void* address, size_t size, |
+ const char* type_name) { |
+ AllocationHook* allocation_hook = allocation_hook_; |
+ if (UNLIKELY(allocation_hook != nullptr)) { |
+ allocation_hook(address, size, type_name); |
+ } |
+ } |
+ static void FreeHookIfEnabled(void* address) { |
+ FreeHook* free_hook = free_hook_; |
+ if (UNLIKELY(free_hook != nullptr)) { |
+ free_hook(address); |
+ } |
+ } |
+ |
+ private: |
+ static AllocationHook* allocation_hook_; |
+ static FreeHook* free_hook_; |
+}; |
+ |
class SK_API SkiaMemoryDumpProvider |
: public base::trace_event::MemoryDumpProvider { |
public: |
@@ -21,6 +52,10 @@ class SK_API SkiaMemoryDumpProvider |
bool OnMemoryDump( |
const base::trace_event::MemoryDumpArgs& args, |
base::trace_event::ProcessMemoryDump* process_memory_dump) override; |
+ void OnHeapProfilingEnabled(bool enabled) override; |
+ |
+ void Insert(void* address, size_t size, const char* type_name); |
+ void Remove(void* address); |
private: |
friend struct base::DefaultSingletonTraits<SkiaMemoryDumpProvider>; |
@@ -28,6 +63,10 @@ class SK_API SkiaMemoryDumpProvider |
SkiaMemoryDumpProvider(); |
~SkiaMemoryDumpProvider() override; |
+ base::Lock lock_; |
+ scoped_ptr<base::trace_event::AllocationRegister> allocation_register_; |
+ bool is_heap_profiling_enabled_; |
+ |
DISALLOW_COPY_AND_ASSIGN(SkiaMemoryDumpProvider); |
}; |