Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6686)

Unified Diff: chrome/plugin/plugin_channel.cc

Issue 149062: mac/linux: rework plugin channel file descriptor creation (Closed)
Patch Set: address review comments Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/plugin/plugin_channel.h ('k') | chrome/plugin/plugin_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/plugin/plugin_channel.cc
diff --git a/chrome/plugin/plugin_channel.cc b/chrome/plugin/plugin_channel.cc
index b9e7a52be56a7e6b656de010c782f034e16e5b03..6264af52a7bf7385d0161b03c1c201c6147d6289 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);
+}
« no previous file with comments | « chrome/plugin/plugin_channel.h ('k') | chrome/plugin/plugin_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698