| 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 c84828daed874da918009cc04c538023486ba931..1372cc9c3d0dff29a260461f9c79a5c723015748 100644
|
| --- a/ppapi/proxy/plugin_main_nacl.cc
|
| +++ b/ppapi/proxy/plugin_main_irt.cc
|
| @@ -2,8 +2,9 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include <unistd.h>
|
| +#include "ppapi/proxy/plugin_main_irt.h"
|
|
|
| +#include <unistd.h>
|
| #include <map>
|
| #include <set>
|
|
|
| @@ -13,6 +14,7 @@
|
| // IPC_MESSAGE_MACROS_LOG_ENABLED so ppapi_messages.h will generate the
|
| // ViewMsgLog et al. functions.
|
|
|
| +#include "base/at_exit.h"
|
| #include "base/command_line.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/message_loop/message_loop.h"
|
| @@ -23,11 +25,8 @@
|
| #include "ipc/ipc_channel_handle.h"
|
| #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"
|
| #include "ppapi/proxy/plugin_dispatcher.h"
|
| #include "ppapi/proxy/plugin_globals.h"
|
| #include "ppapi/proxy/plugin_message_filter.h"
|
| @@ -36,6 +35,11 @@
|
| #include "ppapi/shared_impl/ppapi_switches.h"
|
| #include "ppapi/shared_impl/ppb_audio_shared.h"
|
|
|
| +#if defined(__native_client__)
|
| +#include "native_client/src/public/chrome_main.h"
|
| +#include "native_client/src/shared/srpc/nacl_srpc.h"
|
| +#endif
|
| +
|
| #if defined(IPC_MESSAGE_LOG_ENABLED)
|
| #include "base/containers/hash_tables.h"
|
|
|
| @@ -56,6 +60,19 @@ using ppapi::proxy::SerializedHandle;
|
|
|
| namespace {
|
|
|
| +#if defined(__native_client__)
|
| +// In SFI mode, the FDs of IPC channels are NACL_CHROME_DESC_BASE and its
|
| +// successor, which is set in nacl_listener.cc.
|
| +int g_nacl_ipc_browser_fd = NACL_CHROME_DESC_BASE;
|
| +int g_nacl_ipc_renderer_fd = NACL_CHROME_DESC_BASE + 1;
|
| +#else
|
| +// In non-SFI mode, the FDs of IPC channels are different from the hard coded
|
| +// ones. These values will be set by SetIPCFileDescriptors() below.
|
| +// At first, both are initialized to invalid FD number (-1).
|
| +int g_nacl_ipc_browser_fd = -1;
|
| +int g_nacl_ipc_renderer_fd = -1;
|
| +#endif
|
| +
|
| // This class manages communication between the plugin and the browser, and
|
| // manages the PluginDispatcher instances for communication between the plugin
|
| // and the renderer.
|
| @@ -113,10 +130,10 @@ PpapiDispatcher::PpapiDispatcher(scoped_refptr<base::MessageLoopProxy> io_loop)
|
| : next_plugin_dispatcher_id_(0),
|
| message_loop_(io_loop),
|
| shutdown_event_(true, false) {
|
| - // The first FD (based on NACL_CHROME_DESC_BASE) is the IPC channel to the
|
| - // browser.
|
| + DCHECK_NE(g_nacl_ipc_browser_fd, -1)
|
| + << "g_nacl_ipc_browser_fd must be initialized before the plugin starts";
|
| IPC::ChannelHandle channel_handle(
|
| - "NaCl IPC", base::FileDescriptor(NACL_CHROME_DESC_BASE, false));
|
| + "NaCl IPC", base::FileDescriptor(g_nacl_ipc_browser_fd, false));
|
|
|
| // Delay initializing the SyncChannel until after we add filters. This
|
| // ensures that the filters won't miss any messages received by
|
| @@ -249,10 +266,10 @@ void PpapiDispatcher::OnMsgInitializeNaClDispatcher(
|
| new PluginDispatcher(::PPP_GetInterface, args.permissions,
|
| args.off_the_record);
|
| // The channel handle's true name is not revealed here.
|
| - // The second FD (based on NACL_CHROME_DESC_BASE) is the IPC channel to the
|
| - // renderer.
|
| + DCHECK_NE(g_nacl_ipc_renderer_fd, -1)
|
| + << "g_nacl_ipc_renderer_fd must be initialized before the plugin starts";
|
| 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;
|
| @@ -291,24 +308,41 @@ void PpapiDispatcher::SetPpapiKeepAliveThrottleFromCommandLine() {
|
|
|
| } // namespace
|
|
|
| +void SetIPCFileDescriptors(int ipc_browser_fd, int ipc_renderer_fd) {
|
| + g_nacl_ipc_browser_fd = ipc_browser_fd;
|
| + g_nacl_ipc_renderer_fd = ipc_renderer_fd;
|
| +}
|
| +
|
| 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
|
| @@ -317,6 +351,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);
|
|
|