Chromium Code Reviews| Index: content/common/gpu/gpu_command_buffer_stub.cc |
| diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc |
| index 3878cf58d60b912232c46181411dacde198ded6f..16c0dddc1b902f6d0263fe8199119361085008b0 100644 |
| --- a/content/common/gpu/gpu_command_buffer_stub.cc |
| +++ b/content/common/gpu/gpu_command_buffer_stub.cc |
| @@ -686,9 +686,27 @@ void GpuCommandBufferStub::OnRegisterTransferBuffer( |
| base::SharedMemoryHandle transfer_buffer, |
|
epenner
2014/03/25 22:14:52
Since this is just a handle, the app will crash if
epenner
2014/03/25 22:25:37
Hmm, is there even a possibility we were leaking f
epenner
2014/03/25 23:02:13
Actually, forget this I'm stupid :P. We were closi
|
| uint32 size) { |
| TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnRegisterTransferBuffer"); |
| + |
| + // Duplicate the shared memory for this process. |
| base::SharedMemory shared_memory(transfer_buffer, false); |
| + base::SharedMemoryHandle duped_shared_memory_handle; |
| + if (!shared_memory.ShareToProcess(base::GetCurrentProcessHandle(), |
| + &duped_shared_memory_handle)) { |
| + DVLOG(0) << "Failed to duplicate shared memory handle."; |
| + return; |
| + } |
| + scoped_ptr<base::SharedMemory> duped_shared_memory( |
| + new base::SharedMemory(duped_shared_memory_handle, false)); |
| + |
| + // Map the shared memory into this process. This validates the size. |
| + if (!duped_shared_memory->Map(size)) { |
| + DVLOG(0) << "Failed to map shared memory."; |
| + return; |
| + } |
| + |
| if (command_buffer_) |
| - command_buffer_->RegisterTransferBuffer(id, &shared_memory, size); |
| + command_buffer_->RegisterTransferBuffer( |
| + id, duped_shared_memory.Pass(), size); |
| } |
| void GpuCommandBufferStub::OnDestroyTransferBuffer(int32 id) { |