Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1522)

Unified Diff: content/browser/renderer_host/render_message_filter.cc

Issue 290573011: Delay the response to ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer via a callback to allow for b… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698