Chromium Code Reviews| OLD | NEW |
|---|---|
| 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> | 5 #include <unistd.h> |
| 6 | 6 |
| 7 #include "build/build_config.h" | |
| 7 #include "native_client/src/public/irt_core.h" | 8 #include "native_client/src/public/irt_core.h" |
| 8 #include "native_client/src/trusted/service_runtime/include/sys/unistd.h" | 9 #include "native_client/src/trusted/service_runtime/include/sys/unistd.h" |
| 9 #include "native_client/src/untrusted/irt/irt.h" | 10 #include "native_client/src/untrusted/irt/irt.h" |
| 10 #include "native_client/src/untrusted/irt/irt_private.h" | 11 #include "native_client/src/untrusted/irt/irt_private.h" |
| 11 #include "ppapi/nacl_irt/irt_manifest.h" | 12 #include "ppapi/nacl_irt/irt_manifest.h" |
| 12 #include "ppapi/nacl_irt/irt_ppapi.h" | 13 #include "ppapi/nacl_irt/irt_ppapi.h" |
| 13 #include "ppapi/nacl_irt/plugin_main.h" | 14 #include "ppapi/nacl_irt/plugin_main.h" |
| 14 #include "ppapi/nacl_irt/public/irt_ppapi.h" | 15 #include "ppapi/nacl_irt/public/irt_ppapi.h" |
| 15 #include "ppapi/native_client/src/untrusted/pnacl_irt_shim/irt_shim_ppapi.h" | 16 #include "ppapi/native_client/src/untrusted/pnacl_irt_shim/irt_shim_ppapi.h" |
| 16 | 17 |
| 17 static struct PP_StartFunctions g_pp_functions; | 18 static struct PP_StartFunctions g_pp_functions; |
| 18 | 19 |
| 19 int irt_ppapi_start(const struct PP_StartFunctions* funcs) { | 20 int irt_ppapi_start(const struct PP_StartFunctions* funcs) { |
| 21 #if !defined(OS_NACL_NONSFI) | |
|
Mark Seaborn
2014/10/28 21:57:23
If you're going to add a conditional, please add a
| |
| 20 // Disable NaCl's open_resource() interface on this thread. | 22 // Disable NaCl's open_resource() interface on this thread. |
| 21 g_is_main_thread = 1; | 23 g_is_main_thread = 1; |
|
hidehiko
2014/10/28 20:14:00
FYI: Is this flag still needed? IIUC, this is no l
Mark Seaborn
2014/10/28 21:57:23
Yeah, it is no longer checked by open_resource() s
hidehiko
2014/10/29 06:00:14
Ok. +1 for adding the test. Let me look into it la
| |
| 24 #endif | |
| 22 | 25 |
| 23 g_pp_functions = *funcs; | 26 g_pp_functions = *funcs; |
| 24 return PpapiPluginMain(); | 27 return PpapiPluginMain(); |
| 25 } | 28 } |
| 26 | 29 |
| 27 int32_t PPP_InitializeModule(PP_Module module_id, | 30 int32_t PPP_InitializeModule(PP_Module module_id, |
| 28 PPB_GetInterface get_browser_interface) { | 31 PPB_GetInterface get_browser_interface) { |
| 29 return g_pp_functions.PPP_InitializeModule(module_id, get_browser_interface); | 32 return g_pp_functions.PPP_InitializeModule(module_id, get_browser_interface); |
| 30 } | 33 } |
| 31 | 34 |
| 32 void PPP_ShutdownModule(void) { | 35 void PPP_ShutdownModule(void) { |
| 33 g_pp_functions.PPP_ShutdownModule(); | 36 g_pp_functions.PPP_ShutdownModule(); |
| 34 } | 37 } |
| 35 | 38 |
| 36 const void* PPP_GetInterface(const char* interface_name) { | 39 const void* PPP_GetInterface(const char* interface_name) { |
| 37 return g_pp_functions.PPP_GetInterface(interface_name); | 40 return g_pp_functions.PPP_GetInterface(interface_name); |
| 38 } | 41 } |
| 39 | 42 |
| 40 static const struct nacl_irt_ppapihook nacl_irt_ppapihook = { | 43 static const struct nacl_irt_ppapihook nacl_irt_ppapihook = { |
| 41 irt_ppapi_start, | 44 irt_ppapi_start, |
| 42 PpapiPluginRegisterThreadCreator, | 45 PpapiPluginRegisterThreadCreator, |
| 43 }; | 46 }; |
| 44 | 47 |
| 48 #if defined(OS_NACL_SFI) | |
| 45 static int ppapihook_pnacl_private_filter(void) { | 49 static int ppapihook_pnacl_private_filter(void) { |
| 46 int pnacl_mode = sysconf(NACL_ABI__SC_NACL_PNACL_MODE); | 50 int pnacl_mode = sysconf(NACL_ABI__SC_NACL_PNACL_MODE); |
| 47 if (pnacl_mode == -1) | 51 if (pnacl_mode == -1) |
| 48 return 0; | 52 return 0; |
| 49 return pnacl_mode; | 53 return pnacl_mode; |
| 50 } | 54 } |
| 55 #endif | |
| 51 | 56 |
| 52 static const nacl_irt_resource_open kIrtResourceOpen = { | 57 static const nacl_irt_resource_open kIrtResourceOpen = { |
| 53 ppapi::IrtOpenResource, | 58 ppapi::IrtOpenResource, |
| 54 }; | 59 }; |
| 55 | 60 |
| 56 static int not_pnacl_filter(void) { | 61 static int not_pnacl_filter(void) { |
|
Mark Seaborn
2014/10/28 21:57:23
How come the compiler doesn't warn about this bein
hidehiko
2014/10/29 06:00:14
Good catch. Guarded by #ifdef.
We have -Wno-unused
| |
| 57 int pnacl_mode = sysconf(NACL_ABI__SC_NACL_PNACL_MODE); | 62 int pnacl_mode = sysconf(NACL_ABI__SC_NACL_PNACL_MODE); |
| 58 if (pnacl_mode == -1) | 63 if (pnacl_mode == -1) |
| 59 return 0; | 64 return 0; |
| 60 return !pnacl_mode; | 65 return !pnacl_mode; |
| 61 } | 66 } |
| 62 | 67 |
| 63 static const struct nacl_irt_interface irt_interfaces[] = { | 68 static const struct nacl_irt_interface irt_interfaces[] = { |
| 64 { NACL_IRT_PPAPIHOOK_v0_1, &nacl_irt_ppapihook, sizeof(nacl_irt_ppapihook), | 69 { NACL_IRT_PPAPIHOOK_v0_1, &nacl_irt_ppapihook, sizeof(nacl_irt_ppapihook), |
| 65 NULL }, | 70 NULL }, |
| 71 #if defined(OS_NACL_SFI) | |
| 66 { NACL_IRT_PPAPIHOOK_PNACL_PRIVATE_v0_1, | 72 { NACL_IRT_PPAPIHOOK_PNACL_PRIVATE_v0_1, |
| 67 &nacl_irt_ppapihook_pnacl_private, sizeof(nacl_irt_ppapihook_pnacl_private), | 73 &nacl_irt_ppapihook_pnacl_private, sizeof(nacl_irt_ppapihook_pnacl_private), |
| 68 ppapihook_pnacl_private_filter }, | 74 ppapihook_pnacl_private_filter }, |
| 75 #endif | |
| 69 { NACL_IRT_RESOURCE_OPEN_v0_1, &kIrtResourceOpen, | 76 { NACL_IRT_RESOURCE_OPEN_v0_1, &kIrtResourceOpen, |
| 70 sizeof(kIrtResourceOpen), not_pnacl_filter }, | 77 sizeof(kIrtResourceOpen), |
| 78 #if defined(OS_NACL_SFI) | |
| 79 not_pnacl_filter, | |
| 80 #else | |
| 81 NULL, | |
|
Mark Seaborn
2014/10/28 21:57:23
Maybe add a comment: "If we change PNaCl to use N
hidehiko
2014/10/29 06:00:14
Done.
| |
| 82 #endif | |
| 83 }, | |
| 71 }; | 84 }; |
| 72 | 85 |
| 73 size_t chrome_irt_query(const char* interface_ident, | 86 size_t chrome_irt_query(const char* interface_ident, |
| 74 void* table, size_t tablesize) { | 87 void* table, size_t tablesize) { |
| 75 size_t result = nacl_irt_query_list(interface_ident, | 88 size_t result = nacl_irt_query_list(interface_ident, |
| 76 table, | 89 table, |
| 77 tablesize, | 90 tablesize, |
| 78 irt_interfaces, | 91 irt_interfaces, |
| 79 sizeof(irt_interfaces)); | 92 sizeof(irt_interfaces)); |
| 80 if (result != 0) | 93 if (result != 0) |
| 81 return result; | 94 return result; |
| 82 return nacl_irt_query_core(interface_ident, table, tablesize); | 95 return nacl_irt_query_core(interface_ident, table, tablesize); |
| 83 } | 96 } |
| OLD | NEW |