OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2014 The Chromium Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can be | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 #include "ppapi/proxy/irt_shim_ppapi.h" | |
8 | |
9 #include "native_client/src/untrusted/irt/irt.h" | |
10 #include "ppapi/nacl_irt/irt_ppapi.h" | |
11 #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.
| |
12 #include "ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.h" | |
13 #include "ppapi/proxy/plugin_main_irt.h" | |
14 | |
15 /* | |
16 * Defines a version of the version irt_ppapi_start and of the irt_ppapihook | |
17 * that returns a shimmed GetInterface for PNaCl. | |
18 * | |
19 * The hook will be linked into the IRT but it is considered unstable, | |
20 * 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.
| |
21 * irt_shim_ppapi_start and the shim functions directly into the nexe | |
22 * for stability. | |
Mark Seaborn
2014/02/26 22:11:03
"ABI stability" (to clarify)
jvoung (off chromium)
2014/02/27 01:39:55
Done.
| |
23 */ | |
24 | |
25 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.
| |
26 | |
27 static int32_t shim_PPPInitializeModule(PP_Module module_id, | |
28 PPB_GetInterface get_browser_intf) { | |
29 /* 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.
| |
30 __set_real_Pnacl_PPBGetInterface(get_browser_intf); | |
31 return (*user_start_functions.PPP_InitializeModule)(module_id, | |
32 &__Pnacl_PPBGetInterface); | |
33 } | |
34 | |
35 static void shim_PPPShutdownModule() { | |
36 (*user_start_functions.PPP_ShutdownModule)(); | |
37 } | |
38 | |
39 #if PNACL_SHIM_AOT | |
40 /* | |
41 * This will be discovered and set by the shim, since we cannot link | |
42 * against the IRT directly in the AOT library. | |
43 */ | |
44 int (*real_irt_ppapi_start)(const struct PP_StartFunctions *) = NULL; | |
45 #else | |
46 /* | |
47 * Otherwise, when linking directly into the IRT, we can refer to the | |
48 * real irt_ppapi_start from irt_ppapi. | |
49 */ | |
50 extern int irt_ppapi_start(const struct PP_StartFunctions *); | |
51 static int (* const real_irt_ppapi_start)(const struct PP_StartFunctions *) = | |
52 &irt_ppapi_start; | |
53 #endif | |
54 | |
55 int irt_shim_ppapi_start(const struct PP_StartFunctions *funcs) { | |
56 user_start_functions = *funcs; | |
57 /* | |
58 * Record the original PPP_GetInterface and provide a shimmed one | |
59 * via wrapped_ppapi_methods. | |
60 */ | |
61 const struct PP_StartFunctions wrapped_ppapi_methods = { | |
62 shim_PPPInitializeModule, | |
63 shim_PPPShutdownModule, | |
64 __Pnacl_PPPGetInterface | |
65 }; | |
66 __set_real_Pnacl_PPPGetInterface(user_start_functions.PPP_GetInterface); | |
67 /* | |
68 * Invoke the IRT's ppapi_start interface with the wrapped interface. | |
69 */ | |
70 return (*real_irt_ppapi_start)(&wrapped_ppapi_methods); | |
71 } | |
72 | |
73 #if !PNACL_SHIM_AOT | |
74 const struct nacl_irt_ppapihook nacl_irt_ppapihook_pnacl_private = { | |
75 irt_shim_ppapi_start, | |
76 PpapiPluginRegisterThreadCreator, | |
77 }; | |
78 #endif | |
OLD | NEW |