Chromium Code Reviews| Index: content/browser/renderer_host/render_message_filter.cc |
| diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc |
| index 11f80eeab63347999c3ab2deddfe6bc4096a74a3..7c32a5aa299cec1631baba93078ede2eff05f26a 100644 |
| --- a/content/browser/renderer_host/render_message_filter.cc |
| +++ b/content/browser/renderer_host/render_message_filter.cc |
| @@ -239,6 +239,19 @@ void AddIntegerValue(CFMutableDictionaryRef dictionary, |
| } |
| #endif |
| +class ScopedCallbackRunner { |
| + public: |
| + ScopedCallbackRunner(base::Closure* callback) : callback_(callback) {} |
| + ~ScopedCallbackRunner() { |
| + if (callback_) |
| + callback_->Run(); |
| + } |
| + void reset() { callback_ = NULL; } |
| + |
| + private: |
| + base::Closure* callback_; |
| +}; |
| + |
| } // namespace |
| class RenderMessageFilter::OpenChannelToNpapiPluginCallback |
| @@ -443,8 +456,9 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message, |
| OnAllocateSharedMemory) |
| IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedBitmap, |
| OnAllocateSharedBitmap) |
| - IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer, |
| - OnAllocateGpuMemoryBuffer) |
| + IPC_MESSAGE_HANDLER_DELAY_REPLY( |
| + ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer, |
| + OnAllocateGpuMemoryBuffer) |
| IPC_MESSAGE_HANDLER(ChildProcessHostMsg_AllocatedSharedBitmap, |
| OnAllocatedSharedBitmap) |
| IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedSharedBitmap, |
| @@ -1233,12 +1247,20 @@ void RenderMessageFilter::OnWebAudioMediaCodec( |
| } |
| #endif |
| -void RenderMessageFilter::OnAllocateGpuMemoryBuffer( |
| - uint32 width, |
| - uint32 height, |
| - uint32 internalformat, |
| - uint32 usage, |
| - gfx::GpuMemoryBufferHandle* handle) { |
| +void RenderMessageFilter::OnAllocateGpuMemoryBuffer(uint32 width, |
| + uint32 height, |
| + uint32 internalformat, |
| + uint32 usage, |
| + IPC::Message* reply) { |
| + gfx::GpuMemoryBufferHandle* handle = new gfx::GpuMemoryBufferHandle; |
|
reveman
2014/05/19 05:51:07
I prefer if you don't heap allocate this. Seems un
|
| + |
| + base::Closure reply_callback = |
| + base::Bind(&RenderMessageFilter::SendAllocateGpuMemoryBufferReply, |
| + this, |
| + reply, |
| + base::Owned(handle)); |
| + ScopedCallbackRunner callback_runner(&reply_callback); |
|
reveman
2014/05/19 05:51:07
I prefer if you called ::GpuMemoryBufferAllocated
|
| + |
| if (!GpuMemoryBufferImpl::IsFormatValid(internalformat) || |
| !GpuMemoryBufferImpl::IsUsageValid(usage)) { |
| handle->type = gfx::EMPTY_BUFFER; |
| @@ -1320,9 +1342,22 @@ void RenderMessageFilter::OnAllocateGpuMemoryBuffer( |
| } |
| } |
| #endif |
| + callback_runner.reset(); |
| + |
| + GpuMemoryBufferImpl::AllocateForChildProcess(gfx::Size(width, height), |
| + internalformat, |
| + usage, |
| + PeerHandle(), |
| + handle, |
| + reply_callback); |
| +} |
| - GpuMemoryBufferImpl::AllocateForChildProcess( |
| - gfx::Size(width, height), internalformat, usage, PeerHandle(), handle); |
| +void RenderMessageFilter::SendAllocateGpuMemoryBufferReply( |
| + IPC::Message* reply, |
| + gfx::GpuMemoryBufferHandle* handle) { |
| + ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply, |
| + *handle); |
| + Send(reply); |
| } |
| } // namespace content |