Chromium Code Reviews| 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 "content/browser/gpu/browser_gpu_memory_buffer_manager.h" | 5 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h" |
| 6 | 6 |
| 7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 DCHECK(valid_size); | 287 DCHECK(valid_size); |
| 288 | 288 |
| 289 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 289 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 290 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 290 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 291 buffer_size_in_bytes); | 291 buffer_size_in_bytes); |
| 292 | 292 |
| 293 // Create the cross-process ownership edge. If the client creates a | 293 // Create the cross-process ownership edge. If the client creates a |
| 294 // corresponding dump for the same buffer, this will avoid to | 294 // corresponding dump for the same buffer, this will avoid to |
| 295 // double-count them in tracing. If, instead, no other process will emit a | 295 // double-count them in tracing. If, instead, no other process will emit a |
| 296 // dump with the same guid, the segment will be accounted to the browser. | 296 // dump with the same guid, the segment will be accounted to the browser. |
| 297 const uint64 client_tracing_process_id = base::trace_event:: | 297 uint64 client_tracing_process_id = ClientIdToTracingProcessId(client_id); |
| 298 MemoryDumpManager::ChildProcessIdToTracingProcessId(client_id); | 298 |
| 299 base::trace_event::MemoryAllocatorDumpGuid shared_buffer_guid = | 299 base::trace_event::MemoryAllocatorDumpGuid shared_buffer_guid = |
| 300 gfx::GetGpuMemoryBufferGUIDForTracing(client_tracing_process_id, | 300 gfx::GetGpuMemoryBufferGUIDForTracing(client_tracing_process_id, |
| 301 buffer_id); | 301 buffer_id); |
| 302 pmd->CreateSharedGlobalAllocatorDump(shared_buffer_guid); | 302 pmd->CreateSharedGlobalAllocatorDump(shared_buffer_guid); |
| 303 pmd->AddOwnershipEdge(dump->guid(), shared_buffer_guid); | 303 pmd->AddOwnershipEdge(dump->guid(), shared_buffer_guid); |
| 304 } | 304 } |
| 305 } | 305 } |
| 306 | 306 |
| 307 return true; | 307 return true; |
| 308 } | 308 } |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 return; | 583 return; |
| 584 } | 584 } |
| 585 | 585 |
| 586 GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id); | 586 GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id); |
| 587 if (host) | 587 if (host) |
| 588 host->DestroyGpuMemoryBuffer(id, client_id, sync_point); | 588 host->DestroyGpuMemoryBuffer(id, client_id, sync_point); |
| 589 | 589 |
| 590 buffers.erase(buffer_it); | 590 buffers.erase(buffer_it); |
| 591 } | 591 } |
| 592 | 592 |
| 593 uint64_t BrowserGpuMemoryBufferManager::ClientIdToTracingProcessId( | |
| 594 int client_id) const { | |
| 595 if (client_id == gpu_client_id_) { | |
| 596 // The browser process doesn't use a client ID to generate its tracing ID. | |
| 597 // Instead it uses a fixed tracing ID. If |client_id| == |gpu_client_id_|, | |
| 598 // then this surface is owned by the browser, so get our current tracing ID. | |
| 599 return base::trace_event::MemoryDumpManager::GetInstance() | |
| 600 ->tracing_process_id(); | |
|
reveman
2015/07/29 19:41:19
nit: Please add a "const int gpu_client_tracing_id
ericrk
2015/07/29 21:37:46
good point. done.
| |
| 601 } else { | |
|
reveman
2015/07/29 19:41:19
nit: maybe skip this else statement as you return
ericrk
2015/07/29 21:37:46
Done.
| |
| 602 // In normal cases, |client_id| is a child process id, so we can perform | |
| 603 // the standard conversion. | |
| 604 return base::trace_event::MemoryDumpManager:: | |
| 605 ChildProcessIdToTracingProcessId(client_id); | |
| 606 } | |
| 607 } | |
| 608 | |
| 593 } // namespace content | 609 } // namespace content |
| OLD | NEW |