diff options
author | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-08 23:36:14 +0000 |
---|---|---|
committer | yzshen@chromium.org <yzshen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-08 23:36:14 +0000 |
commit | c29bf7e6023761a0cf008c6ee6d1ab9aec0b16e4 (patch) | |
tree | f4868d36455f346143bdf7075f7f542519f64526 /ppapi | |
parent | 73286d56c43e3cc1a5388b90f5a8aabbb3f87fd6 (diff) | |
download | chromium_src-c29bf7e6023761a0cf008c6ee6d1ab9aec0b16e4.zip chromium_src-c29bf7e6023761a0cf008c6ee6d1ab9aec0b16e4.tar.gz chromium_src-c29bf7e6023761a0cf008c6ee6d1ab9aec0b16e4.tar.bz2 |
Pepper: avoid posting unnecessary tasks in ResourceMessageFilter.
If a message needs to be handled on the same thread as
ResourceMessageFilter::HandleMessage(), handle it directly instead of
posting a task to the same thread.
BUG=269737
TEST=None
Review URL: https://chromiumcodereview.appspot.com/22429007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216487 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/host/resource_message_filter.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/ppapi/host/resource_message_filter.cc b/ppapi/host/resource_message_filter.cc index 6d947e3..ff56cac 100644 --- a/ppapi/host/resource_message_filter.cc +++ b/ppapi/host/resource_message_filter.cc @@ -42,11 +42,16 @@ bool ResourceMessageFilter::HandleMessage(const IPC::Message& msg, HostMessageContext* context) { scoped_refptr<base::TaskRunner> runner = OverrideTaskRunnerForMessage(msg); if (runner.get()) { - // TODO(raymes): We need to make a copy so the context can be used on other - // threads. It would be better to have a thread-safe refcounted context. - HostMessageContext context_copy = *context; - runner->PostTask(FROM_HERE, base::Bind( - &ResourceMessageFilter::DispatchMessage, this, msg, context_copy)); + if (runner->RunsTasksOnCurrentThread()) { + DispatchMessage(msg, *context); + } else { + // TODO(raymes): We need to make a copy so the context can be used on + // other threads. It would be better to have a thread-safe refcounted + // context. + HostMessageContext context_copy = *context; + runner->PostTask(FROM_HERE, base::Bind( + &ResourceMessageFilter::DispatchMessage, this, msg, context_copy)); + } return true; } |