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

Unified Diff: gpu/skia_runner/in_process_graphics_system.cc

Issue 1306243003: Add support to create memory allocator dump in base::DiscardableMemory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix html_viewer. Created 5 years, 4 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 | « content/common/host_discardable_shared_memory_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/skia_runner/in_process_graphics_system.cc
diff --git a/gpu/skia_runner/in_process_graphics_system.cc b/gpu/skia_runner/in_process_graphics_system.cc
index e5294b1777fb78580d12411640352d5016988893..c9f02e0659db0d800bde122b30d2757916a9255b 100644
--- a/gpu/skia_runner/in_process_graphics_system.cc
+++ b/gpu/skia_runner/in_process_graphics_system.cc
@@ -10,6 +10,9 @@
#include "base/memory/discardable_memory.h"
#include "base/memory/discardable_memory_allocator.h"
#include "base/thread_task_runner_handle.h"
+#include "base/trace_event/memory_allocator_dump.h"
+#include "base/trace_event/memory_dump_manager.h"
+#include "base/trace_event/process_memory_dump.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "gpu/command_buffer/client/gles2_lib.h"
#include "gpu/skia_bindings/gl_bindings_skia_cmd_buffer.h"
@@ -21,13 +24,30 @@ namespace {
// TODO(hendrikw): Replace TestDiscardableMemoryAllocator and move to base?
class NonDiscardableMemory : public base::DiscardableMemory {
public:
- explicit NonDiscardableMemory(size_t size) : data_(new uint8_t[size]) {}
+ explicit NonDiscardableMemory(size_t size)
+ : data_(new uint8_t[size]), size_(size) {}
bool Lock() override { return false; }
void Unlock() override {}
void* data() const override { return data_.get(); }
+ base::trace_event::MemoryAllocatorDump* CreateMemoryAllocatorDump(
+ const char* name,
+ base::trace_event::ProcessMemoryDump* pmd) const override {
+ base::trace_event::MemoryAllocatorDump* dump =
+ pmd->CreateAllocatorDump(name);
+ dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes, size_);
+
+ // Memory is allocated from system allocator (malloc).
+ pmd->AddSuballocation(dump->guid(),
+ base::trace_event::MemoryDumpManager::GetInstance()
+ ->system_allocator_pool_name());
+ return dump;
+ }
+
private:
scoped_ptr<uint8_t[]> data_;
+ size_t size_;
};
class NonDiscardableMemoryAllocator : public base::DiscardableMemoryAllocator {
« no previous file with comments | « content/common/host_discardable_shared_memory_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698