| OLD | NEW |
| 1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. | 1 // Copyright (c) 2011 The Native Client 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 <sys/nacl_imc_api.h> | 5 #include <sys/nacl_imc_api.h> |
| 6 #include <sys/nacl_syscalls.h> | 6 #include <sys/nacl_syscalls.h> |
| 7 | 7 |
| 8 #include "native_client/src/shared/platform/nacl_check.h" | 8 #include "native_client/src/shared/platform/nacl_check.h" |
| 9 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" | 9 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" |
| 10 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_core.h" | 10 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_core.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 } | 148 } |
| 149 | 149 |
| 150 | 150 |
| 151 } // namespace ppapi_proxy | 151 } // namespace ppapi_proxy |
| 152 | 152 |
| 153 void PpapiPluginRegisterThreadCreator( | 153 void PpapiPluginRegisterThreadCreator( |
| 154 const struct PP_ThreadFunctions* new_funcs) { | 154 const struct PP_ThreadFunctions* new_funcs) { |
| 155 thread_funcs = *new_funcs; | 155 thread_funcs = *new_funcs; |
| 156 } | 156 } |
| 157 | 157 |
| 158 int PpapiPluginMain() { | 158 int IrtInit() { |
| 159 if (getenv("NACL_LD_ACCEPTS_PLUGIN_CONNECTION") != NULL) { | 159 // TODO(halyavin): this is needed for tests without IRT. They do not start |
| 160 // Send a message to the page to ask it to reinitialise the | 160 // in irt_entry.c where IrtInit is called. |
| 161 // plugin's SRPC/PPAPI connection. This triggers a call to | 161 static int initialized = 0; |
| 162 // __startSrpcServices() which in turn calls | 162 if (initialized) { |
| 163 // StartProxiedExecution() which sets up the PPAPI proxy. This is | 163 return 0; |
| 164 // necessary because LoadNaClModule()'s earlier call to | |
| 165 // StartSrpcServices() was matched by the dynamic linker before | |
| 166 // libppruntime was available. | |
| 167 // For background, see: | |
| 168 // http://code.google.com/p/nativeclient/issues/detail?id=617 | |
| 169 // http://code.google.com/p/nativeclient/issues/detail?id=1501 | |
| 170 // TODO(mseaborn): This is a temporary measure. Find a less hacky | |
| 171 // way to do this. | |
| 172 struct NaClImcMsgIoVec iov = { const_cast<char*>("Init"), 4 }; | |
| 173 struct NaClImcMsgHdr message = { &iov, 1, NULL, 0, 0 }; | |
| 174 imc_sendmsg(NACL_SEND_FD, &message, 0); | |
| 175 } | 164 } |
| 176 | |
| 177 if (!NaClSrpcModuleInit()) { | 165 if (!NaClSrpcModuleInit()) { |
| 178 return 1; | 166 return 1; |
| 179 } | 167 } |
| 180 NaClLogModuleInit(); // Enable NaClLog'ing used by CHECK(). | 168 NaClLogModuleInit(); // Enable NaClLog'ing used by CHECK(). |
| 169 initialized = 1; |
| 170 return 0; |
| 171 } |
| 172 |
| 173 int PpapiPluginMain() { |
| 174 IrtInit(); |
| 181 PpapiPluginRegisterDefaultThreadCreator(); | 175 PpapiPluginRegisterDefaultThreadCreator(); |
| 182 // Designate this as the main thread for PPB_Core::IsMainThread(). | 176 // Designate this as the main thread for PPB_Core::IsMainThread(). |
| 183 ppapi_proxy::PluginCore::MarkMainThread(); | 177 ppapi_proxy::PluginCore::MarkMainThread(); |
| 184 if (!NaClSrpcAcceptClientConnection(PppRpcs::srpc_methods)) { | 178 if (!NaClSrpcAcceptClientConnection(PppRpcs::srpc_methods)) { |
| 185 return 1; | 179 return 1; |
| 186 } | 180 } |
| 187 NaClSrpcModuleFini(); | 181 NaClSrpcModuleFini(); |
| 188 | 182 |
| 189 return 0; | 183 return 0; |
| 190 } | 184 } |
| OLD | NEW |