| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/gpu/gpu_child_thread.h" | 5 #include "content/gpu/gpu_child_thread.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/threading/worker_pool.h" | 12 #include "base/threading/worker_pool.h" |
| 13 #include "base/win/scoped_com_initializer.h" | |
| 14 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 15 #include "content/common/child_process.h" | 14 #include "content/common/child_process.h" |
| 16 #include "content/common/gpu/gpu_messages.h" | 15 #include "content/common/gpu/gpu_messages.h" |
| 17 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" |
| 18 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 19 #include "content/gpu/gpu_info_collector.h" | 18 #include "content/gpu/gpu_info_collector.h" |
| 20 #include "content/gpu/gpu_watchdog_thread.h" | 19 #include "content/gpu/gpu_watchdog_thread.h" |
| 21 #include "ipc/ipc_channel_handle.h" | 20 #include "ipc/ipc_channel_handle.h" |
| 22 #include "ui/gfx/gl/gl_implementation.h" | 21 #include "ui/gfx/gl/gl_implementation.h" |
| 23 | 22 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 watchdog_thread_->Stop(); | 165 watchdog_thread_->Stop(); |
| 167 } | 166 } |
| 168 } | 167 } |
| 169 | 168 |
| 170 void GpuChildThread::OnCollectGraphicsInfo() { | 169 void GpuChildThread::OnCollectGraphicsInfo() { |
| 171 #if defined(OS_WIN) | 170 #if defined(OS_WIN) |
| 172 if (!gpu_info_.finalized && !collecting_dx_diagnostics_) { | 171 if (!gpu_info_.finalized && !collecting_dx_diagnostics_) { |
| 173 // Prevent concurrent collection of DirectX diagnostics. | 172 // Prevent concurrent collection of DirectX diagnostics. |
| 174 collecting_dx_diagnostics_ = true; | 173 collecting_dx_diagnostics_ = true; |
| 175 | 174 |
| 176 // Asynchronously collect the DirectX diagnostics because this can take a | 175 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 177 // couple of seconds. | 176 switches::kDisableGpuSandbox)) { |
| 178 if (!base::WorkerPool::PostTask( | 177 // Asynchronously collect the DirectX diagnostics because this can take a |
| 179 FROM_HERE, base::Bind(&GpuChildThread::CollectDxDiagnostics, this), | 178 // couple of seconds. |
| 180 true)) { | 179 if (!base::WorkerPool::PostTask( |
| 181 // Flag GPU info as complete if the DirectX diagnostics cannot be | 180 FROM_HERE, base::Bind(&GpuChildThread::CollectDxDiagnostics, this), |
| 182 // collected. | 181 true)) { |
| 183 collecting_dx_diagnostics_ = false; | 182 // Flag GPU info as complete if the DirectX diagnostics cannot be |
| 184 gpu_info_.finalized = true; | 183 // collected. |
| 185 } else { | 184 collecting_dx_diagnostics_ = false; |
| 186 // Do not send response if we are still completing the GPUInfo struct | 185 gpu_info_.finalized = true; |
| 187 return; | 186 } else { |
| 187 // Do not send response if we are still completing the GPUInfo struct |
| 188 return; |
| 189 } |
| 188 } | 190 } |
| 189 } | 191 } |
| 190 #endif | 192 #endif |
| 191 Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); | 193 Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); |
| 192 } | 194 } |
| 193 | 195 |
| 194 void GpuChildThread::OnClean() { | 196 void GpuChildThread::OnClean() { |
| 195 LOG(INFO) << "GPU: Removing all contexts"; | 197 LOG(INFO) << "GPU: Removing all contexts"; |
| 196 if (gpu_channel_manager_.get()) | 198 if (gpu_channel_manager_.get()) |
| 197 gpu_channel_manager_->LoseAllContexts(); | 199 gpu_channel_manager_->LoseAllContexts(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 210 // Do not sleep here. The GPU watchdog timer tracks the amount of user | 212 // Do not sleep here. The GPU watchdog timer tracks the amount of user |
| 211 // time this thread is using and it doesn't use much while calling Sleep. | 213 // time this thread is using and it doesn't use much while calling Sleep. |
| 212 } | 214 } |
| 213 } | 215 } |
| 214 | 216 |
| 215 #if defined(OS_WIN) | 217 #if defined(OS_WIN) |
| 216 | 218 |
| 217 // Runs on a worker thread. The GPU process never terminates voluntarily so | 219 // Runs on a worker thread. The GPU process never terminates voluntarily so |
| 218 // it is safe to assume that its message loop is valid. | 220 // it is safe to assume that its message loop is valid. |
| 219 void GpuChildThread::CollectDxDiagnostics(GpuChildThread* thread) { | 221 void GpuChildThread::CollectDxDiagnostics(GpuChildThread* thread) { |
| 220 base::win::ScopedCOMInitializer com_initializer; | |
| 221 | |
| 222 content::DxDiagNode node; | 222 content::DxDiagNode node; |
| 223 gpu_info_collector::GetDxDiagnostics(&node); | 223 gpu_info_collector::GetDxDiagnostics(&node); |
| 224 | 224 |
| 225 thread->message_loop()->PostTask( | 225 thread->message_loop()->PostTask( |
| 226 FROM_HERE, base::Bind(&GpuChildThread::SetDxDiagnostics, thread, node)); | 226 FROM_HERE, base::Bind(&GpuChildThread::SetDxDiagnostics, thread, node)); |
| 227 } | 227 } |
| 228 | 228 |
| 229 // Runs on the main thread. | 229 // Runs on the main thread. |
| 230 void GpuChildThread::SetDxDiagnostics(GpuChildThread* thread, | 230 void GpuChildThread::SetDxDiagnostics(GpuChildThread* thread, |
| 231 const content::DxDiagNode& node) { | 231 const content::DxDiagNode& node) { |
| 232 thread->gpu_info_.dx_diagnostics = node; | 232 thread->gpu_info_.dx_diagnostics = node; |
| 233 thread->gpu_info_.finalized = true; | 233 thread->gpu_info_.finalized = true; |
| 234 thread->collecting_dx_diagnostics_ = false; | 234 thread->collecting_dx_diagnostics_ = false; |
| 235 thread->Send(new GpuHostMsg_GraphicsInfoCollected(thread->gpu_info_)); | 235 thread->Send(new GpuHostMsg_GraphicsInfoCollected(thread->gpu_info_)); |
| 236 } | 236 } |
| 237 | 237 |
| 238 #endif | 238 #endif |
| OLD | NEW |