summaryrefslogtreecommitdiffstats
path: root/components/nacl/browser
diff options
context:
space:
mode:
authorJustin TerAvest <teravest@chromium.org>2014-09-10 13:21:56 -0600
committerJustin TerAvest <teravest@chromium.org>2014-09-10 19:25:55 +0000
commitcffdd030d9ecd5e2ef50de941fca337a94c3b476 (patch)
tree92ca8712763e0d7851b83d969adcf24cdd1b9b64 /components/nacl/browser
parent465cf3e643d44ce7176072bdbac1a9b03ac70514 (diff)
downloadchromium_src-cffdd030d9ecd5e2ef50de941fca337a94c3b476.zip
chromium_src-cffdd030d9ecd5e2ef50de941fca337a94c3b476.tar.gz
chromium_src-cffdd030d9ecd5e2ef50de941fca337a94c3b476.tar.bz2
Pepper: Stop using SRPC for irt_open_resource().
This registers an IRT interface in Chromium instead of using the one provided by NaCl. This reuses the ManifestServiceChannel used for providing irt_open_resource() in non-SFI mode. In this change, the Chromium implementation of NACL_IRT_RESOURCE_OPEN_v0_1 takes precedence over the one supplied by NaCl (which is SRPC-based). The SRPC-based codepath in service_runtime.cc needs to be kept because the PNaCl translator doesn't have the IRT available yet. I've added a check to enforce that's the only user of that codepath. BUG=394130 TEST=Manually tested with a file token that didn't resolve with a local patch that forced GetFilePath to fail in nacl_process_host.cc and confirmed that URLLoader* still passed. CQ_EXTRA_TRYBOTS=tryserver.chromium.linux:linux_rel_precise32 R=dmichael@chromium.org, mseaborn@chromium.org, tsepez@chromium.org Review URL: https://codereview.chromium.org/418423002 Cr-Commit-Position: refs/heads/master@{#294208}
Diffstat (limited to 'components/nacl/browser')
-rw-r--r--components/nacl/browser/nacl_process_host.cc101
-rw-r--r--components/nacl/browser/nacl_process_host.h6
2 files changed, 85 insertions, 22 deletions
diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc
index defc29f..c461d3e 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) {
diff --git a/components/nacl/browser/nacl_process_host.h b/components/nacl/browser/nacl_process_host.h
index 3b358b5..cae9b73 100644
--- a/components/nacl/browser/nacl_process_host.h
+++ b/components/nacl/browser/nacl_process_host.h
@@ -172,10 +172,14 @@ class NaClProcessHost : public content::BrowserChildProcessHostDelegate {
void OnSetKnownToValidate(const std::string& signature);
void OnResolveFileToken(uint64 file_token_lo, uint64 file_token_hi,
IPC::Message* reply_msg);
+ void OnResolveFileTokenAsync(uint64 file_token_lo, uint64 file_token_hi);
void FileResolved(const base::FilePath& file_path,
IPC::Message* reply_msg,
base::File file);
-
+ void FileResolvedAsync(uint64_t file_token_lo,
+ uint64_t file_token_hi,
+ const base::FilePath& file_path,
+ base::File file);
#if defined(OS_WIN)
// Message handler for Windows hardware exception handling.
void OnAttachDebugExceptionHandler(const std::string& info,