OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2015 The Chromium Authors. All rights reserved. |
Sam Clegg
2015/02/19 21:24:20
nit: might as well drop (c) if you are going to ch
binji
2015/02/20 17:33:48
Done.
| |
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 "ppapi_simple/ps_main.h" | |
6 | |
5 #ifdef __native_client__ | 7 #ifdef __native_client__ |
6 #include <irt.h> | 8 #include <irt.h> |
7 #include <irt_ppapi.h> | 9 #include <irt_ppapi.h> |
8 #endif | 10 #endif |
9 | 11 |
10 #include <stdio.h> | 12 #include <stdio.h> |
11 | 13 |
12 #include "nacl_io/nacl_io.h" | 14 #include "nacl_io/nacl_io.h" |
13 #include "ppapi/c/pp_instance.h" | |
14 #include "ppapi/c/pp_module.h" | |
15 #include "ppapi_simple/ps_instance.h" | 15 #include "ppapi_simple/ps_instance.h" |
16 #include "ppapi_simple/ps_main.h" | |
17 | 16 |
18 extern "C" int PpapiPluginMain(); | 17 extern PSMainFunc_t g_main_cb; |
19 | 18 |
20 void* PSMainCreate(PP_Instance inst, PSMainFunc_t entry_point) { | 19 int PpapiPluginMain(); |
21 PSInstance* pInst = new PSInstance(inst); | |
22 pInst->SetMain(entry_point); | |
23 return pInst; | |
24 } | |
25 | 20 |
26 /** | 21 /** |
27 * main entry point for ppapi_simple applications. This differs from the | 22 * main entry point for ppapi_simple applications. This differs from the |
28 * regular ppapi main entry point in that it will fall back to running | 23 * regular ppapi main entry point in that it will fall back to running |
29 * the user's main code in the case that the PPAPI hooks are not found. | 24 * the user's main code in the case that the PPAPI hooks are not found. |
30 * This allows ppapi_simple binary to run within chrome (with PPAPI present) | 25 * This allows ppapi_simple binary to run within chrome (with PPAPI present) |
31 * and also under sel_ldr (no PPAPI). | 26 * and also under sel_ldr (no PPAPI). |
32 */ | 27 */ |
33 #ifdef __native_client__ | 28 #ifdef __native_client__ |
34 extern "C" int __nacl_main(int argc, char* argv[]) { | 29 int __nacl_main(int argc, char* argv[]) { |
35 struct nacl_irt_ppapihook hooks; | 30 struct nacl_irt_ppapihook hooks; |
36 if (nacl_interface_query(NACL_IRT_PPAPIHOOK_v0_1, &hooks, sizeof(hooks)) == | 31 if (nacl_interface_query(NACL_IRT_PPAPIHOOK_v0_1, &hooks, sizeof(hooks)) == |
37 sizeof(hooks)) { | 32 sizeof(hooks)) { |
38 return PpapiPluginMain(); | 33 return PpapiPluginMain(); |
39 } | 34 } |
40 #else | 35 #else |
41 int main(int argc, char* argv[]) { | 36 int main(int argc, char* argv[]) { |
42 #endif | 37 #endif |
43 // By default, or if not running in the browser we simply run the main | 38 // By default, or if not running in the browser we simply run the main |
44 // entry point directly, on the main thread. | 39 // entry point directly, on the main thread. |
45 int rtn = nacl_io_init(); | 40 int rtn = nacl_io_init(); |
46 if (rtn != 0) | 41 if (rtn != 0) |
47 return rtn; | 42 return rtn; |
48 rtn = PSUserMainGet()(argc, argv); | 43 rtn = PSUserMainGet()(argc, argv); |
49 nacl_io_uninit(); | 44 nacl_io_uninit(); |
50 return rtn; | 45 return rtn; |
51 } | 46 } |
47 | |
Sam Clegg
2015/02/19 21:24:20
nit: trailing newline.
binji
2015/02/20 17:33:48
Done.
| |
OLD | NEW |