Chromium Code Reviews| Index: ppapi/nacl_irt/manifest_service.cc |
| diff --git a/ppapi/nacl_irt/manifest_service.cc b/ppapi/nacl_irt/manifest_service.cc |
| index d84b3f35f717f5f98a9b4016724733dad80edbfa..e7953e4fdfc24001206f384871c6a51f2babc63c 100644 |
| --- a/ppapi/nacl_irt/manifest_service.cc |
| +++ b/ppapi/nacl_irt/manifest_service.cc |
| @@ -80,18 +80,41 @@ void ManifestService::StartupInitializationComplete() { |
| } |
| bool ManifestService::OpenResource(const char* file, int* fd) { |
| + // We currently restrict to only allow one concurrent open_resource() call |
| + // per plugin. This could be fixed by doing a token lookup with |
| + // NaClProcessMsg_ResolveFileTokenAsyncReply instead of using a |
| + // global inside components/nacl/loader/nacl_listener.cc |
| + base::AutoLock lock(open_resource_lock_); |
| + |
| // OpenResource will return INVALID SerializedHandle, if it is not supported. |
| // Specifically, PNaCl doesn't support open resource. |
| ppapi::proxy::SerializedHandle ipc_fd; |
| + |
| + // File tokens are ignored here, but needed when the message is processed |
| + // inside NaClIPCAdapter. |
| + uint64_t file_token_lo; |
| + uint64_t file_token_hi; |
| if (!filter_->Send(new PpapiHostMsg_OpenResource( |
| - std::string(kFilePrefix) + file, &ipc_fd)) || |
| - !ipc_fd.is_file()) { |
| + std::string(kFilePrefix) + file, |
| + &ipc_fd, |
| + &file_token_lo, |
| + &file_token_hi))) { |
| LOG(ERROR) << "ManifestService::OpenResource failed:" << file; |
| *fd = -1; |
| return false; |
| } |
| - *fd = ipc_fd.descriptor().fd; |
| + // TODO(teravest): Check that file_token_lo and file_token_hi are 0. That |
| + // currently works on Linux, but not on Windows... |
|
Mark Seaborn
2014/08/28 21:33:49
Why doesn't it work on Windows?
teravest
2014/09/04 22:13:30
I'm going to debug this. I wanted to get some feed
|
| + |
| + // Copy the file if we received a valid file descriptor. Otherwise, if we got |
| + // a reply, the file doesn't exist, so provide an fd of -1. |
| + // See ppapi/nacl_irt/manifest_service.cc for how this function's result is |
|
Mark Seaborn
2014/08/28 21:33:49
That is this file, in the function immediately bel
teravest
2014/09/04 22:13:30
Thanks, I've worded this a bit better now.
|
| + // interpreted. |
| + if (ipc_fd.is_file()) |
| + *fd = ipc_fd.descriptor().fd; |
| + else |
| + *fd = -1; |
| return true; |
| } |
| @@ -105,7 +128,6 @@ int IrtOpenResource(const char* file, int* fd) { |
| !manifest_service->OpenResource(file, fd)) { |
| return NACL_ABI_EIO; |
| } |
| - |
| return (*fd == -1) ? NACL_ABI_ENOENT : 0; |
| } |