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

Side by Side Diff: ppapi/nacl_irt/irt_ppapi.cc

Issue 1245893002: Reland of NaCl cleanup: Split out irt_interfaces.cc from irt_ppapi.cc (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 5 years, 5 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/nacl_irt/irt_ppapi.h ('k') | ppapi/nacl_irt/irt_start.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <unistd.h>
6
7 #include "build/build_config.h" 5 #include "build/build_config.h"
8 #include "native_client/src/public/irt_core.h" 6 #include "ppapi/nacl_irt/irt_interfaces.h"
9 #include "native_client/src/trusted/service_runtime/include/sys/unistd.h"
10 #include "native_client/src/untrusted/irt/irt.h"
11 #include "ppapi/nacl_irt/irt_manifest.h"
12 #include "ppapi/nacl_irt/irt_ppapi.h" 7 #include "ppapi/nacl_irt/irt_ppapi.h"
13 #include "ppapi/nacl_irt/plugin_main.h" 8 #include "ppapi/nacl_irt/plugin_main.h"
14 #include "ppapi/nacl_irt/public/irt_ppapi.h" 9 #include "ppapi/nacl_irt/public/irt_ppapi.h"
15 #include "ppapi/native_client/src/untrusted/pnacl_irt_shim/irt_shim_ppapi.h"
16 10
17 static struct PP_StartFunctions g_pp_functions; 11 static struct PP_StartFunctions g_pp_functions;
18 12
19 int irt_ppapi_start(const struct PP_StartFunctions* funcs) { 13 int irt_ppapi_start(const struct PP_StartFunctions* funcs) {
20 g_pp_functions = *funcs; 14 g_pp_functions = *funcs;
21 return PpapiPluginMain(); 15 return PpapiPluginMain();
22 } 16 }
23 17
24 int32_t PPP_InitializeModule(PP_Module module_id, 18 int32_t PPP_InitializeModule(PP_Module module_id,
25 PPB_GetInterface get_browser_interface) { 19 PPB_GetInterface get_browser_interface) {
26 return g_pp_functions.PPP_InitializeModule(module_id, get_browser_interface); 20 return g_pp_functions.PPP_InitializeModule(module_id, get_browser_interface);
27 } 21 }
28 22
29 void PPP_ShutdownModule(void) { 23 void PPP_ShutdownModule(void) {
30 g_pp_functions.PPP_ShutdownModule(); 24 g_pp_functions.PPP_ShutdownModule();
31 } 25 }
32 26
33 const void* PPP_GetInterface(const char* interface_name) { 27 const void* PPP_GetInterface(const char* interface_name) {
34 return g_pp_functions.PPP_GetInterface(interface_name); 28 return g_pp_functions.PPP_GetInterface(interface_name);
35 } 29 }
36 30
37 static const struct nacl_irt_ppapihook nacl_irt_ppapihook = { 31 const struct nacl_irt_ppapihook nacl_irt_ppapihook = {
38 irt_ppapi_start, 32 irt_ppapi_start,
39 PpapiPluginRegisterThreadCreator, 33 PpapiPluginRegisterThreadCreator,
40 }; 34 };
41
42 #if defined(OS_NACL_SFI)
43 static int ppapihook_pnacl_private_filter(void) {
44 int pnacl_mode = sysconf(NACL_ABI__SC_NACL_PNACL_MODE);
45 if (pnacl_mode == -1)
46 return 0;
47 return pnacl_mode;
48 }
49 #endif
50
51 static const nacl_irt_resource_open kIrtResourceOpen = {
52 ppapi::IrtOpenResource,
53 };
54
55 #if defined(OS_NACL_SFI)
56 static int not_pnacl_filter(void) {
57 int pnacl_mode = sysconf(NACL_ABI__SC_NACL_PNACL_MODE);
58 if (pnacl_mode == -1)
59 return 0;
60 return !pnacl_mode;
61 }
62 #endif
63
64 static const struct nacl_irt_interface irt_interfaces[] = {
65 { NACL_IRT_PPAPIHOOK_v0_1, &nacl_irt_ppapihook, sizeof(nacl_irt_ppapihook),
66 NULL },
67 #if defined(OS_NACL_SFI)
68 { NACL_IRT_PPAPIHOOK_PNACL_PRIVATE_v0_1,
69 &nacl_irt_ppapihook_pnacl_private, sizeof(nacl_irt_ppapihook_pnacl_private),
70 ppapihook_pnacl_private_filter },
71 #endif
72 { NACL_IRT_RESOURCE_OPEN_v0_1, &kIrtResourceOpen,
73 sizeof(kIrtResourceOpen),
74 #if defined(OS_NACL_SFI)
75 not_pnacl_filter,
76 #else
77 // If we change PNaCl to use Non-SFI Mode on the open web,
78 // we should add a filter here.
79 NULL,
80 #endif
81 },
82 };
83
84 size_t chrome_irt_query(const char* interface_ident,
85 void* table, size_t tablesize) {
86 size_t result = nacl_irt_query_list(interface_ident,
87 table,
88 tablesize,
89 irt_interfaces,
90 sizeof(irt_interfaces));
91 if (result != 0)
92 return result;
93
94 return nacl_irt_query_core(interface_ident, table, tablesize);
95 }
OLDNEW
« no previous file with comments | « ppapi/nacl_irt/irt_ppapi.h ('k') | ppapi/nacl_irt/irt_start.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698