Chromium Code Reviews

Side by Side Diff: ui/gl/gl_image_shared_memory.cc

Issue 2535213002: [WIP] Add SharedMemoryTracker to dump base::SharedMemory usage
Patch Set: (wip) Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gl/gl_image_shared_memory.h" 5 #include "ui/gl/gl_image_shared_memory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/memory/shared_memory_tracker.h"
9 #include "base/numerics/safe_math.h" 10 #include "base/numerics/safe_math.h"
10 #include "base/process/process_handle.h" 11 #include "base/process/process_handle.h"
11 #include "base/sys_info.h" 12 #include "base/sys_info.h"
12 #include "base/trace_event/memory_allocator_dump.h" 13 #include "base/trace_event/memory_allocator_dump.h"
13 #include "base/trace_event/memory_dump_manager.h" 14 #include "base/trace_event/memory_dump_manager.h"
14 #include "base/trace_event/process_memory_dump.h" 15 #include "base/trace_event/process_memory_dump.h"
15 #include "ui/gfx/buffer_format_util.h" 16 #include "ui/gfx/buffer_format_util.h"
16 17
17 namespace gl { 18 namespace gl {
18 19
(...skipping 60 matching lines...)
79 if (shared_memory_) 80 if (shared_memory_)
80 size_in_bytes = stride() * GetSize().height(); 81 size_in_bytes = stride() * GetSize().height();
81 82
82 // Dump under "/shared_memory", as the base class may also dump to 83 // Dump under "/shared_memory", as the base class may also dump to
83 // "/texture_memory". 84 // "/texture_memory".
84 base::trace_event::MemoryAllocatorDump* dump = 85 base::trace_event::MemoryAllocatorDump* dump =
85 pmd->CreateAllocatorDump(dump_name + "/shared_memory"); 86 pmd->CreateAllocatorDump(dump_name + "/shared_memory");
86 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 87 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
87 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 88 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
88 static_cast<uint64_t>(size_in_bytes)); 89 static_cast<uint64_t>(size_in_bytes));
89 90 base::SharedMemoryTracker::AddOwnershipEdges(pmd, dump->guid(),
90 auto guid = GetGenericSharedMemoryGUIDForTracing(process_tracing_id, 91 shared_memory_->handle(),
91 shared_memory_id_); 92 shared_memory_->mapped_size());
92 pmd->CreateSharedGlobalAllocatorDump(guid);
93 pmd->AddOwnershipEdge(dump->guid(), guid);
94 } 93 }
95 94
96 } // namespace gl 95 } // namespace gl
OLDNEW

Powered by Google App Engine