diff options
Diffstat (limited to 'chrome/plugin/plugin_channel.cc')
-rw-r--r-- | chrome/plugin/plugin_channel.cc | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/chrome/plugin/plugin_channel.cc b/chrome/plugin/plugin_channel.cc index b9e7a52..6264af5 100644 --- a/chrome/plugin/plugin_channel.cc +++ b/chrome/plugin/plugin_channel.cc @@ -18,18 +18,11 @@ #endif PluginChannel* PluginChannel::GetPluginChannel( - int process_id, MessageLoop* ipc_message_loop, int channel_fd) { + int process_id, MessageLoop* ipc_message_loop) { // map renderer's process id to a (single) channel to that process std::string channel_name = StringPrintf( "%d.r%d", base::GetCurrentProcId(), process_id); -#if defined(OS_POSIX) - // If we were provided an already-open channel, associate it with - // the channel name in this process's name<->socket map. - if (channel_fd > 0) - IPC::AddChannelSocket(channel_name, channel_fd); -#endif - return static_cast<PluginChannel*>(PluginChannelBase::GetChannel( channel_name, IPC::Channel::MODE_SERVER, @@ -38,8 +31,13 @@ PluginChannel* PluginChannel::GetPluginChannel( false)); } -PluginChannel::PluginChannel() : renderer_handle_(0), in_send_(0), - off_the_record_(false) { +PluginChannel::PluginChannel() + : renderer_handle_(0), +#if defined(OS_POSIX) + renderer_fd_(-1), +#endif + in_send_(0), + off_the_record_(false) { SendUnblockingOnlyDuringDispatch(); ChildProcess::current()->AddRefProcess(); const CommandLine* command_line = CommandLine::ForCurrentProcess(); @@ -49,6 +47,12 @@ PluginChannel::PluginChannel() : renderer_handle_(0), in_send_(0), PluginChannel::~PluginChannel() { if (renderer_handle_) base::CloseProcessHandle(renderer_handle_); +#if defined(OS_POSIX) + // If we still have the FD, close it. + if (renderer_fd_ != -1) { + close(renderer_fd_); + } +#endif ChildProcess::current()->ReleaseProcess(); } @@ -144,3 +148,16 @@ void PluginChannel::CleanUp() { plugin_stubs_.clear(); } + +bool PluginChannel::Init(MessageLoop* ipc_message_loop, bool create_pipe_now) { +#if defined(OS_POSIX) + // This gets called when the PluginChannel is initially created. At this + // point, create the socketpair and assign the plugin side FD to the channel + // name. Keep the renderer side FD as a member variable in the PluginChannel + // to be able to transmit it through IPC. + int plugin_fd; + IPC::SocketPair(&plugin_fd, &renderer_fd_); + IPC::AddChannelSocket(channel_name(), plugin_fd); +#endif + return PluginChannelBase::Init(ipc_message_loop, create_pipe_now); +} |