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

Unified Diff: components/nacl/browser/nacl_process_host.cc

Issue 418423002: Pepper: Stop using SRPC for irt_open_resource(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes for mseaborn and dmichael Created 6 years, 3 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/browser/nacl_process_host.cc
diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc
index 33b071f07b1ebfa91b9f301160080bf66f23293f..09f712ca5b01516e55c192b85f583183c7e87cc1 100644
--- a/components/nacl/browser/nacl_process_host.cc
+++ b/components/nacl/browser/nacl_process_host.cc
@@ -664,6 +664,9 @@ bool NaClProcessHost::OnMessageReceived(const IPC::Message& msg) {
OnSetKnownToValidate)
IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClProcessMsg_ResolveFileToken,
OnResolveFileToken)
+ IPC_MESSAGE_HANDLER(NaClProcessMsg_ResolveFileTokenAsync,
+ OnResolveFileTokenAsync)
+
#if defined(OS_WIN)
IPC_MESSAGE_HANDLER_DELAY_REPLY(
NaClProcessMsg_AttachDebugExceptionHandler,
@@ -1027,27 +1030,6 @@ void NaClProcessHost::OnSetKnownToValidate(const std::string& signature) {
signature, off_the_record_);
}
-void NaClProcessHost::FileResolved(
- const base::FilePath& file_path,
- IPC::Message* reply_msg,
- base::File file) {
- if (file.IsValid()) {
- IPC::PlatformFileForTransit handle = IPC::TakeFileHandleForProcess(
- file.Pass(),
- process_->GetData().handle);
- NaClProcessMsg_ResolveFileToken::WriteReplyParams(
- reply_msg,
- handle,
- file_path);
- } else {
- NaClProcessMsg_ResolveFileToken::WriteReplyParams(
- reply_msg,
- IPC::InvalidPlatformFileForTransit(),
- base::FilePath());
- }
- Send(reply_msg);
-}
-
void NaClProcessHost::OnResolveFileToken(uint64 file_token_lo,
uint64 file_token_hi,
IPC::Message* reply_msg) {
@@ -1103,6 +1085,83 @@ void NaClProcessHost::OnResolveFileToken(uint64 file_token_lo,
}
}
+void NaClProcessHost::OnResolveFileTokenAsync(uint64 file_token_lo,
+ uint64 file_token_hi) {
+ // See the comment at OnResolveFileToken() for details of the file path cache
+ // behavior.
+ CHECK(!uses_nonsfi_mode_);
+ base::FilePath file_path;
+ if (!NaClBrowser::GetInstance()->GetFilePath(
+ file_token_lo, file_token_hi, &file_path)) {
+ Send(new NaClProcessMsg_ResolveFileTokenAsyncReply(
+ file_token_lo,
+ file_token_hi,
+ IPC::PlatformFileForTransit(),
+ base::FilePath()));
+ return;
+ }
+
+ // Open the file.
+ if (!base::PostTaskAndReplyWithResult(
+ content::BrowserThread::GetBlockingPool(),
+ FROM_HERE,
+ base::Bind(OpenNaClReadExecImpl, file_path, true /* is_executable */),
+ base::Bind(&NaClProcessHost::FileResolvedAsync,
+ weak_factory_.GetWeakPtr(),
+ file_token_lo,
+ file_token_hi,
+ file_path))) {
+ Send(new NaClProcessMsg_ResolveFileTokenAsyncReply(
+ file_token_lo,
+ file_token_hi,
+ IPC::PlatformFileForTransit(),
+ base::FilePath()));
+ }
+}
+
+void NaClProcessHost::FileResolved(
+ const base::FilePath& file_path,
+ IPC::Message* reply_msg,
+ base::File file) {
+ if (file.IsValid()) {
+ IPC::PlatformFileForTransit handle = IPC::TakeFileHandleForProcess(
+ file.Pass(),
+ process_->GetData().handle);
+ NaClProcessMsg_ResolveFileToken::WriteReplyParams(
+ reply_msg,
+ handle,
+ file_path);
+ } else {
+ NaClProcessMsg_ResolveFileToken::WriteReplyParams(
+ reply_msg,
+ IPC::InvalidPlatformFileForTransit(),
+ base::FilePath());
+ }
+ Send(reply_msg);
+}
+
+void NaClProcessHost::FileResolvedAsync(
+ uint64_t file_token_lo,
+ uint64_t file_token_hi,
+ const base::FilePath& file_path,
+ base::File file) {
+ base::FilePath out_file_path;
+ IPC::PlatformFileForTransit out_handle;
+ if (file.IsValid()) {
+ out_file_path = file_path;
+ out_handle = IPC::TakeFileHandleForProcess(
+ file.Pass(),
+ process_->GetData().handle);
+ } else {
+ out_handle = IPC::InvalidPlatformFileForTransit();
+ }
+ Send(new NaClProcessMsg_ResolveFileTokenAsyncReply(
+ file_token_lo,
+ file_token_hi,
+ out_handle,
+ out_file_path));
+}
+
#if defined(OS_WIN)
void NaClProcessHost::OnAttachDebugExceptionHandler(const std::string& info,
IPC::Message* reply_msg) {

Powered by Google App Engine
This is Rietveld 408576698