Chromium Code Reviews| Index: ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.c |
| diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.c |
| index 27f6ee7e5a96781de41140f80b8536dac0a78f00..97fbca0720cb8900e44cf9ad3e3d702c538ad07d 100644 |
| --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.c |
| +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.c |
| @@ -13,6 +13,7 @@ |
| #include "ppapi/nacl_irt/irt_ppapi.h" |
| #include "ppapi/native_client/src/shared/ppapi_proxy/ppruntime.h" |
| #include "ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.h" |
| +#include "ppapi/proxy/irt_shim_ppapi.h" |
| /* |
| * This is a whitelist of NaCl IRT interfaces that are exposed under |
| @@ -89,55 +90,9 @@ static int is_irt_interface_whitelisted(const char *interface_name) { |
| return 0; |
| } |
| -TYPE_nacl_irt_query __pnacl_real_irt_interface = NULL; |
| +TYPE_nacl_irt_query __pnacl_real_irt_query_func = NULL; |
| -/* |
| - * These remember the interface pointers the user registers by calling the |
| - * IRT entry point. |
| - */ |
| -static struct PP_StartFunctions user_start_functions; |
| - |
| -static int32_t wrap_PPPInitializeModule(PP_Module module_id, |
| - PPB_GetInterface get_browser_intf) { |
| - __set_real_Pnacl_PPBGetInterface(get_browser_intf); |
| - /* |
| - * Calls from user code to the PPB interfaces pass through here and may |
| - * require shims to convert the ABI. |
| - */ |
| - return (*user_start_functions.PPP_InitializeModule)(module_id, |
| - &__Pnacl_PPBGetInterface); |
| -} |
| - |
| -static void wrap_PPPShutdownModule() { |
| - (*user_start_functions.PPP_ShutdownModule)(); |
| -} |
| - |
| -static const struct PP_StartFunctions wrapped_ppapi_methods = { |
| - wrap_PPPInitializeModule, |
| - wrap_PPPShutdownModule, |
| - /* |
| - * Calls from the IRT to the user plugin pass through here and may require |
| - * shims to convert the ABI. |
| - */ |
| - __Pnacl_PPPGetInterface |
| -}; |
| - |
| -static struct nacl_irt_ppapihook real_irt_ppapi_hook; |
| - |
| -static int wrap_ppapi_start(const struct PP_StartFunctions *funcs) { |
| - /* |
| - * Save the user's real bindings for the start functions. |
| - */ |
| - user_start_functions = *funcs; |
| - __set_real_Pnacl_PPPGetInterface(user_start_functions.PPP_GetInterface); |
| - |
| - /* |
| - * Invoke the IRT's ppapi_start interface with the wrapped interface. |
| - */ |
| - return (*real_irt_ppapi_hook.ppapi_start)(&wrapped_ppapi_methods); |
| -} |
| - |
| -size_t __pnacl_irt_interface_wrapper(const char *interface_ident, |
| +size_t __pnacl_wrap_irt_query_func(const char *interface_ident, |
| void *table, size_t tablesize) { |
| if (!is_irt_interface_whitelisted(interface_ident)) |
| return 0; |
| @@ -153,23 +108,39 @@ size_t __pnacl_irt_interface_wrapper(const char *interface_ident, |
| /* |
| * The interface is not wrapped, so use the real interface. |
| */ |
| - return (*__pnacl_real_irt_interface)(interface_ident, table, tablesize); |
| + return (*__pnacl_real_irt_query_func)(interface_ident, table, tablesize); |
| } |
| - if ((*__pnacl_real_irt_interface)(NACL_IRT_PPAPIHOOK_v0_1, |
| - &real_irt_ppapi_hook, |
| - sizeof real_irt_ppapi_hook) != |
| +#if !PNACL_SHIM_AOT |
| + /* |
| + * For the PNaCl in-the-browser, redirect to using |
|
Mark Seaborn
2014/02/26 22:11:03
Nit: drop "the"?
jvoung (off chromium)
2014/02/27 01:39:55
Done.
|
| + * NACL_IRT_PPAPIHOOK_PNACL_PRIVATE_v0_1 instead of NACL_IRT_PPAPIHOOK_v0_1. |
| + */ |
| + return (*__pnacl_real_irt_query_func)(NACL_IRT_PPAPIHOOK_PNACL_PRIVATE_v0_1, |
| + table, tablesize); |
| +#else |
| + /* |
| + * For offline generated nexes, avoid depending on the private |
| + * NACL_IRT_PPAPIHOOK_PNACL_PRIVATE_v0_1 interface, and just do the |
| + * overriding here manually. |
| + */ |
| + struct nacl_irt_ppapihook real_irt_ppapi_hook; |
| + if ((*__pnacl_real_irt_query_func)(NACL_IRT_PPAPIHOOK_v0_1, |
| + &real_irt_ppapi_hook, |
| + sizeof real_irt_ppapi_hook) != |
| sizeof real_irt_ppapi_hook) { |
| return 0; |
| } |
| + real_irt_ppapi_start = real_irt_ppapi_hook.ppapi_start; |
| /* |
| * Copy the interface structure into the client. |
| */ |
| struct nacl_irt_ppapihook *dest = table; |
| if (sizeof *dest <= tablesize) { |
| - dest->ppapi_start = wrap_ppapi_start; |
| + dest->ppapi_start = irt_shim_ppapi_start; |
| dest->ppapi_register_thread_creator = |
| real_irt_ppapi_hook.ppapi_register_thread_creator; |
| return sizeof *dest; |
| } |
| return 0; |
| +#endif |
| } |