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

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

Issue 1010183002: SFI NaCl: Batch-open resource files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: wip: test fix 1 Created 5 years, 8 months 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
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 5df92fbe6adb4ef6e1bcf56b2bba334f19bc1469..89654c6dd858058f80068df7119e7af39656697e 100644
--- a/components/nacl/loader/nacl_ipc_adapter.cc
+++ b/components/nacl/loader/nacl_ipc_adapter.cc
@@ -13,6 +13,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/memory/shared_memory.h"
#include "base/task_runner_util.h"
+#include "base/tuple.h"
#include "build/build_config.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_platform_file.h"
@@ -502,11 +503,11 @@ bool NaClIPCAdapter::OnMessageReceived(const IPC::Message& msg) {
// arbitrary code in a plugin process.
DCHECK(!resolve_file_token_cb_.is_null());
- // resolve_file_token_cb_ must be invoked from the main thread.
+ // resolve_file_token_cb_ must be invoked from the I/O thread.
resolve_file_token_cb_.Run(
token_lo,
token_hi,
- base::Bind(&NaClIPCAdapter::OnFileTokenResolved,
+ base::Bind(&NaClIPCAdapter::SaveOpenResourceMessage,
this,
msg));
@@ -624,9 +625,10 @@ scoped_ptr<IPC::Message> CreateOpenResourceReply(
return new_msg.Pass();
}
-void NaClIPCAdapter::OnFileTokenResolved(const IPC::Message& orig_msg,
- IPC::PlatformFileForTransit ipc_fd,
- base::FilePath file_path) {
+void NaClIPCAdapter::SaveOpenResourceMessage(
+ const IPC::Message& orig_msg,
+ IPC::PlatformFileForTransit ipc_fd,
+ base::FilePath file_path) {
// The path where an invalid ipc_fd is returned isn't currently
// covered by any tests.
if (ipc_fd == IPC::InvalidPlatformFileForTransit()) {
@@ -787,6 +789,23 @@ void NaClIPCAdapter::SendMessageOnIOThread(scoped_ptr<IPC::Message> message) {
DCHECK(io_thread_data_.pending_sync_msgs_.find(id) ==
io_thread_data_.pending_sync_msgs_.end());
+ // 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() &&
+ message->type() == PpapiHostMsg_OpenResource::ID &&
+ PpapiHostMsg_OpenResource::ReadSendParam(message.get(), &send_params)) {
+ const std::string key = get<0>(send_params);
+ // Both open_resource_cb_ and SaveOpenResourceMessage must be invoked
+ // from the I/O thread.
+ if (open_resource_cb_.Run(
+ *message.get(), key,
+ base::Bind(&NaClIPCAdapter::SaveOpenResourceMessage, this))) {
+ // The callback sent a reply to the untrusted side.
+ return;
+ }
+ }
+
if (message->is_sync())
io_thread_data_.pending_sync_msgs_[id] = message->type();
io_thread_data_.channel_->Send(message.release());

Powered by Google App Engine
This is Rietveld 408576698