diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-27 01:43:51 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-27 01:43:51 +0000 |
commit | 3dfc7a41b5e87e3fb1b99836e26a8a62aa3efcfe (patch) | |
tree | a075d88642cf2ee3c0597b5569e1b5232254063d /chrome/plugin/plugin_thread.cc | |
parent | 550c2e55ca73daff47dbcfffd1789c121064f093 (diff) | |
download | chromium_src-3dfc7a41b5e87e3fb1b99836e26a8a62aa3efcfe.zip chromium_src-3dfc7a41b5e87e3fb1b99836e26a8a62aa3efcfe.tar.gz chromium_src-3dfc7a41b5e87e3fb1b99836e26a8a62aa3efcfe.tar.bz2 |
mac/linux: rework plugin channel file descriptor creation
This CL fixes a bug where the same renderer could open several channels to the same plugin process, which end up having the same name. This CL makes it that there is only one channel for each (plugin, renderer) pair, just like on Windows.
The socketpair is created in the plugin process (which can ensure that only one channel per renderer gets created), and sends the renderer side through the browser process.
Note: this should essentially be a noop on Windows.
Review URL: http://codereview.chromium.org/149062
Patch from Antoine Labour <piman@google.com>.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19448 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/plugin/plugin_thread.cc')
-rw-r--r-- | chrome/plugin/plugin_thread.cc | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/chrome/plugin/plugin_thread.cc b/chrome/plugin/plugin_thread.cc index 2f9c2ec..2701f5b 100644 --- a/chrome/plugin/plugin_thread.cc +++ b/chrome/plugin/plugin_thread.cc @@ -103,24 +103,23 @@ void PluginThread::CleanUp() { } void PluginThread::OnCreateChannel( -#if defined(OS_POSIX) - base::FileDescriptor socket, -#endif int process_id, bool off_the_record) { - int fd = -1; -#if defined(OS_POSIX) - fd = socket.fd; -#endif - std::string channel_name; scoped_refptr<PluginChannel> channel = - PluginChannel::GetPluginChannel(process_id, owner_loop(), fd); + PluginChannel::GetPluginChannel(process_id, owner_loop()); + IPC::ChannelHandle channel_handle; if (channel.get()) { - channel_name = channel->channel_name(); + channel_handle.name = channel->channel_name(); +#if defined(OS_POSIX) + // On POSIX, pass the renderer-side FD. Also mark it as auto-close so that + // it gets closed after it has been sent. + int renderer_fd = channel->DisownRendererFd(); + channel_handle.socket = base::FileDescriptor(renderer_fd, true); +#endif channel->set_off_the_record(off_the_record); } - Send(new PluginProcessHostMsg_ChannelCreated(channel_name)); + Send(new PluginProcessHostMsg_ChannelCreated(channel_handle)); } void PluginThread::OnPluginMessage(const std::vector<unsigned char> &data) { |