Commit d21269da authored by jbauman@chromium.org's avatar jbauman@chromium.org

Allocate SharedBitmaps on FILE_USER_BLOCKING thread.

Allocating these can be expensive (especially on OS X) so it's best not to block the IO thread while doing that.

BUG=

Review URL: https://codereview.chromium.org/317973004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276358 0039d316-1c4b-4281-b951-d872f2087c98
parent d6fba165
...@@ -331,10 +331,10 @@ RenderMessageFilter::~RenderMessageFilter() { ...@@ -331,10 +331,10 @@ RenderMessageFilter::~RenderMessageFilter() {
// This function should be called on the IO thread. // This function should be called on the IO thread.
DCHECK_CURRENTLY_ON(BrowserThread::IO); DCHECK_CURRENTLY_ON(BrowserThread::IO);
DCHECK(plugin_host_clients_.empty()); DCHECK(plugin_host_clients_.empty());
HostSharedBitmapManager::current()->ProcessRemoved(PeerHandle());
} }
void RenderMessageFilter::OnChannelClosing() { void RenderMessageFilter::OnChannelClosing() {
HostSharedBitmapManager::current()->ProcessRemoved(PeerHandle());
#if defined(ENABLE_PLUGINS) #if defined(ENABLE_PLUGINS)
for (std::set<OpenChannelToNpapiPluginCallback*>::iterator it = for (std::set<OpenChannelToNpapiPluginCallback*>::iterator it =
plugin_host_clients_.begin(); it != plugin_host_clients_.end(); ++it) { plugin_host_clients_.begin(); it != plugin_host_clients_.end(); ++it) {
...@@ -409,8 +409,8 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message) { ...@@ -409,8 +409,8 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message) {
OnCheckNotificationPermission) OnCheckNotificationPermission)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedMemory, IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedMemory,
OnAllocateSharedMemory) OnAllocateSharedMemory)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedBitmap, IPC_MESSAGE_HANDLER_DELAY_REPLY(
OnAllocateSharedBitmap) ChildProcessHostMsg_SyncAllocateSharedBitmap, OnAllocateSharedBitmap)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_AllocatedSharedBitmap, IPC_MESSAGE_HANDLER(ChildProcessHostMsg_AllocatedSharedBitmap,
OnAllocatedSharedBitmap) OnAllocatedSharedBitmap)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedSharedBitmap, IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedSharedBitmap,
...@@ -900,12 +900,29 @@ void RenderMessageFilter::OnAllocateSharedMemory( ...@@ -900,12 +900,29 @@ void RenderMessageFilter::OnAllocateSharedMemory(
buffer_size, PeerHandle(), handle); buffer_size, PeerHandle(), handle);
} }
void RenderMessageFilter::OnAllocateSharedBitmap( void RenderMessageFilter::AllocateSharedBitmapOnFileThread(
uint32 buffer_size, uint32 buffer_size,
const cc::SharedBitmapId& id, const cc::SharedBitmapId& id,
base::SharedMemoryHandle* handle) { IPC::Message* reply_msg) {
base::SharedMemoryHandle handle;
HostSharedBitmapManager::current()->AllocateSharedBitmapForChild( HostSharedBitmapManager::current()->AllocateSharedBitmapForChild(
PeerHandle(), buffer_size, id, handle); PeerHandle(), buffer_size, id, &handle);
ChildProcessHostMsg_SyncAllocateSharedBitmap::WriteReplyParams(reply_msg,
handle);
Send(reply_msg);
}
void RenderMessageFilter::OnAllocateSharedBitmap(uint32 buffer_size,
const cc::SharedBitmapId& id,
IPC::Message* reply_msg) {
BrowserThread::PostTask(
BrowserThread::FILE_USER_BLOCKING,
FROM_HERE,
base::Bind(&RenderMessageFilter::AllocateSharedBitmapOnFileThread,
this,
buffer_size,
id,
reply_msg));
} }
void RenderMessageFilter::OnAllocatedSharedBitmap( void RenderMessageFilter::OnAllocatedSharedBitmap(
......
...@@ -209,9 +209,12 @@ class RenderMessageFilter : public BrowserMessageFilter { ...@@ -209,9 +209,12 @@ class RenderMessageFilter : public BrowserMessageFilter {
// in the renderer on POSIX due to the sandbox. // in the renderer on POSIX due to the sandbox.
void OnAllocateSharedMemory(uint32 buffer_size, void OnAllocateSharedMemory(uint32 buffer_size,
base::SharedMemoryHandle* handle); base::SharedMemoryHandle* handle);
void AllocateSharedBitmapOnFileThread(uint32 buffer_size,
const cc::SharedBitmapId& id,
IPC::Message* reply_msg);
void OnAllocateSharedBitmap(uint32 buffer_size, void OnAllocateSharedBitmap(uint32 buffer_size,
const cc::SharedBitmapId& id, const cc::SharedBitmapId& id,
base::SharedMemoryHandle* handle); IPC::Message* reply_msg);
void OnAllocatedSharedBitmap(size_t buffer_size, void OnAllocatedSharedBitmap(size_t buffer_size,
const base::SharedMemoryHandle& handle, const base::SharedMemoryHandle& handle,
const cc::SharedBitmapId& id); const cc::SharedBitmapId& id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment