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