summaryrefslogtreecommitdiffstats
path: root/chrome/gpu
diff options
context:
space:
mode:
authordmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-08 19:28:09 +0000
committerdmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-08 19:28:09 +0000
commit42ce94ec8e98df0744cc1dea26b49c084fe185f0 (patch)
tree8b585da323dc3bbabb3c61a8941aed90e1819648 /chrome/gpu
parentade3ef65f389b00a101da5eb18a02b966d354b18 (diff)
downloadchromium_src-42ce94ec8e98df0744cc1dea26b49c084fe185f0.zip
chromium_src-42ce94ec8e98df0744cc1dea26b49c084fe185f0.tar.gz
chromium_src-42ce94ec8e98df0744cc1dea26b49c084fe185f0.tar.bz2
Convert over to channel handles
This hides some of the internals of the posix channels from users, and gets rid of several #ifdef POSIX blocks. Generally simplifies usage of channels xplatform. BUG=none TEST=build Review URL: http://codereview.chromium.org/5598010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68621 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/gpu')
-rw-r--r--chrome/gpu/gpu_channel.cc34
-rw-r--r--chrome/gpu/gpu_channel.h22
-rw-r--r--chrome/gpu/gpu_thread.cc4
3 files changed, 18 insertions, 42 deletions
diff --git a/chrome/gpu/gpu_channel.cc b/chrome/gpu/gpu_channel.cc
index 9d3ebd3..7741391 100644
--- a/chrome/gpu/gpu_channel.cc
+++ b/chrome/gpu/gpu_channel.cc
@@ -24,24 +24,12 @@
#endif
GpuChannel::GpuChannel(int renderer_id)
- : renderer_id_(renderer_id)
-#if defined(OS_POSIX)
- , renderer_fd_(-1)
-#endif
-{
+ : renderer_id_(renderer_id) {
const CommandLine* command_line = CommandLine::ForCurrentProcess();
log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages);
}
GpuChannel::~GpuChannel() {
-#if defined(OS_POSIX)
- IPC::RemoveAndCloseChannelSocket(GetChannelName());
-
- // If we still have the renderer FD, close it.
- if (renderer_fd_ != -1) {
- close(renderer_fd_);
- }
-#endif
}
void GpuChannel::OnChannelConnected(int32 peer_pid) {
@@ -242,15 +230,6 @@ bool GpuChannel::Init() {
// Map renderer ID to a (single) channel to that process.
std::string channel_name = GetChannelName();
-#if defined(OS_POSIX)
- // This gets called when the GpuChannel is initially created. At this
- // point, create the socketpair and assign the GPU 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 gpu_fd;
- IPC::SocketPair(&gpu_fd, &renderer_fd_);
- IPC::AddChannelSocket(channel_name, gpu_fd);
-#endif
channel_.reset(new IPC::SyncChannel(
channel_name, IPC::Channel::MODE_SERVER, this,
ChildProcess::current()->io_message_loop(), false,
@@ -262,3 +241,14 @@ bool GpuChannel::Init() {
std::string GpuChannel::GetChannelName() {
return StringPrintf("%d.r%d", base::GetCurrentProcId(), renderer_id_);
}
+
+#if defined(OS_POSIX)
+int GpuChannel::GetRendererFileDescriptor() {
+ int fd = -1;
+ if (channel_.get()) {
+ fd = channel_->GetClientFileDescriptor();
+ }
+ return fd;
+}
+#endif // defined(OS_POSIX)
+
diff --git a/chrome/gpu/gpu_channel.h b/chrome/gpu/gpu_channel.h
index 3d64355..53c0d70 100644
--- a/chrome/gpu/gpu_channel.h
+++ b/chrome/gpu/gpu_channel.h
@@ -36,22 +36,14 @@ class GpuChannel : public IPC::Channel::Listener,
std::string GetChannelName();
+#if defined(OS_POSIX)
+ int GetRendererFileDescriptor();
+#endif // defined(OS_POSIX)
+
base::ProcessHandle renderer_handle() const {
return renderer_process_.handle();
}
-#if defined(OS_POSIX)
- // When first created, the GpuChannel gets assigned the file descriptor
- // for the renderer.
- // After the first time we pass it through the IPC, we don't need it anymore,
- // and we close it. At that time, we reset renderer_fd_ to -1.
- int DisownRendererFd() {
- int value = renderer_fd_;
- renderer_fd_ = -1;
- return value;
- }
-#endif
-
// IPC::Channel::Listener implementation:
virtual void OnMessageReceived(const IPC::Message& msg);
virtual void OnChannelConnected(int32 peer_pid);
@@ -96,12 +88,6 @@ class GpuChannel : public IPC::Channel::Listener,
// The id of the renderer who is on the other side of the channel.
int renderer_id_;
-#if defined(OS_POSIX)
- // FD for the renderer end of the pipe. It is stored until we send it over
- // IPC after which it is cleared. It will be closed by the IPC mechanism.
- int renderer_fd_;
-#endif
-
// Used to implement message routing functionality to CommandBuffer objects
MessageRouter router_;
diff --git a/chrome/gpu/gpu_thread.cc b/chrome/gpu/gpu_thread.cc
index 09c91f2..411fbbb 100644
--- a/chrome/gpu/gpu_thread.cc
+++ b/chrome/gpu/gpu_thread.cc
@@ -95,8 +95,8 @@ void GpuThread::OnEstablishChannel(int renderer_id) {
#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);
+ int renderer_fd = channel->GetRendererFileDescriptor();
+ channel_handle.socket = base::FileDescriptor(renderer_fd, false);
#endif
}