Chromium Code Reviews| Index: ppapi/proxy/plugin_main_irt.cc |
| diff --git a/ppapi/proxy/plugin_main_nacl.cc b/ppapi/proxy/plugin_main_irt.cc |
| similarity index 87% |
| rename from ppapi/proxy/plugin_main_nacl.cc |
| rename to ppapi/proxy/plugin_main_irt.cc |
| index 90ebfd484874e18fe77da9f949eca9f187bd3e04..3e8aa6cbacbe35e8b11a91dd36e730829f3fcda4 100644 |
| --- a/ppapi/proxy/plugin_main_nacl.cc |
| +++ b/ppapi/proxy/plugin_main_irt.cc |
| @@ -2,6 +2,8 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "ppapi/proxy/plugin_main_irt.h" |
| + |
| #include <map> |
| #include <set> |
| @@ -11,6 +13,15 @@ |
| // IPC_MESSAGE_MACROS_LOG_ENABLED so ppapi_messages.h will generate the |
| // ViewMsgLog et al. functions. |
| +#ifndef __native_client__ |
| +# if OS_LINUX |
| +# define NACL_LINUX 1 |
|
Mark Seaborn
2014/02/15 03:00:52
This is rather hacky... Which headers do you find
hidehiko
2014/02/19 13:05:02
nacl_compiler_annotations.h, which is indirectly i
|
| +# else |
| +# error "non-SFI mode is currently supported only on Linux." |
| +# endif |
| +#endif |
| + |
| +#include "base/at_exit.h" |
| #include "base/command_line.h" |
| #include "base/message_loop/message_loop.h" |
| #include "base/strings/string_number_conversions.h" |
| @@ -21,7 +32,6 @@ |
| #include "ipc/ipc_logging.h" |
| #include "ipc/ipc_message.h" |
| #include "native_client/src/public/chrome_main.h" |
| -#include "native_client/src/shared/srpc/nacl_srpc.h" |
| #include "ppapi/c/ppp.h" |
| #include "ppapi/c/ppp_instance.h" |
| #include "ppapi/native_client/src/shared/ppapi_proxy/ppruntime.h" |
|
Mark Seaborn
2014/02/15 03:00:52
You can remove this now that you #include "ppapi/p
hidehiko
2014/02/19 13:05:02
Done.
|
| @@ -33,6 +43,10 @@ |
| #include "ppapi/shared_impl/ppapi_switches.h" |
| #include "ppapi/shared_impl/ppb_audio_shared.h" |
| +#if defined(__native_client__) |
| +#include "native_client/src/shared/srpc/nacl_srpc.h" |
| +#endif |
| + |
| #if defined(IPC_MESSAGE_LOG_ENABLED) |
| #include "base/containers/hash_tables.h" |
| @@ -53,6 +67,13 @@ using ppapi::proxy::SerializedHandle; |
| namespace { |
| +// On non-SFI mode, the FDs of IPC channels are different from the hard coded |
| +// ones. These values will be overwritten by SetIPCFileDescriptors() below. |
| +// The first FD (based on NACL_CHROME_DESC_BASE) is the IPC channel to the |
| +// browser, and the second one is to the renderer. |
| +int g_nacl_ipc_browser_fd = NACL_CHROME_DESC_BASE; |
| +int g_nacl_ipc_renderer_fd = NACL_CHROME_DESC_BASE + 1; |
| + |
| // This class manages communication between the plugin and the browser, and |
| // manages the PluginDispatcher instances for communication between the plugin |
| // and the renderer. |
| @@ -107,7 +128,7 @@ PpapiDispatcher::PpapiDispatcher(scoped_refptr<base::MessageLoopProxy> io_loop) |
| // The first FD (based on NACL_CHROME_DESC_BASE) is the IPC channel to the |
| // browser. |
| IPC::ChannelHandle channel_handle( |
| - "NaCl IPC", base::FileDescriptor(NACL_CHROME_DESC_BASE, false)); |
| + "NaCl IPC", base::FileDescriptor(g_nacl_ipc_browser_fd, false)); |
| // We don't have/need a PID since handle sharing happens outside of the |
| // NaCl sandbox. |
| InitWithChannel(this, base::kNullProcessId, channel_handle, |
| @@ -232,14 +253,12 @@ void PpapiDispatcher::OnMsgInitializeNaClDispatcher( |
| // The second FD (based on NACL_CHROME_DESC_BASE) is the IPC channel to the |
| // renderer. |
| IPC::ChannelHandle channel_handle( |
| - "nacl", base::FileDescriptor(NACL_CHROME_DESC_BASE + 1, false)); |
| + "nacl", base::FileDescriptor(g_nacl_ipc_renderer_fd, false)); |
| if (!dispatcher->InitPluginWithChannel(this, base::kNullProcessId, |
| channel_handle, false)) { |
| delete dispatcher; |
| return; |
| } |
| - // From here, the dispatcher will manage its own lifetime according to the |
| - // lifetime of the attached channel. |
| } |
| void PpapiDispatcher::OnPluginDispatcherMessageReceived( |
| @@ -273,22 +292,34 @@ void PpapiDispatcher::SetPpapiKeepAliveThrottleFromCommandLine() { |
| void PpapiPluginRegisterThreadCreator( |
| const struct PP_ThreadFunctions* thread_functions) { |
| +#if defined(__native_client__) |
| + // TODO(hidehiko): The thread creation for the PPB_Audio is not yet |
| + // implemented on non-SFI mode. Support this. Now, this function invocation |
| + // is just ignored. |
| + |
| // Initialize all classes that need to create threads that call back into |
| // user code. |
| ppapi::PPB_Audio_Shared::SetThreadFunctions(thread_functions); |
| +#endif |
| } |
| int PpapiPluginMain() { |
| // Though it isn't referenced here, we must instantiate an AtExitManager. |
| base::AtExitManager exit_manager; |
| base::MessageLoop loop; |
| +#if defined(IPC_MESSAGE_LOG_ENABLED) |
| IPC::Logging::set_log_function_map(&g_log_function_mapping); |
| +#endif |
| ppapi::proxy::PluginGlobals plugin_globals; |
| base::Thread io_thread("Chrome_NaClIOThread"); |
| base::Thread::Options options; |
| options.message_loop_type = base::MessageLoop::TYPE_IO; |
| io_thread.StartWithOptions(options); |
| +#if defined(__native_client__) |
| + // Currently on non-SFI mode, we don't use SRPC server on plugin. |
| + // TODO(hidehiko): Make sure this SRPC is actually used on SFI-mode. |
| + |
| // Start up the SRPC server on another thread. Otherwise, when it blocks |
| // on an RPC, the PPAPI proxy will hang. Do this before we initialize the |
| // module and start the PPAPI proxy so that the NaCl plugin can continue |
| @@ -297,6 +328,7 @@ int PpapiPluginMain() { |
| if (!NaClSrpcAcceptClientOnThread(srpc_methods)) { |
| return 1; |
| } |
| +#endif |
| PpapiDispatcher ppapi_dispatcher(io_thread.message_loop_proxy()); |
| plugin_globals.set_plugin_proxy_delegate(&ppapi_dispatcher); |
| @@ -305,3 +337,10 @@ int PpapiPluginMain() { |
| return 0; |
| } |
| + |
| +void SetIPCFileDescriptors(int ipc_browser_fd, int ipc_renderer_fd) { |
|
Mark Seaborn
2014/02/15 03:00:52
Nit: maybe put this above PpapiPluginRegisterThrea
hidehiko
2014/02/19 13:05:02
Done.
|
| + // For non-SFI mode, the browser_ipc_fd and renderer_ipc_fd are different |
| + // from the hard-coded numbers. So, this overwrites the values directly. |
| + g_nacl_ipc_browser_fd = ipc_browser_fd; |
| + g_nacl_ipc_renderer_fd = ipc_renderer_fd; |
| +} |