Skip to content

Commit

Permalink
Pepper: avoid posting unnecessary tasks in ResourceMessageFilter.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yzshen@chromium.org committed Aug 8, 2013
1 parent 73286d5 commit c29bf7e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ppapi/host/resource_message_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit c29bf7e

Please sign in to comment.