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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 // Need to include this before most other files because it defines |
| 7 // IPC_MESSAGE_LOG_ENABLED. We need to use it to define |
| 8 // IPC_MESSAGE_MACROS_LOG_ENABLED so ppapi_messages.h will generate the |
| 9 // ViewMsgLog et al. functions. |
| 10 |
| 11 #include "base/threading/thread.h" |
| 12 #include "ipc/ipc_logging.h" |
6 #include "ppapi/nacl_irt/irt_interfaces.h" | 13 #include "ppapi/nacl_irt/irt_interfaces.h" |
7 #include "ppapi/nacl_irt/irt_ppapi.h" | 14 #include "ppapi/nacl_irt/irt_ppapi.h" |
8 #include "ppapi/nacl_irt/plugin_main.h" | 15 #include "ppapi/nacl_irt/plugin_startup.h" |
| 16 #include "ppapi/nacl_irt/ppapi_dispatcher.h" |
9 #include "ppapi/nacl_irt/public/irt_ppapi.h" | 17 #include "ppapi/nacl_irt/public/irt_ppapi.h" |
| 18 #include "ppapi/proxy/plugin_globals.h" |
| 19 #include "ppapi/shared_impl/ppb_audio_shared.h" |
10 | 20 |
11 static struct PP_StartFunctions g_pp_functions; | 21 static struct PP_StartFunctions g_pp_functions; |
12 | 22 |
| 23 void PpapiPluginRegisterThreadCreator( |
| 24 const struct PP_ThreadFunctions* thread_functions) { |
| 25 // Initialize all classes that need to create threads that call back into |
| 26 // user code. |
| 27 ppapi::PPB_Audio_Shared::SetThreadFunctions(thread_functions); |
| 28 } |
| 29 |
13 int irt_ppapi_start(const struct PP_StartFunctions* funcs) { | 30 int irt_ppapi_start(const struct PP_StartFunctions* funcs) { |
14 g_pp_functions = *funcs; | 31 g_pp_functions = *funcs; |
15 return PpapiPluginMain(); | 32 |
| 33 base::MessageLoop loop; |
| 34 ppapi::proxy::PluginGlobals plugin_globals( |
| 35 scoped_refptr<base::TaskRunner>(ppapi::GetIOThread()->task_runner())); |
| 36 |
| 37 ppapi::PpapiDispatcher ppapi_dispatcher( |
| 38 ppapi::GetIOThread()->task_runner(), ppapi::GetShutdownEvent(), |
| 39 ppapi::GetBrowserIPCFileDescriptor(), |
| 40 ppapi::GetRendererIPCFileDescriptor()); |
| 41 plugin_globals.SetPluginProxyDelegate(&ppapi_dispatcher); |
| 42 |
| 43 loop.Run(); |
| 44 |
| 45 return 0; |
16 } | 46 } |
17 | 47 |
18 int32_t PPP_InitializeModule(PP_Module module_id, | 48 int32_t PPP_InitializeModule(PP_Module module_id, |
19 PPB_GetInterface get_browser_interface) { | 49 PPB_GetInterface get_browser_interface) { |
20 return g_pp_functions.PPP_InitializeModule(module_id, get_browser_interface); | 50 return g_pp_functions.PPP_InitializeModule(module_id, get_browser_interface); |
21 } | 51 } |
22 | 52 |
23 void PPP_ShutdownModule(void) { | 53 void PPP_ShutdownModule(void) { |
24 g_pp_functions.PPP_ShutdownModule(); | 54 g_pp_functions.PPP_ShutdownModule(); |
25 } | 55 } |
26 | 56 |
27 const void* PPP_GetInterface(const char* interface_name) { | 57 const void* PPP_GetInterface(const char* interface_name) { |
28 return g_pp_functions.PPP_GetInterface(interface_name); | 58 return g_pp_functions.PPP_GetInterface(interface_name); |
29 } | 59 } |
30 | 60 |
31 const struct nacl_irt_ppapihook nacl_irt_ppapihook = { | 61 const struct nacl_irt_ppapihook nacl_irt_ppapihook = { |
32 irt_ppapi_start, | 62 irt_ppapi_start, |
33 PpapiPluginRegisterThreadCreator, | 63 PpapiPluginRegisterThreadCreator, |
34 }; | 64 }; |
OLD | NEW |