| Index: components/nacl/loader/nacl_ipc_adapter.cc
|
| diff --git a/components/nacl/loader/nacl_ipc_adapter.cc b/components/nacl/loader/nacl_ipc_adapter.cc
|
| index 5d28152366e62b93b8ea2b68b371a675442ff809..f9378f58c058bb69ec3577ea66d1ade496e1fdd7 100644
|
| --- a/components/nacl/loader/nacl_ipc_adapter.cc
|
| +++ b/components/nacl/loader/nacl_ipc_adapter.cc
|
| @@ -628,6 +628,15 @@ scoped_ptr<IPC::Message> CreateOpenResourceReply(
|
| void NaClIPCAdapter::OnFileTokenResolved(const IPC::Message& orig_msg,
|
| IPC::PlatformFileForTransit ipc_fd,
|
| base::FilePath file_path) {
|
| + base::AutoLock lock(lock_);
|
| + OnFileTokenResolvedLocked(orig_msg, ipc_fd, file_path);
|
| +}
|
| +
|
| +void NaClIPCAdapter::OnFileTokenResolvedLocked(
|
| + const IPC::Message& orig_msg,
|
| + IPC::PlatformFileForTransit ipc_fd,
|
| + base::FilePath file_path) {
|
| + lock_.AssertAcquired();
|
| // The path where an invalid ipc_fd is returned isn't currently
|
| // covered by any tests.
|
| if (ipc_fd == IPC::InvalidPlatformFileForTransit()) {
|
| @@ -653,11 +662,8 @@ void NaClIPCAdapter::OnFileTokenResolved(const IPC::Message& orig_msg,
|
|
|
| scoped_refptr<RewrittenMessage> rewritten_msg(new RewrittenMessage);
|
| rewritten_msg->AddDescriptor(desc_wrapper.release());
|
| - {
|
| - base::AutoLock lock(lock_);
|
| - SaveMessage(*new_msg, rewritten_msg.get());
|
| - cond_var_.Signal();
|
| - }
|
| + SaveMessage(*new_msg, rewritten_msg.get());
|
| + cond_var_.Signal();
|
| return;
|
| }
|
|
|
| @@ -692,11 +698,8 @@ void NaClIPCAdapter::OnFileTokenResolved(const IPC::Message& orig_msg,
|
| scoped_refptr<RewrittenMessage> rewritten_msg(new RewrittenMessage);
|
|
|
| rewritten_msg->AddDescriptor(desc_wrapper.release());
|
| - {
|
| - base::AutoLock lock(lock_);
|
| - SaveMessage(*new_msg, rewritten_msg.get());
|
| - cond_var_.Signal();
|
| - }
|
| + SaveMessage(*new_msg, rewritten_msg.get());
|
| + cond_var_.Signal();
|
| }
|
|
|
| void NaClIPCAdapter::OnChannelConnected(int32 peer_pid) {
|
| @@ -777,6 +780,21 @@ bool NaClIPCAdapter::SendCompleteMessage(const char* buffer,
|
| if (new_msg)
|
| msg.reset(new_msg.release());
|
|
|
| + // Handle PpapiHostMsg_OpenResource locally without sending an IPC to the
|
| + // renderer when possible.
|
| + PpapiHostMsg_OpenResource::Schema::SendParam send_params;
|
| + if (!open_resource_cb_.is_null() &&
|
| + (msg->type() == PpapiHostMsg_OpenResource::ID) &&
|
| + PpapiHostMsg_OpenResource::ReadSendParam(msg.get(), &send_params)) {
|
| + const std::string key = send_params.a;
|
| + if (open_resource_cb_.Run(
|
| + *msg.get(), key,
|
| + base::Bind(&NaClIPCAdapter::OnFileTokenResolvedLocked, this))) {
|
| + // The callback sent a reply to the untrusted side.
|
| + return true;
|
| + }
|
| + }
|
| +
|
| // Actual send must be done on the I/O thread.
|
| task_runner_->PostTask(FROM_HERE,
|
| base::Bind(&NaClIPCAdapter::SendMessageOnIOThread, this,
|
|
|