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 55e10b5cf34afc9fd5ceddb9fb8637cf7d899be2..29c39c43441495fb5fa9f509271fb57251653a80 100644 |
--- a/content/browser/renderer_host/render_message_filter.cc |
+++ b/content/browser/renderer_host/render_message_filter.cc |
@@ -376,6 +376,15 @@ void RenderMessageFilter::OnChannelConnected(int32 peer_id) { |
bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message, |
bool* message_was_ok) { |
+#if defined(OS_MACOSX) |
+ // Remove surface references that are now in use by the renderer. |
+ while (!io_surfaces_.empty()) { |
+ IOSurfaceSupport* io_surface_support = IOSurfaceSupport::Initialize(); |
+ if (!io_surface_support->IOSurfaceIsInUse(io_surfaces_.front())) |
+ break; |
+ io_surfaces_.pop(); |
+ } |
+#endif |
bool handled = true; |
IPC_BEGIN_MESSAGE_MAP_EX(RenderMessageFilter, message, *message_was_ok) |
#if defined(OS_WIN) |
@@ -1220,10 +1229,9 @@ void RenderMessageFilter::OnAllocateGpuMemoryBuffer( |
handle->type = gfx::IO_SURFACE_BUFFER; |
handle->io_surface_id = io_surface_support->IOSurfaceGetID(io_surface); |
- // TODO(reveman): This makes the assumption that the renderer will |
- // grab a reference to the surface before sending another message. |
- // crbug.com/325045 |
- last_io_surface_ = io_surface; |
+ DCHECK(!io_surface_support->IOSurfaceIsInUse(io_surface)); |
+ // Keep a reference to the surface until it's in use by the renderer. |
+ io_surfaces_.push(io_surface); |
return; |
} |
} |