OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "gpu/command_buffer/service/transfer_buffer_manager.h" | 5 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 #include <memory> | 10 #include <memory> |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 BufferMap::iterator it = registered_buffers_.find(id); | 104 BufferMap::iterator it = registered_buffers_.find(id); |
105 if (it == registered_buffers_.end()) | 105 if (it == registered_buffers_.end()) |
106 return NULL; | 106 return NULL; |
107 | 107 |
108 return it->second; | 108 return it->second; |
109 } | 109 } |
110 | 110 |
111 bool TransferBufferManager::OnMemoryDump( | 111 bool TransferBufferManager::OnMemoryDump( |
112 const base::trace_event::MemoryDumpArgs& args, | 112 const base::trace_event::MemoryDumpArgs& args, |
113 base::trace_event::ProcessMemoryDump* pmd) { | 113 base::trace_event::ProcessMemoryDump* pmd) { |
114 using base::trace_event::MemoryAllocatorDump; | |
115 using base::trace_event::MemoryDumpLevelOfDetail; | |
116 | |
117 if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) { | |
118 std::string dump_name = base::StringPrintf("gpu/transfer_memory/client_%d", | |
119 memory_tracker_->ClientId()); | |
120 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name); | |
121 dump->AddScalar(MemoryAllocatorDump::kNameSize, | |
122 MemoryAllocatorDump::kUnitsBytes, | |
123 shared_memory_bytes_allocated_); | |
124 | |
125 // Early out, no need for more detail in a BACKGROUND dump. | |
126 return true; | |
127 } | |
128 | |
129 for (const auto& buffer_entry : registered_buffers_) { | 114 for (const auto& buffer_entry : registered_buffers_) { |
130 int32_t buffer_id = buffer_entry.first; | 115 int32_t buffer_id = buffer_entry.first; |
131 const Buffer* buffer = buffer_entry.second.get(); | 116 const Buffer* buffer = buffer_entry.second.get(); |
132 std::string dump_name = | 117 std::string dump_name = |
133 base::StringPrintf("gpu/transfer_memory/client_%d/buffer_%d", | 118 base::StringPrintf("gpu/transfer_memory/client_%d/buffer_%d", |
134 memory_tracker_->ClientId(), buffer_id); | 119 memory_tracker_->ClientId(), buffer_id); |
135 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name); | 120 base::trace_event::MemoryAllocatorDump* dump = |
136 dump->AddScalar(MemoryAllocatorDump::kNameSize, | 121 pmd->CreateAllocatorDump(dump_name); |
137 MemoryAllocatorDump::kUnitsBytes, buffer->size()); | 122 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 123 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 124 buffer->size()); |
138 auto guid = | 125 auto guid = |
139 GetBufferGUIDForTracing(memory_tracker_->ClientTracingId(), buffer_id); | 126 GetBufferGUIDForTracing(memory_tracker_->ClientTracingId(), buffer_id); |
140 pmd->CreateSharedGlobalAllocatorDump(guid); | 127 pmd->CreateSharedGlobalAllocatorDump(guid); |
141 pmd->AddOwnershipEdge(dump->guid(), guid); | 128 pmd->AddOwnershipEdge(dump->guid(), guid); |
142 } | 129 } |
143 | 130 |
144 return true; | 131 return true; |
145 } | 132 } |
146 | 133 |
147 } // namespace gpu | 134 } // namespace gpu |
OLD | NEW |