diff options
Diffstat (limited to 'chrome/gpu/gpu_thread.cc')
-rw-r--r-- | chrome/gpu/gpu_thread.cc | 71 |
1 files changed, 39 insertions, 32 deletions
diff --git a/chrome/gpu/gpu_thread.cc b/chrome/gpu/gpu_thread.cc index 3a1dc7b..8c1059f 100644 --- a/chrome/gpu/gpu_thread.cc +++ b/chrome/gpu/gpu_thread.cc @@ -12,6 +12,7 @@ #include "build/build_config.h" #include "chrome/common/child_process.h" #include "chrome/common/child_process_logging.h" +#include "chrome/common/gpu_info.h" #include "chrome/common/gpu_messages.h" #include "chrome/gpu/gpu_info_collector.h" #include "ipc/ipc_channel_handle.h" @@ -66,15 +67,6 @@ GpuThread::GpuThread() { GpuThread::~GpuThread() { } -void GpuThread::Init(const base::Time& process_start_time) { - gpu_info_collector::CollectGraphicsInfo(&gpu_info_); - child_process_logging::SetGpuInfo(gpu_info_); - - // Record initialization only after collecting the GPU info because that can - // take a significant amount of time. - gpu_info_.SetInitializationTime(base::Time::Now() - process_start_time); -} - #if defined(GPU_USE_GLX) GpuBackingStoreGLXContext* GpuThread::GetGLXContext() { if (!glx_context_.get()) @@ -110,32 +102,40 @@ void GpuThread::OnEstablishChannel(int renderer_id) { IPC::ChannelHandle channel_handle; GPUInfo gpu_info; - GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); - if (iter == gpu_channels_.end()) { - channel = new GpuChannel(renderer_id); - } else { - channel = iter->second; - } - - DCHECK(channel != NULL); - - if (channel->Init()) { - gpu_channels_[renderer_id] = channel; - } else { - channel = NULL; - } - - if (channel.get()) { - channel_handle.name = channel->GetChannelName(); + // Fail to establish a channel if some implementation of GL cannot be + // initialized. + if (gfx::GLContext::InitializeOneOff()) { + // Fail to establish channel if GPU stats cannot be retreived. + if (gpu_info_collector::CollectGraphicsInfo(&gpu_info)) { + child_process_logging::SetGpuInfo(gpu_info); + GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); + if (iter == gpu_channels_.end()) { + channel = new GpuChannel(renderer_id); + } else { + channel = iter->second; + } + + DCHECK(channel != NULL); + + if (channel->Init()) { + gpu_channels_[renderer_id] = channel; + } else { + channel = NULL; + } + + if (channel.get()) { + channel_handle.name = channel->GetChannelName(); #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); + // 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 + } + } } - Send(new GpuHostMsg_ChannelEstablished(channel_handle, gpu_info_)); + Send(new GpuHostMsg_ChannelEstablished(channel_handle, gpu_info)); } void GpuThread::OnSynchronize() { @@ -157,7 +157,14 @@ void GpuThread::OnNewRenderWidgetHostView(GpuNativeWindowHandle parent_window, } void GpuThread::OnCollectGraphicsInfo() { - Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); + // Fail to establish a channel if some implementation of GL cannot be + // initialized. + GPUInfo gpu_info; + if (gfx::GLContext::InitializeOneOff()) { + gpu_info_collector::CollectGraphicsInfo(&gpu_info); + } + + Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info)); } void GpuThread::OnCrash() { |