OLD | NEW |
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 #include "ui/gfx/gpu_memory_buffer_tracing.h" | 17 #include "ui/gfx/gpu_memory_buffer_tracing.h" |
17 | 18 |
18 namespace gl { | 19 namespace gl { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 size_in_bytes = stride() * GetSize().height(); | 82 size_in_bytes = stride() * GetSize().height(); |
82 | 83 |
83 // Dump under "/shared_memory", as the base class may also dump to | 84 // Dump under "/shared_memory", as the base class may also dump to |
84 // "/texture_memory". | 85 // "/texture_memory". |
85 base::trace_event::MemoryAllocatorDump* dump = | 86 base::trace_event::MemoryAllocatorDump* dump = |
86 pmd->CreateAllocatorDump(dump_name + "/shared_memory"); | 87 pmd->CreateAllocatorDump(dump_name + "/shared_memory"); |
87 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 88 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
88 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 89 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
89 static_cast<uint64_t>(size_in_bytes)); | 90 static_cast<uint64_t>(size_in_bytes)); |
90 | 91 |
91 auto guid = | 92 if (shared_memory_) { |
92 gfx::GetSharedMemoryGUIDForTracing(process_tracing_id, shared_memory_id_); | 93 auto name = shared_memory_->handle().GetGUIDNameForTracing(); |
93 pmd->CreateSharedGlobalAllocatorDump(guid); | 94 // The same dump name might be already created on single-process mode. |
94 pmd->AddOwnershipEdge(dump->guid(), guid); | 95 base::trace_event::MemoryAllocatorDump* local = |
| 96 pmd->GetOrCreateAllocatorDump(name); |
| 97 pmd->CreateSharedGlobalAllocatorDump(local->guid()); |
| 98 pmd->AddOwnershipEdge(dump->guid(), local->guid()); |
| 99 } else { |
| 100 auto guid = gfx::GetSharedMemoryGUIDForTracing(process_tracing_id, |
| 101 shared_memory_id_); |
| 102 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 103 pmd->AddOwnershipEdge(dump->guid(), guid); |
| 104 } |
95 } | 105 } |
96 | 106 |
97 } // namespace gl | 107 } // namespace gl |
OLD | NEW |