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

Unified Diff: skia/ext/skia_memory_dump_provider.h

Issue 1780053003: DO NOT COMMIT: Heap profiler for Skia (sk_malloc) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « skia/ext/SkMemory_new_handler.cpp ('k') | skia/ext/skia_memory_dump_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
};
« no previous file with comments | « skia/ext/SkMemory_new_handler.cpp ('k') | skia/ext/skia_memory_dump_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698