summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorhidehiko@chromium.org <hidehiko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-02 23:24:52 +0000
committerhidehiko@chromium.org <hidehiko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-02 23:24:52 +0000
commitae5f7f8df0da772d0658971334f8356a45a2720c (patch)
tree820952854634b6face0c68222a96ca25adde0e07 /ppapi
parent49a6d858575651f079c883ef0f6122ee8185dcee (diff)
downloadchromium_src-ae5f7f8df0da772d0658971334f8356a45a2720c.zip
chromium_src-ae5f7f8df0da772d0658971334f8356a45a2720c.tar.gz
chromium_src-ae5f7f8df0da772d0658971334f8356a45a2720c.tar.bz2
Implement open_resource in non-SFI mode.
This CL implements open_resource() in non-SFI mode. 1) Introduced a new sync message PpapiHostMsg_OpenResource and its handlers. 2) Implement async version of OpenManifestEntry. As IPC's handler is called on renderer's main thread, otherwise it causes deadlock. TEST=Run trybots. BUG=358431 Review URL: https://codereview.chromium.org/249183004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267962 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/api/private/ppb_nacl_private.idl16
-rw-r--r--ppapi/c/private/ppb_nacl_private.h30
-rw-r--r--ppapi/nacl_irt/DEPS3
-rw-r--r--ppapi/nacl_irt/irt_manifest.h21
-rw-r--r--ppapi/nacl_irt/manifest_service.cc37
-rw-r--r--ppapi/nacl_irt/manifest_service.h1
-rw-r--r--ppapi/native_client/src/trusted/plugin/nacl_entry_points.h2
-rw-r--r--ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc2
-rw-r--r--ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h2
-rw-r--r--ppapi/native_client/src/trusted/plugin/service_runtime.cc164
-rw-r--r--ppapi/native_client/src/trusted/plugin/service_runtime.h20
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c8
-rw-r--r--ppapi/ppapi_nacl_test_common.gypi15
-rw-r--r--ppapi/proxy/ppapi_messages.h5
14 files changed, 276 insertions, 50 deletions
diff --git a/ppapi/api/private/ppb_nacl_private.idl b/ppapi/api/private/ppb_nacl_private.idl
index ac93742..04b6758 100644
--- a/ppapi/api/private/ppb_nacl_private.idl
+++ b/ppapi/api/private/ppb_nacl_private.idl
@@ -139,6 +139,10 @@ struct PP_PNaClOptions {
int32_t opt_level;
};
+/* Callback invoked upon completion of PPP_ManifestService::OpenResource(). */
+typedef void PP_OpenResourceCompletionCallback([inout] mem_t user_data,
+ [in] PP_FileHandle file_handle);
+
/* ManifestService to support irt_open_resource() function.
* All functions of the service should have PP_Bool return value. It represents
* whether the service is still alive or not. Trivially Quit() should always
@@ -146,12 +150,20 @@ struct PP_PNaClOptions {
* Once false is called, as the service has been destructed, all functions
* should never be called afterwords.
*/
-interface PP_ManifestService {
+interface PPP_ManifestService {
/* Called when ManifestService should be destructed. */
PP_Bool Quit([inout] mem_t user_data);
/* Called when PPAPI initialization in the NaCl plugin is finished. */
PP_Bool StartupInitializationComplete([inout] mem_t user_data);
+
+ /* Called when irt_open_resource() is invoked in the NaCl plugin.
+ * Upon completion, callback will be invoked with given callback_user_data
+ * and the result file handle (or PP_kInvalidFileHandle on error). */
+ PP_Bool OpenResource([inout] mem_t user_data,
+ [in] str_t entry_key,
+ [in] PP_OpenResourceCompletionCallback callback,
+ [inout] mem_t callback_user_data);
};
/* PPB_NaCl_Private */
@@ -184,7 +196,7 @@ interface PPB_NaCl_Private {
[in] PP_Bool enable_dyncode_syscalls,
[in] PP_Bool enable_exception_handling,
[in] PP_Bool enable_crash_throttling,
- [in] PP_ManifestService manifest_service_interface,
+ [in] PPP_ManifestService manifest_service_interface,
[inout] mem_t manifest_service_user_data,
[out] mem_t imc_handle,
[out] PP_Var error_message,
diff --git a/ppapi/c/private/ppb_nacl_private.h b/ppapi/c/private/ppb_nacl_private.h
index 573b8d0..9ac540a 100644
--- a/ppapi/c/private/ppb_nacl_private.h
+++ b/ppapi/c/private/ppb_nacl_private.h
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* From private/ppb_nacl_private.idl modified Wed Apr 30 14:13:27 2014. */
+/* From private/ppb_nacl_private.idl modified Sat May 3 04:07:13 2014. */
#ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
#define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
@@ -15,8 +15,8 @@
#include "ppapi/c/pp_stdint.h"
#include "ppapi/c/pp_var.h"
-#define PP_MANIFESTSERVICE_INTERFACE_1_0 "PP_ManifestService;1.0"
-#define PP_MANIFESTSERVICE_INTERFACE PP_MANIFESTSERVICE_INTERFACE_1_0
+#define PPP_MANIFESTSERVICE_INTERFACE_1_0 "PPP_ManifestService;1.0"
+#define PPP_MANIFESTSERVICE_INTERFACE PPP_MANIFESTSERVICE_INTERFACE_1_0
#define PPB_NACL_PRIVATE_INTERFACE_1_0 "PPB_NaCl_Private;1.0"
#define PPB_NACL_PRIVATE_INTERFACE PPB_NACL_PRIVATE_INTERFACE_1_0
@@ -168,6 +168,17 @@ struct PP_PNaClOptions {
*/
/**
+ * @addtogroup Typedefs
+ * @{
+ */
+/* Callback invoked upon completion of PPP_ManifestService::OpenResource(). */
+typedef void (*PP_OpenResourceCompletionCallback)(void* user_data,
+ PP_FileHandle file_handle);
+/**
+ * @}
+ */
+
+/**
* @addtogroup Interfaces
* @{
*/
@@ -178,14 +189,21 @@ struct PP_PNaClOptions {
* Once false is called, as the service has been destructed, all functions
* should never be called afterwords.
*/
-struct PP_ManifestService_1_0 {
+struct PPP_ManifestService_1_0 {
/* Called when ManifestService should be destructed. */
PP_Bool (*Quit)(void* user_data);
/* Called when PPAPI initialization in the NaCl plugin is finished. */
PP_Bool (*StartupInitializationComplete)(void* user_data);
+ /* Called when irt_open_resource() is invoked in the NaCl plugin.
+ * Upon completion, callback will be invoked with given callback_user_data
+ * and the result file handle (or PP_kInvalidFileHandle on error). */
+ PP_Bool (*OpenResource)(void* user_data,
+ const char* entry_key,
+ PP_OpenResourceCompletionCallback callback,
+ void* callback_user_data);
};
-typedef struct PP_ManifestService_1_0 PP_ManifestService;
+typedef struct PPP_ManifestService_1_0 PPP_ManifestService;
/* PPB_NaCl_Private */
struct PPB_NaCl_Private_1_0 {
@@ -218,7 +236,7 @@ struct PPB_NaCl_Private_1_0 {
PP_Bool enable_dyncode_syscalls,
PP_Bool enable_exception_handling,
PP_Bool enable_crash_throttling,
- const struct PP_ManifestService_1_0* manifest_service_interface,
+ const struct PPP_ManifestService_1_0* manifest_service_interface,
void* manifest_service_user_data,
void* imc_handle,
struct PP_Var* error_message,
diff --git a/ppapi/nacl_irt/DEPS b/ppapi/nacl_irt/DEPS
index b759edf..8e4bc77 100644
--- a/ppapi/nacl_irt/DEPS
+++ b/ppapi/nacl_irt/DEPS
@@ -10,6 +10,7 @@ include_rules = [
"+native_client/src/shared/srpc/nacl_srpc.h",
"+native_client/src/untrusted/irt/irt.h",
"+native_client/src/untrusted/irt/irt_private.h",
- # The IRT also needs to know the sysconf enums.
+ # The IRT also needs to know the errno and sysconf enums.
+ "+native_client/src/trusted/service_runtime/include/sys/errno.h",
"+native_client/src/trusted/service_runtime/include/sys/unistd.h",
]
diff --git a/ppapi/nacl_irt/irt_manifest.h b/ppapi/nacl_irt/irt_manifest.h
new file mode 100644
index 0000000..b1e0923
--- /dev/null
+++ b/ppapi/nacl_irt/irt_manifest.h
@@ -0,0 +1,21 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_NACL_IRT_IRT_MANIFEST_H_
+#define PPAPI_NACL_IRT_IRT_MANIFEST_H_
+
+#include "ppapi/proxy/ppapi_proxy_export.h"
+
+namespace ppapi {
+
+// The implementation of irt_open_resource() based on ManifestService.
+// This communicates with the renderer process via Chrome IPC to obtain the
+// read-only file descriptor of the resource specified in the manifest file
+// with the key |file| in files section. Returns 0 on success, or error number
+// on failure. See also irt_open_resource()'s comment.
+PPAPI_PROXY_EXPORT int IrtOpenResource(const char* file, int* fd);
+
+} // namespace ppapi
+
+#endif // PPAPI_NACL_IRT_IRT_MANIFEST_H_
diff --git a/ppapi/nacl_irt/manifest_service.cc b/ppapi/nacl_irt/manifest_service.cc
index ed7c4eb..0afa217 100644
--- a/ppapi/nacl_irt/manifest_service.cc
+++ b/ppapi/nacl_irt/manifest_service.cc
@@ -8,10 +8,15 @@
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_channel_proxy.h"
#include "ipc/ipc_sync_message_filter.h"
+#include "native_client/src/trusted/service_runtime/include/sys/errno.h"
+#include "ppapi/nacl_irt/irt_manifest.h"
+#include "ppapi/nacl_irt/plugin_startup.h"
#include "ppapi/proxy/ppapi_messages.h"
namespace ppapi {
+const char kFilePrefix[] = "files/";
+
ManifestService::ManifestService(
const IPC::ChannelHandle& handle,
scoped_refptr<base::MessageLoopProxy> io_message_loop,
@@ -19,7 +24,7 @@ ManifestService::ManifestService(
filter_ = new IPC::SyncMessageFilter(shutdown_event);
channel_.reset(new IPC::ChannelProxy(handle,
IPC::Channel::MODE_SERVER,
- NULL, // Listener
+ NULL, // Listener
io_message_loop));
channel_->AddFilter(filter_.get());
}
@@ -31,4 +36,34 @@ void ManifestService::StartupInitializationComplete() {
filter_->Send(new PpapiHostMsg_StartupInitializationComplete);
}
+bool ManifestService::OpenResource(const char* file, int* fd) {
+ // OpenResource will return INVALID SerializedHandle, if it is not supported.
+ // Specifically, PNaCl doesn't support open resource.
+ ppapi::proxy::SerializedHandle ipc_fd;
+ if (!filter_->Send(new PpapiHostMsg_OpenResource(
+ std::string(kFilePrefix) + file, &ipc_fd)) ||
+ !ipc_fd.is_file()) {
+ LOG(ERROR) << "ManifestService::OpenResource failed:" << file;
+ *fd = -1;
+ return false;
+ }
+
+ *fd = ipc_fd.descriptor().fd;
+ return true;
+}
+
+int IrtOpenResource(const char* file, int* fd) {
+ // Remove leading '/' character.
+ if (file[0] == '/')
+ ++file;
+
+ ManifestService* manifest_service = GetManifestService();
+ if (manifest_service == NULL ||
+ !manifest_service->OpenResource(file, fd)) {
+ return NACL_ABI_EIO;
+ }
+
+ return (*fd == -1) ? NACL_ABI_ENOENT : 0;
+}
+
} // namespace ppapi
diff --git a/ppapi/nacl_irt/manifest_service.h b/ppapi/nacl_irt/manifest_service.h
index ec5e38c..ce414cc 100644
--- a/ppapi/nacl_irt/manifest_service.h
+++ b/ppapi/nacl_irt/manifest_service.h
@@ -30,6 +30,7 @@ class ManifestService {
~ManifestService();
void StartupInitializationComplete();
+ bool OpenResource(const char* file, int* fd);
private:
scoped_ptr<IPC::ChannelProxy> channel_;
diff --git a/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h b/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h
index 4d4c923..5e8ca99 100644
--- a/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h
+++ b/ppapi/native_client/src/trusted/plugin/nacl_entry_points.h
@@ -28,7 +28,7 @@ typedef PP_ExternalPluginResult (*LaunchNaClProcessFunc)(
PP_Bool enable_dyncode_syscalls,
PP_Bool enable_exception_handling,
PP_Bool enable_crash_throttling,
- const PP_ManifestService* manifest_service_interface,
+ const PPP_ManifestService* manifest_service_interface,
void* manifest_service_user_data,
NaClHandle* result_socket,
struct PP_Var* error_message,
diff --git a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc
index bd8ee9e..d27de7e 100644
--- a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc
+++ b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.cc
@@ -27,7 +27,7 @@ void SelLdrLauncherChrome::Start(
bool enable_dyncode_syscalls,
bool enable_exception_handling,
bool enable_crash_throttling,
- const PP_ManifestService* manifest_service_interface,
+ const PPP_ManifestService* manifest_service_interface,
void* manifest_service_user_data,
PP_Var* error_message,
pp::CompletionCallback callback) {
diff --git a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h
index 50e8848..7ab2339 100644
--- a/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h
+++ b/ppapi/native_client/src/trusted/plugin/sel_ldr_launcher_chrome.h
@@ -25,7 +25,7 @@ class SelLdrLauncherChrome : public nacl::SelLdrLauncherBase {
bool enable_dyncode_syscalls,
bool enable_exception_handling,
bool enable_crash_throttling,
- const PP_ManifestService* manifest_service_interface,
+ const PPP_ManifestService* manifest_service_interface,
void* manifest_service_user_data,
PP_Var* error_message,
pp::CompletionCallback callback);
diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.cc b/ppapi/native_client/src/trusted/plugin/service_runtime.cc
index 7406e79..d7c8683 100644
--- a/ppapi/native_client/src/trusted/plugin/service_runtime.cc
+++ b/ppapi/native_client/src/trusted/plugin/service_runtime.cc
@@ -56,6 +56,42 @@
#include "ppapi/native_client/src/trusted/weak_ref/call_on_main_thread.h"
namespace plugin {
+
+class OpenManifestEntryAsyncCallback {
+ public:
+ OpenManifestEntryAsyncCallback(PP_OpenResourceCompletionCallback callback,
+ void* callback_user_data)
+ : callback_(callback), callback_user_data_(callback_user_data) {
+ }
+
+ ~OpenManifestEntryAsyncCallback() {
+ if (callback_)
+ callback_(callback_user_data_, PP_kInvalidFileHandle);
+ }
+
+ void Run(int32_t pp_error) {
+#if defined(OS_WIN)
+ // Currently, this is used only for non-SFI mode, and now the mode is not
+ // supported on windows.
+ // TODO(hidehiko): Support it on Windows when we switch to use
+ // ManifestService also in SFI-mode.
+ NACL_NOTREACHED();
+#elif defined(OS_POSIX)
+ // On posix, PlatformFile is the file descriptor.
+ callback_(callback_user_data_, (pp_error == PP_OK) ? info_.desc : -1);
+ callback_ = NULL;
+#endif
+ }
+
+ NaClFileInfo* mutable_info() { return &info_; }
+
+ private:
+ NaClFileInfo info_;
+ PP_OpenResourceCompletionCallback callback_;
+ void* callback_user_data_;
+ DISALLOW_COPY_AND_ASSIGN(OpenManifestEntryAsyncCallback);
+};
+
namespace {
// For doing crude quota enforcement on writes to temp files.
@@ -92,6 +128,25 @@ class ManifestService {
return true;
}
+ bool OpenResource(const char* entry_key,
+ PP_OpenResourceCompletionCallback callback,
+ void* callback_user_data) {
+ // Release this instance if the ServiceRuntime is already destructed.
+ if (anchor_->is_abandoned()) {
+ callback(callback_user_data, PP_kInvalidFileHandle);
+ delete this;
+ return false;
+ }
+
+ OpenManifestEntryAsyncCallback* open_manifest_callback =
+ new OpenManifestEntryAsyncCallback(callback, callback_user_data);
+ plugin_reverse_->OpenManifestEntryAsync(
+ entry_key,
+ open_manifest_callback->mutable_info(),
+ open_manifest_callback);
+ return true;
+ }
+
static PP_Bool QuitTrampoline(void* user_data) {
return PP_FromBool(static_cast<ManifestService*>(user_data)->Quit());
}
@@ -101,6 +156,15 @@ class ManifestService {
StartupInitializationComplete());
}
+ static PP_Bool OpenResourceTrampoline(
+ void* user_data,
+ const char* entry_key,
+ PP_OpenResourceCompletionCallback callback,
+ void* callback_user_data) {
+ return PP_FromBool(static_cast<ManifestService*>(user_data)->OpenResource(
+ entry_key, callback, callback_user_data));
+ }
+
private:
// Weak reference to check if plugin_reverse is legally accessible or not.
nacl::WeakRefAnchor* anchor_;
@@ -110,13 +174,27 @@ class ManifestService {
};
// Vtable to pass functions to LaunchSelLdr.
-const PP_ManifestService kManifestServiceVTable = {
+const PPP_ManifestService kManifestServiceVTable = {
&ManifestService::QuitTrampoline,
&ManifestService::StartupInitializationCompleteTrampoline,
+ &ManifestService::OpenResourceTrampoline,
};
} // namespace
+OpenManifestEntryResource::~OpenManifestEntryResource() {
+ MaybeRunCallback(PP_ERROR_ABORTED);
+}
+
+void OpenManifestEntryResource::MaybeRunCallback(int32_t pp_error) {
+ if (!callback)
+ return;
+
+ callback->Run(pp_error);
+ delete callback;
+ callback = NULL;
+}
+
PluginReverseInterface::PluginReverseInterface(
nacl::WeakRefAnchor* anchor,
Plugin* plugin,
@@ -195,7 +273,7 @@ bool PluginReverseInterface::OpenManifestEntry(nacl::string url_key,
// the main thread before this function can return. The pointers it contains
// to stack variables will not leak.
OpenManifestEntryResource* to_open =
- new OpenManifestEntryResource(url_key, info, &op_complete);
+ new OpenManifestEntryResource(url_key, info, &op_complete, NULL);
CHECK(to_open != NULL);
NaClLog(4, "PluginReverseInterface::OpenManifestEntry: %s\n",
url_key.c_str());
@@ -245,6 +323,16 @@ bool PluginReverseInterface::OpenManifestEntry(nacl::string url_key,
return true;
}
+void PluginReverseInterface::OpenManifestEntryAsync(
+ const nacl::string& entry_key,
+ struct NaClFileInfo* info,
+ OpenManifestEntryAsyncCallback* callback) {
+ bool op_complete = false;
+ OpenManifestEntryResource to_open(
+ entry_key, info, &op_complete, callback);
+ OpenManifestEntry_MainThreadContinuation(&to_open, PP_OK);
+}
+
// Transfer point from OpenManifestEntry() which runs on the main thread
// (Some PPAPI actions -- like StreamAsFile -- can only run on the main thread).
// OpenManifestEntry() is waiting on a condvar for this continuation to
@@ -265,10 +353,13 @@ void PluginReverseInterface::OpenManifestEntry_MainThreadContinuation(
NaClLog(4, "OpenManifestEntry_MainThreadContinuation: ResolveKey failed\n");
// Failed, and error_info has the details on what happened. Wake
// up requesting thread -- we are done.
- nacl::MutexLocker take(&mu_);
- *p->op_complete_ptr = true; // done...
- p->file_info->desc = -1; // but failed.
- NaClXCondVarBroadcast(&cv_);
+ {
+ nacl::MutexLocker take(&mu_);
+ *p->op_complete_ptr = true; // done...
+ p->file_info->desc = -1; // but failed.
+ NaClXCondVarBroadcast(&cv_);
+ }
+ p->MaybeRunCallback(PP_OK);
return;
}
NaClLog(4,
@@ -281,10 +372,13 @@ void PluginReverseInterface::OpenManifestEntry_MainThreadContinuation(
NaClLog(4,
"OpenManifestEntry_MainThreadContinuation: "
"Requires PNaCl translation -- not supported\n");
- nacl::MutexLocker take(&mu_);
- *p->op_complete_ptr = true; // done...
- p->file_info->desc = -1; // but failed.
- NaClXCondVarBroadcast(&cv_);
+ {
+ nacl::MutexLocker take(&mu_);
+ *p->op_complete_ptr = true; // done...
+ p->file_info->desc = -1; // but failed.
+ NaClXCondVarBroadcast(&cv_);
+ }
+ p->MaybeRunCallback(PP_OK);
return;
}
@@ -302,14 +396,17 @@ void PluginReverseInterface::OpenManifestEntry_MainThreadContinuation(
"OpenManifestEntry_MainThreadContinuation: "
"GetReadonlyPnaclFd failed\n");
}
- nacl::MutexLocker take(&mu_);
- *p->op_complete_ptr = true; // done!
- // TODO(ncbray): enable the fast loading and validation paths for this
- // type of file.
- p->file_info->desc = fd;
- NaClXCondVarBroadcast(&cv_);
+ {
+ nacl::MutexLocker take(&mu_);
+ *p->op_complete_ptr = true; // done!
+ // TODO(ncbray): enable the fast loading and validation paths for this
+ // type of file.
+ p->file_info->desc = fd;
+ NaClXCondVarBroadcast(&cv_);
+ }
NaClLog(4,
"OpenManifestEntry_MainThreadContinuation: GetPnaclFd okay\n");
+ p->MaybeRunCallback(PP_OK);
return;
}
@@ -319,6 +416,9 @@ void PluginReverseInterface::OpenManifestEntry_MainThreadContinuation(
// to create another instance.
OpenManifestEntryResource* open_cont = new OpenManifestEntryResource(*p);
open_cont->url = mapped_url;
+ // Callback is now delegated from p to open_cont. So, here we manually clear
+ // complete callback.
+ p->callback = NULL;
pp::CompletionCallback stream_cc = WeakRefNewCallback(
anchor_,
this,
@@ -346,22 +446,26 @@ void PluginReverseInterface::StreamAsFile_MainThreadContinuation(
NaClLog(4,
"Entered StreamAsFile_MainThreadContinuation\n");
- nacl::MutexLocker take(&mu_);
- if (result == PP_OK) {
- NaClLog(4, "StreamAsFile_MainThreadContinuation: GetFileInfo(%s)\n",
- p->url.c_str());
- *p->file_info = plugin_->GetFileInfo(p->url);
+ {
+ nacl::MutexLocker take(&mu_);
+ if (result == PP_OK) {
+ NaClLog(4, "StreamAsFile_MainThreadContinuation: GetFileInfo(%s)\n",
+ p->url.c_str());
+ *p->file_info = plugin_->GetFileInfo(p->url);
- NaClLog(4,
- "StreamAsFile_MainThreadContinuation: PP_OK, desc %d\n",
- p->file_info->desc);
- } else {
- NaClLog(4,
- "StreamAsFile_MainThreadContinuation: !PP_OK, setting desc -1\n");
- p->file_info->desc = -1;
+ NaClLog(4,
+ "StreamAsFile_MainThreadContinuation: PP_OK, desc %d\n",
+ p->file_info->desc);
+ } else {
+ NaClLog(
+ 4,
+ "StreamAsFile_MainThreadContinuation: !PP_OK, setting desc -1\n");
+ p->file_info->desc = -1;
+ }
+ *p->op_complete_ptr = true;
+ NaClXCondVarBroadcast(&cv_);
}
- *p->op_complete_ptr = true;
- NaClXCondVarBroadcast(&cv_);
+ p->MaybeRunCallback(PP_OK);
}
bool PluginReverseInterface::CloseManifestEntry(int32_t desc) {
diff --git a/ppapi/native_client/src/trusted/plugin/service_runtime.h b/ppapi/native_client/src/trusted/plugin/service_runtime.h
index 07850d4..ca12764 100644
--- a/ppapi/native_client/src/trusted/plugin/service_runtime.h
+++ b/ppapi/native_client/src/trusted/plugin/service_runtime.h
@@ -41,6 +41,7 @@ namespace plugin {
class ErrorInfo;
class Manifest;
+class OpenManifestEntryAsyncCallback;
class Plugin;
class SrpcClient;
class ServiceRuntime;
@@ -87,13 +88,19 @@ struct OpenManifestEntryResource {
public:
OpenManifestEntryResource(const std::string& target_url,
struct NaClFileInfo* finfo,
- bool* op_complete)
+ bool* op_complete,
+ OpenManifestEntryAsyncCallback* callback)
: url(target_url),
file_info(finfo),
- op_complete_ptr(op_complete) {}
+ op_complete_ptr(op_complete),
+ callback(callback) {}
+ ~OpenManifestEntryResource();
+ void MaybeRunCallback(int32_t pp_error);
+
std::string url;
struct NaClFileInfo* file_info;
bool* op_complete_ptr;
+ OpenManifestEntryAsyncCallback* callback;
};
struct CloseManifestEntryResource {
@@ -170,6 +177,15 @@ class PluginReverseInterface: public nacl::ReverseInterface {
const pp::FileIO& file_io);
void AddTempQuotaManagedFile(const nacl::string& file_id);
+ // This is a sibling of OpenManifestEntry. While OpenManifestEntry is
+ // a sync function and must be called on a non-main thread,
+ // OpenManifestEntryAsync must be called on the main thread. Upon completion
+ // (even on error), callback will be invoked. The caller has responsibility
+ // to keep the memory passed to info until callback is invoked.
+ void OpenManifestEntryAsync(const nacl::string& key,
+ struct NaClFileInfo* info,
+ OpenManifestEntryAsyncCallback* callback);
+
protected:
virtual void PostMessage_MainThreadContinuation(PostMessageResource* p,
int32_t err);
diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
index b6efef0..4713148 100644
--- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
+++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c
@@ -3082,11 +3082,11 @@ static int32_t Pnacl_M33_PPB_IsolatedFileSystem_Private_Open(PP_Instance instanc
/* End wrapper methods for PPB_IsolatedFileSystem_Private_0_2 */
-/* Not generating wrapper methods for PP_ManifestService_1_0 */
+/* Not generating wrapper methods for PPP_ManifestService_1_0 */
/* Begin wrapper methods for PPB_NaCl_Private_1_0 */
-static void Pnacl_M25_PPB_NaCl_Private_LaunchSelLdr(PP_Instance instance, const char* alleged_url, PP_Bool uses_irt, PP_Bool uses_ppapi, PP_Bool uses_nonsfi_mode, PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, PP_Bool enable_crash_throttling, const struct PP_ManifestService_1_0* manifest_service_interface, void* manifest_service_user_data, void* imc_handle, struct PP_Var* error_message, struct PP_CompletionCallback* callback) {
+static void Pnacl_M25_PPB_NaCl_Private_LaunchSelLdr(PP_Instance instance, const char* alleged_url, PP_Bool uses_irt, PP_Bool uses_ppapi, PP_Bool uses_nonsfi_mode, PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, PP_Bool enable_crash_throttling, const struct PPP_ManifestService_1_0* manifest_service_interface, void* manifest_service_user_data, void* imc_handle, struct PP_Var* error_message, struct PP_CompletionCallback* callback) {
const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface;
iface->LaunchSelLdr(instance, alleged_url, uses_irt, uses_ppapi, uses_nonsfi_mode, enable_ppapi_dev, enable_dyncode_syscalls, enable_exception_handling, enable_crash_throttling, manifest_service_interface, manifest_service_user_data, imc_handle, error_message, *callback);
}
@@ -4971,10 +4971,10 @@ static const struct PPB_IsolatedFileSystem_Private_0_2 Pnacl_Wrappers_PPB_Isolat
.Open = (int32_t (*)(PP_Instance instance, PP_IsolatedFileSystemType_Private type, PP_Resource* file_system, struct PP_CompletionCallback callback))&Pnacl_M33_PPB_IsolatedFileSystem_Private_Open
};
-/* Not generating wrapper interface for PP_ManifestService_1_0 */
+/* Not generating wrapper interface for PPP_ManifestService_1_0 */
static const struct PPB_NaCl_Private_1_0 Pnacl_Wrappers_PPB_NaCl_Private_1_0 = {
- .LaunchSelLdr = (void (*)(PP_Instance instance, const char* alleged_url, PP_Bool uses_irt, PP_Bool uses_ppapi, PP_Bool uses_nonsfi_mode, PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, PP_Bool enable_crash_throttling, const struct PP_ManifestService_1_0* manifest_service_interface, void* manifest_service_user_data, void* imc_handle, struct PP_Var* error_message, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_LaunchSelLdr,
+ .LaunchSelLdr = (void (*)(PP_Instance instance, const char* alleged_url, PP_Bool uses_irt, PP_Bool uses_ppapi, PP_Bool uses_nonsfi_mode, PP_Bool enable_ppapi_dev, PP_Bool enable_dyncode_syscalls, PP_Bool enable_exception_handling, PP_Bool enable_crash_throttling, const struct PPP_ManifestService_1_0* manifest_service_interface, void* manifest_service_user_data, void* imc_handle, struct PP_Var* error_message, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_LaunchSelLdr,
.StartPpapiProxy = (PP_Bool (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_StartPpapiProxy,
.UrandomFD = (int32_t (*)(void))&Pnacl_M25_PPB_NaCl_Private_UrandomFD,
.Are3DInterfacesDisabled = (PP_Bool (*)(void))&Pnacl_M25_PPB_NaCl_Private_Are3DInterfacesDisabled,
diff --git a/ppapi/ppapi_nacl_test_common.gypi b/ppapi/ppapi_nacl_test_common.gypi
index b5c60555..0d9b676 100644
--- a/ppapi/ppapi_nacl_test_common.gypi
+++ b/ppapi/ppapi_nacl_test_common.gypi
@@ -19,6 +19,7 @@
'nacl_newlib_out_dir': '<(PRODUCT_DIR)/>(nexe_destination_dir)/newlib',
'nacl_glibc_out_dir': '<(PRODUCT_DIR)/>(nexe_destination_dir)/glibc',
'nacl_pnacl_newlib_out_dir': '<(PRODUCT_DIR)/>(nexe_destination_dir)/pnacl',
+ 'nacl_pnacl_newlib_nonsfi_out_dir': '<(PRODUCT_DIR)/>(nexe_destination_dir)/nonsfi',
'target_conditions': [
['nexe_target!=""', {
# These variables are used for nexe building and for library building.
@@ -33,6 +34,7 @@
'nmf_glibc%': '>(nacl_glibc_out_dir)/>(nexe_target).nmf',
'out_pnacl_newlib%': '>(nacl_pnacl_newlib_out_dir)/>(nexe_target)_newlib_pnacl.pexe',
'nmf_pnacl_newlib%': '>(nacl_pnacl_newlib_out_dir)/>(nexe_target).nmf',
+ 'out_pnacl_newlib_x86_32_nonsfi_nexe': '>(nacl_pnacl_newlib_nonsfi_out_dir)/>(nexe_target)_pnacl_newlib_x32_nonsfi.nexe',
}],
],
},
@@ -62,7 +64,8 @@
},
],
}],
- ['test_files!=[] and build_pnacl_newlib==1 and disable_pnacl==0', {
+ # Nonsfi pnacl copy is covered below. Currently, these are exclusive.
+ ['test_files!=[] and build_pnacl_newlib==1 and disable_pnacl==0 and enable_x86_32_nonsfi==0', {
'copies': [
{
'destination': '>(nacl_pnacl_newlib_out_dir)',
@@ -72,6 +75,16 @@
},
],
}],
+ ['test_files!=[] and build_pnacl_newlib==1 and enable_x86_32_nonsfi==1', {
+ 'copies': [
+ {
+ 'destination': '>(nacl_pnacl_newlib_nonsfi_out_dir)',
+ 'files': [
+ '>@(test_files)',
+ ],
+ },
+ ],
+ }],
['nexe_target!=""', {
'variables': {
# Patch over the fact that untrusted.gypi doesn't define these in all
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 10cde4e..5fe5e968 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -756,6 +756,11 @@ IPC_MESSAGE_CONTROL1(PpapiHostMsg_ChannelCreated,
// Notify the renderer that the PPAPI channel gets ready in the plugin.
IPC_MESSAGE_CONTROL0(PpapiHostMsg_StartupInitializationComplete);
+// Calls renderer to open a resource file for nacl_irt_open_resource().
+IPC_SYNC_MESSAGE_CONTROL1_1(PpapiHostMsg_OpenResource,
+ std::string /* key */,
+ ppapi::proxy::SerializedHandle /* fd */)
+
// Logs the given message to the console of all instances.
IPC_MESSAGE_CONTROL4(PpapiHostMsg_LogWithSource,
PP_Instance /* instance */,