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

Unified Diff: content/common/gpu/client/gpu_channel_host.cc

Issue 11362171: GPUChannel pools mailbox names. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « content/common/gpu/client/gpu_channel_host.h ('k') | content/common/gpu/gpu_channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/client/gpu_channel_host.cc
===================================================================
--- content/common/gpu/client/gpu_channel_host.cc (revision 166793)
+++ content/common/gpu/client/gpu_channel_host.cc (working copy)
@@ -71,6 +71,18 @@
return gpu_info_;
}
+void GpuChannelHost::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+
+ IPC_BEGIN_MESSAGE_MAP(GpuChannelHost, message)
+ IPC_MESSAGE_HANDLER(GpuChannelMsg_GenerateMailboxNamesReply,
+ OnGenerateMailboxNamesReply)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+
+ DCHECK(handled);
+}
+
void GpuChannelHost::OnChannelError() {
state_ = kLost;
@@ -246,9 +258,37 @@
std::vector<std::string>* names) {
TRACE_EVENT0("gpu", "GenerateMailboxName");
AutoLock lock(context_lock_);
- return Send(new GpuChannelMsg_GenerateMailboxNames(num, names));
+
+ if (num > mailbox_name_pool_.size()) {
+ if (!Send(new GpuChannelMsg_GenerateMailboxNames(num, names)))
+ return false;
+ } else {
+ names->insert(names->begin(),
+ mailbox_name_pool_.end() - num,
+ mailbox_name_pool_.end());
+ mailbox_name_pool_.erase(mailbox_name_pool_.end() - num,
+ mailbox_name_pool_.end());
+ }
+
+ const unsigned ideal_mailbox_pool_size = 100;
+ if (mailbox_name_pool_.size() < ideal_mailbox_pool_size / 2) {
+ Send(new GpuChannelMsg_GenerateMailboxNamesAsync(
+ ideal_mailbox_pool_size - mailbox_name_pool_.size()));
+ }
+
+ return true;
}
+void GpuChannelHost::OnGenerateMailboxNamesReply(
+ const std::vector<std::string>& names) {
+ TRACE_EVENT0("gpu", "OnGenerateMailboxNamesReply");
+ AutoLock lock(context_lock_);
+
+ mailbox_name_pool_.insert(mailbox_name_pool_.end(),
+ names.begin(),
+ names.end());
+}
+
GpuChannelHost::~GpuChannelHost() {}
@@ -280,11 +320,19 @@
bool GpuChannelHost::MessageFilter::OnMessageReceived(
const IPC::Message& message) {
DCHECK(parent_->factory_->IsIOThread());
+
// Never handle sync message replies or we will deadlock here.
if (message.is_reply())
return false;
- DCHECK(message.routing_id() != MSG_ROUTING_CONTROL);
+ if (message.routing_id() == MSG_ROUTING_CONTROL) {
+ MessageLoop* main_loop = parent_->factory_->GetMainLoop();
+ main_loop->PostTask(FROM_HERE,
+ base::Bind(&GpuChannelHost::OnMessageReceived,
+ parent_,
+ message));
+ return true;
+ }
ListenerMap::iterator it = listeners_.find(message.routing_id());
« no previous file with comments | « content/common/gpu/client/gpu_channel_host.h ('k') | content/common/gpu/gpu_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698