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

Unified Diff: ppapi/proxy/irt_shim_ppapi.c

Issue 164373010: Split the PNaCl IRT shim into 3 pieces, and include one piece into IRT. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix up mips Created 6 years, 10 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
« ppapi/proxy/irt_ppapi.c ('K') | « ppapi/proxy/irt_shim_ppapi.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/irt_shim_ppapi.c
diff --git a/ppapi/proxy/irt_shim_ppapi.c b/ppapi/proxy/irt_shim_ppapi.c
new file mode 100644
index 0000000000000000000000000000000000000000..122cb365db0db342eb7f4876d2c6005d42763c2b
--- /dev/null
+++ b/ppapi/proxy/irt_shim_ppapi.c
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+#include "ppapi/proxy/irt_shim_ppapi.h"
+
+#include "native_client/src/untrusted/irt/irt.h"
+#include "ppapi/nacl_irt/irt_ppapi.h"
+#include "ppapi/native_client/src/shared/ppapi_proxy/ppruntime.h"
Mark Seaborn 2014/02/26 22:11:03 You shouldn't need ppruntime.h. It's now for user
jvoung (off chromium) 2014/02/27 01:39:55 Done.
+#include "ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.h"
+#include "ppapi/proxy/plugin_main_irt.h"
+
+/*
+ * Defines a version of the version irt_ppapi_start and of the irt_ppapihook
+ * that returns a shimmed GetInterface for PNaCl.
+ *
+ * The hook will be linked into the IRT but it is considered unstable,
+ * should not use that IRT hook. Instead PNaCl nexes should embed the
Mark Seaborn 2014/02/26 22:11:03 Missing noun? "Stable nexes should not use...".
jvoung (off chromium) 2014/02/27 01:39:55 Done.
+ * irt_shim_ppapi_start and the shim functions directly into the nexe
+ * for stability.
Mark Seaborn 2014/02/26 22:11:03 "ABI stability" (to clarify)
jvoung (off chromium) 2014/02/27 01:39:55 Done.
+ */
+
+static struct PP_StartFunctions user_start_functions;
Mark Seaborn 2014/02/26 22:11:03 Nit: add "g_" prefix to warn about use of global s
jvoung (off chromium) 2014/02/27 01:39:55 Done.
+
+static int32_t shim_PPPInitializeModule(PP_Module module_id,
+ PPB_GetInterface get_browser_intf) {
+ /* Record the original PPB_GetInterface and provide a shimmed one. */
Mark Seaborn 2014/02/26 22:11:03 Nit: fix indentation to line up
jvoung (off chromium) 2014/02/27 01:39:55 Done.
+ __set_real_Pnacl_PPBGetInterface(get_browser_intf);
+ return (*user_start_functions.PPP_InitializeModule)(module_id,
+ &__Pnacl_PPBGetInterface);
+}
+
+static void shim_PPPShutdownModule() {
+ (*user_start_functions.PPP_ShutdownModule)();
+}
+
+#if PNACL_SHIM_AOT
+ /*
+ * This will be discovered and set by the shim, since we cannot link
+ * against the IRT directly in the AOT library.
+ */
+int (*real_irt_ppapi_start)(const struct PP_StartFunctions *) = NULL;
+#else
+ /*
+ * Otherwise, when linking directly into the IRT, we can refer to the
+ * real irt_ppapi_start from irt_ppapi.
+ */
+extern int irt_ppapi_start(const struct PP_StartFunctions *);
+static int (* const real_irt_ppapi_start)(const struct PP_StartFunctions *) =
+ &irt_ppapi_start;
+#endif
+
+int irt_shim_ppapi_start(const struct PP_StartFunctions *funcs) {
+ user_start_functions = *funcs;
+ /*
+ * Record the original PPP_GetInterface and provide a shimmed one
+ * via wrapped_ppapi_methods.
+ */
+ const struct PP_StartFunctions wrapped_ppapi_methods = {
+ shim_PPPInitializeModule,
+ shim_PPPShutdownModule,
+ __Pnacl_PPPGetInterface
+ };
+ __set_real_Pnacl_PPPGetInterface(user_start_functions.PPP_GetInterface);
+ /*
+ * Invoke the IRT's ppapi_start interface with the wrapped interface.
+ */
+ return (*real_irt_ppapi_start)(&wrapped_ppapi_methods);
+}
+
+#if !PNACL_SHIM_AOT
+const struct nacl_irt_ppapihook nacl_irt_ppapihook_pnacl_private = {
+ irt_shim_ppapi_start,
+ PpapiPluginRegisterThreadCreator,
+};
+#endif
« ppapi/proxy/irt_ppapi.c ('K') | « ppapi/proxy/irt_shim_ppapi.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698