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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
15 #include "base/trace_event/process_memory_dump.h" | 15 #include "base/trace_event/process_memory_dump.h" |
16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "content/browser/gpu/gpu_process_host.h" | 18 #include "content/browser/gpu/gpu_process_host.h" |
19 #include "content/common/child_process_host_impl.h" | 19 #include "content/common/child_process_host_impl.h" |
20 #include "content/common/generic_shared_memory_id_generator.h" | 20 #include "content/common/generic_shared_memory_id_generator.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
23 #include "gpu/GLES2/gl2extchromium.h" | 23 #include "gpu/GLES2/gl2extchromium.h" |
24 #include "gpu/ipc/client/gpu_memory_buffer_impl.h" | 24 #include "gpu/ipc/client/gpu_memory_buffer_impl.h" |
25 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" | 25 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" |
26 #include "gpu/ipc/common/gpu_memory_buffer_support.h" | 26 #include "gpu/ipc/common/gpu_memory_buffer_support.h" |
27 #include "ui/gfx/buffer_format_util.h" | 27 #include "ui/gfx/buffer_format_util.h" |
28 #include "ui/gfx/gpu_memory_buffer_tracing.h" | |
29 #include "ui/gl/gl_switches.h" | 28 #include "ui/gl/gl_switches.h" |
30 | 29 |
31 namespace content { | 30 namespace content { |
32 namespace { | 31 namespace { |
33 | 32 |
34 void GpuMemoryBufferDeleted( | 33 void GpuMemoryBufferDeleted( |
35 scoped_refptr<base::SingleThreadTaskRunner> destruction_task_runner, | 34 scoped_refptr<base::SingleThreadTaskRunner> destruction_task_runner, |
36 const gpu::GpuMemoryBufferImpl::DestructionCallback& destruction_callback, | 35 const gpu::GpuMemoryBufferImpl::DestructionCallback& destruction_callback, |
37 const gpu::SyncToken& sync_token) { | 36 const gpu::SyncToken& sync_token) { |
38 destruction_task_runner->PostTask( | 37 destruction_task_runner->PostTask( |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 167 |
169 // Create the cross-process ownership edge. If the client creates a | 168 // Create the cross-process ownership edge. If the client creates a |
170 // corresponding dump for the same buffer, this will avoid to | 169 // corresponding dump for the same buffer, this will avoid to |
171 // double-count them in tracing. If, instead, no other process will emit a | 170 // double-count them in tracing. If, instead, no other process will emit a |
172 // dump with the same guid, the segment will be accounted to the browser. | 171 // dump with the same guid, the segment will be accounted to the browser. |
173 uint64_t client_tracing_process_id = | 172 uint64_t client_tracing_process_id = |
174 ClientIdToTracingProcessId(client_id); | 173 ClientIdToTracingProcessId(client_id); |
175 | 174 |
176 base::trace_event::MemoryAllocatorDumpGuid shared_buffer_guid; | 175 base::trace_event::MemoryAllocatorDumpGuid shared_buffer_guid; |
177 if (buffer.second.type == gfx::SHARED_MEMORY_BUFFER) { | 176 if (buffer.second.type == gfx::SHARED_MEMORY_BUFFER) { |
178 shared_buffer_guid = gfx::GetSharedMemoryGUIDForTracing( | 177 // TODO: Fix this! Get shared memroy here! |
179 client_tracing_process_id, buffer_id); | 178 shared_buffer_guid = base::trace_event:: |
| 179 MemoryAllocatorDumpGuid(); // GetGUIDForTracing(); |
| 180 // SharedMemoryTracker::AddOwnershipEdges(pmd, ); |
180 } else { | 181 } else { |
181 shared_buffer_guid = gfx::GetGenericSharedGpuMemoryGUIDForTracing( | 182 shared_buffer_guid = gfx::GetGenericSharedGpuMemoryGUIDForTracing( |
182 client_tracing_process_id, buffer_id); | 183 client_tracing_process_id, buffer_id); |
| 184 pmd->CreateSharedGlobalAllocatorDump(shared_buffer_guid); |
| 185 pmd->AddOwnershipEdge(dump->guid(), shared_buffer_guid); |
183 } | 186 } |
184 pmd->CreateSharedGlobalAllocatorDump(shared_buffer_guid); | |
185 pmd->AddOwnershipEdge(dump->guid(), shared_buffer_guid); | |
186 } | 187 } |
187 } | 188 } |
188 | 189 |
189 return true; | 190 return true; |
190 } | 191 } |
191 | 192 |
192 void BrowserGpuMemoryBufferManager::ChildProcessDeletedGpuMemoryBuffer( | 193 void BrowserGpuMemoryBufferManager::ChildProcessDeletedGpuMemoryBuffer( |
193 gfx::GpuMemoryBufferId id, | 194 gfx::GpuMemoryBufferId id, |
194 int child_client_id, | 195 int child_client_id, |
195 const gpu::SyncToken& sync_token) { | 196 const gpu::SyncToken& sync_token) { |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 format(format), | 471 format(format), |
471 usage(usage), | 472 usage(usage), |
472 gpu_host_id(gpu_host_id) {} | 473 gpu_host_id(gpu_host_id) {} |
473 | 474 |
474 BrowserGpuMemoryBufferManager::BufferInfo::BufferInfo(const BufferInfo& other) = | 475 BrowserGpuMemoryBufferManager::BufferInfo::BufferInfo(const BufferInfo& other) = |
475 default; | 476 default; |
476 | 477 |
477 BrowserGpuMemoryBufferManager::BufferInfo::~BufferInfo() {} | 478 BrowserGpuMemoryBufferManager::BufferInfo::~BufferInfo() {} |
478 | 479 |
479 } // namespace content | 480 } // namespace content |
OLD | NEW |