Index: chrome/renderer/render_thread.cc |
=================================================================== |
--- chrome/renderer/render_thread.cc (revision 42644) |
+++ chrome/renderer/render_thread.cc (working copy) |
@@ -90,6 +90,10 @@ |
#include "chrome/app/breakpad_mac.h" |
#endif |
+#if defined(OS_POSIX) |
+#include "ipc/ipc_channel_posix.h" |
+#endif |
+ |
using WebKit::WebCache; |
using WebKit::WebCrossOriginPreflightResultCache; |
using WebKit::WebFontCache; |
@@ -565,6 +569,7 @@ |
OnSpellCheckWordAdded) |
IPC_MESSAGE_HANDLER(ViewMsg_SpellChecker_EnableAutoSpellCorrect, |
OnSpellCheckEnableAutoSpellCorrect) |
+ IPC_MESSAGE_HANDLER(ViewMsg_GpuChannelEstablished, OnGpuChannelEstablished) |
IPC_END_MESSAGE_MAP() |
} |
@@ -680,6 +685,34 @@ |
child_process_logging::SetActiveExtensions(active_extensions); |
} |
+void RenderThread::EstablishGpuChannel() { |
+ if (gpu_channel_.get()) { |
+ // Do nothing if we are already establishing GPU channel. |
+ if (gpu_channel_->state() == GpuChannelHost::UNCONNECTED) |
+ return; |
+ |
+ // Recreate the channel if it has been lost. |
+ if (gpu_channel_->state() == GpuChannelHost::LOST) |
+ gpu_channel_ = NULL; |
+ } |
+ |
+ if (!gpu_channel_.get()) |
+ gpu_channel_ = new GpuChannelHost; |
+ |
+ // Ask the browser for the channel name. |
+ Send(new ViewHostMsg_EstablishGpuChannel()); |
+} |
+ |
+GpuChannelHost* RenderThread::GetGpuChannel() { |
+ if (!gpu_channel_.get()) |
+ return NULL; |
+ |
+ if (gpu_channel_->state() != GpuChannelHost::CONNECTED) |
+ return NULL; |
+ |
+ return gpu_channel_.get(); |
+} |
+ |
static void* CreateHistogram( |
const char *name, int min, int max, size_t buckets) { |
if (min <= 0) |
@@ -940,3 +973,20 @@ |
void RenderThread::OnSetIsIncognitoProcess(bool is_incognito_process) { |
is_incognito_process_ = is_incognito_process; |
} |
+ |
+void RenderThread::OnGpuChannelEstablished( |
+ const IPC::ChannelHandle& channel_handle) { |
+#if defined(OS_POSIX) |
+ // If we received a ChannelHandle, register it now. |
+ if (channel_handle.socket.fd >= 0) |
+ IPC::AddChannelSocket(channel_handle.name, channel_handle.socket.fd); |
+#endif |
+ |
+ if (channel_handle.name.size() != 0) { |
+ // Connect to the GPU process if a channel name was received. |
+ gpu_channel_->Connect(channel_handle.name); |
+ } else { |
+ // Otherwise cancel the connection. |
+ gpu_channel_ = NULL; |
+ } |
+} |