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

Side by Side Diff: ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.c

Issue 10908085: Add pnacl shims to the chrome build. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: presubmit Created 8 years, 3 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 unified diff | Download patch
« no previous file with comments | « ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_entry.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2012 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 "native_client/src/untrusted/pnacl_irt_shim/shim_ppapi.h"
8
9 #include <string.h>
10 #include "native_client/src/shared/ppapi_proxy/ppruntime.h"
11 #include "native_client/src/untrusted/irt/irt.h"
12 #include "native_client/src/untrusted/irt/irt_ppapi.h"
13 #include "ppapi/generators/pnacl_shim.h"
14
15 TYPE_nacl_irt_query __pnacl_real_irt_interface;
16
17 /*
18 * These remember the interface pointers the user registers by calling the
19 * IRT entry point.
20 */
21 static struct PP_StartFunctions user_start_functions;
22
23 static int32_t wrap_PPPInitializeModule(PP_Module module_id,
24 PPB_GetInterface get_browser_intf) {
25 __set_real_Pnacl_PPBGetInterface(get_browser_intf);
26 /*
27 * Calls from user code to the PPB interfaces pass through here and may
28 * require shims to convert the ABI.
29 */
30 return (*user_start_functions.PPP_InitializeModule)(module_id,
31 &__Pnacl_PPBGetInterface);
32 }
33
34 static void wrap_PPPShutdownModule() {
35 (*user_start_functions.PPP_ShutdownModule)();
36 }
37
38 static const struct PP_StartFunctions wrapped_ppapi_methods = {
39 wrap_PPPInitializeModule,
40 wrap_PPPShutdownModule,
41 /*
42 * Calls from the IRT to the user plugin pass through here and may require
43 * shims to convert the ABI.
44 */
45 __Pnacl_PPPGetInterface
46 };
47
48 static struct nacl_irt_ppapihook real_irt_ppapi_hook;
49
50 static int wrap_ppapi_start(const struct PP_StartFunctions *funcs) {
51 /*
52 * Save the user's real bindings for the start functions.
53 */
54 user_start_functions = *funcs;
55 __set_real_Pnacl_PPPGetInterface(user_start_functions.PPP_GetInterface);
56
57 /*
58 * Invoke the IRT's ppapi_start interface with the wrapped interface.
59 */
60 return (*real_irt_ppapi_hook.ppapi_start)(&wrapped_ppapi_methods);
61 }
62
63 static struct nacl_irt_ppapihook ppapi_hook = {
64 wrap_ppapi_start,
65 NULL
66 };
67
68 size_t __pnacl_irt_interface_wrapper(const char *interface_ident,
69 void *table, size_t tablesize) {
70 /*
71 * Note there is a benign race in initializing the wrapper.
72 * We build the "hook" structure by copying from the IRT's hook and then
73 * writing our wrapper for the ppapi method. Two threads may end up
74 * attempting to do this simultaneously, which should not be a problem,
75 * as they are writing the same values.
76 */
77 if (0 != strcmp(interface_ident, NACL_IRT_PPAPIHOOK_v0_1)) {
78 /*
79 * The interface is not wrapped, so use the real interface.
80 */
81 return (*__pnacl_real_irt_interface)(interface_ident, table, tablesize);
82 }
83 if ((*__pnacl_real_irt_interface)(NACL_IRT_PPAPIHOOK_v0_1,
84 &real_irt_ppapi_hook,
85 sizeof real_irt_ppapi_hook) !=
86 sizeof real_irt_ppapi_hook) {
87 return -1;
88 }
89 /*
90 * Copy the portion of the ppapihook interface that is not wrapped.
91 */
92 ppapi_hook.ppapi_register_thread_creator =
93 real_irt_ppapi_hook.ppapi_register_thread_creator;
94 /*
95 * Copy the interface structure into the client.
96 */
97 if (sizeof ppapi_hook <= tablesize) {
98 memcpy(table, &ppapi_hook, sizeof ppapi_hook);
99 return sizeof ppapi_hook;
100 }
101 return 0;
102 }
OLDNEW
« no previous file with comments | « ppapi/native_client/src/untrusted/pnacl_irt_shim/shim_entry.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698