| Index: native_client_sdk/src/libraries/ppapi_simple/ps_main.cc
|
| diff --git a/native_client_sdk/src/libraries/ppapi_simple/ps_main.cc b/native_client_sdk/src/libraries/ppapi_simple/ps_main.cc
|
| index eabbeaace6fb150f0c112a1f5241de68f231d858..167ff1cc95f2db1782f316291cfc94cd78c211d8 100644
|
| --- a/native_client_sdk/src/libraries/ppapi_simple/ps_main.cc
|
| +++ b/native_client_sdk/src/libraries/ppapi_simple/ps_main.cc
|
| @@ -2,15 +2,44 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#ifdef __native_client__
|
| +#include <irt.h>
|
| +#include <irt_ppapi.h>
|
| +#endif
|
| +
|
| +#include <stdio.h>
|
| +
|
| +#include "nacl_io/nacl_io.h"
|
| #include "ppapi/c/pp_instance.h"
|
| #include "ppapi/c/pp_module.h"
|
| -
|
| #include "ppapi_simple/ps_instance.h"
|
| #include "ppapi_simple/ps_main.h"
|
|
|
| +extern "C" int PpapiPluginMain();
|
|
|
| -void* PSMainCreate(PP_Instance inst, PSMainFunc_t func) {
|
| +void* PSMainCreate(PP_Instance inst) {
|
| PSInstance* pInst = new PSInstance(inst);
|
| - pInst->SetMain(func);
|
| + pInst->SetMain(PSUserMainGet());
|
| return pInst;
|
| }
|
| +
|
| +/**
|
| + * main entry point for ppapi_simple applications. This differs from the
|
| + * regular ppapi main entry point in that it will fall back to running
|
| + * the user's main code in the case that the PPAPI hooks are not found.
|
| + * This allows ppapi_simple binary to run within chrome (with PPAPI present)
|
| + * and also under sel_ldr (no PPAPI).
|
| + */
|
| +int main(int argc, char* argv[]) {
|
| +#ifdef __native_client__
|
| + struct nacl_irt_ppapihook hooks;
|
| + if (nacl_interface_query(NACL_IRT_PPAPIHOOK_v0_1, &hooks, sizeof(hooks)) ==
|
| + sizeof(hooks)) {
|
| + return PpapiPluginMain();
|
| + }
|
| +#endif
|
| + // By default, or if not running in the browser we simply run the main
|
| + // entry point directly, on the main thread.
|
| + nacl_io_init();
|
| + return PSUserMainGet()(argc, argv);
|
| +}
|
|
|