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

Unified Diff: components/nacl/loader/nacl_ipc_adapter.cc

Issue 728113002: obsolete: SFI NaCl: Batch-open resource files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 6 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 | « components/nacl/loader/nacl_ipc_adapter.h ('k') | components/nacl/loader/nacl_listener.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « components/nacl/loader/nacl_ipc_adapter.h ('k') | components/nacl/loader/nacl_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698