Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/common/host_shared_bitmap_manager.h" | 5 #include "content/common/host_shared_bitmap_manager.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/trace_event/process_memory_dump.h" | 10 #include "base/trace_event/process_memory_dump.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 | 148 |
| 149 return make_scoped_ptr(new HostSharedBitmap( | 149 return make_scoped_ptr(new HostSharedBitmap( |
| 150 static_cast<uint8*>(data->memory->memory()), data, id, nullptr)); | 150 static_cast<uint8*>(data->memory->memory()), data, id, nullptr)); |
| 151 } | 151 } |
| 152 | 152 |
| 153 bool HostSharedBitmapManager::OnMemoryDump( | 153 bool HostSharedBitmapManager::OnMemoryDump( |
| 154 base::trace_event::ProcessMemoryDump* pmd) { | 154 base::trace_event::ProcessMemoryDump* pmd) { |
| 155 base::AutoLock lock(lock_); | 155 base::AutoLock lock(lock_); |
| 156 | 156 |
| 157 for (const auto& bitmap : handle_map_) { | 157 for (const auto& bitmap : handle_map_) { |
| 158 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump( | 158 base::trace_event::MemoryAllocatorDump* dump = |
| 159 base::StringPrintf("%s/%s", kMemoryAllocatorName, | 159 pmd->CreateAllocatorDump(base::StringPrintf( |
| 160 base::HexEncode(bitmap.first.name, | 160 "%s/%s", kMemoryAllocatorName, |
|
reveman
2015/07/28 21:38:49
while here, can you remove the kMemoryAllocatorNam
ericrk
2015/07/29 18:46:46
Done.
| |
| 161 sizeof(bitmap.first.name)).c_str())); | 161 base::HexEncode(bitmap.first.name, sizeof(bitmap.first.name)) |
| 162 .c_str())); | |
| 162 if (!dump) | 163 if (!dump) |
| 163 return false; | 164 return false; |
| 164 | 165 |
| 165 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 166 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 166 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 167 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 167 bitmap.second->buffer_size); | 168 bitmap.second->buffer_size); |
| 169 | |
| 170 // Generate a global GUID used to share this allocation with the GPU | |
| 171 // process. | |
|
reveman
2015/07/28 21:38:49
not shared with GPU process. only shared with rend
ericrk
2015/07/29 18:46:46
yup, got a little to copy-pasty.
| |
| 172 auto guid = cc::GetSharedBitmapGUIDForTracing(bitmap.first); | |
| 173 pmd->CreateSharedGlobalAllocatorDump(guid); | |
| 174 pmd->AddOwnershipEdge(dump->guid(), guid); | |
| 168 } | 175 } |
| 169 | 176 |
| 170 return true; | 177 return true; |
| 171 } | 178 } |
| 172 | 179 |
| 173 void HostSharedBitmapManager::ChildAllocatedSharedBitmap( | 180 void HostSharedBitmapManager::ChildAllocatedSharedBitmap( |
| 174 size_t buffer_size, | 181 size_t buffer_size, |
| 175 const base::SharedMemoryHandle& handle, | 182 const base::SharedMemoryHandle& handle, |
| 176 base::ProcessHandle process_handle, | 183 base::ProcessHandle process_handle, |
| 177 const cc::SharedBitmapId& id) { | 184 const cc::SharedBitmapId& id) { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 return handle_map_.size(); | 241 return handle_map_.size(); |
| 235 } | 242 } |
| 236 | 243 |
| 237 void HostSharedBitmapManager::FreeSharedMemoryFromMap( | 244 void HostSharedBitmapManager::FreeSharedMemoryFromMap( |
| 238 const cc::SharedBitmapId& id) { | 245 const cc::SharedBitmapId& id) { |
| 239 base::AutoLock lock(lock_); | 246 base::AutoLock lock(lock_); |
| 240 handle_map_.erase(id); | 247 handle_map_.erase(id); |
| 241 } | 248 } |
| 242 | 249 |
| 243 } // namespace content | 250 } // namespace content |
| OLD | NEW |