| 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/command_line.h" | 11 #include "base/command_line.h" |
| 11 #include "base/threading/worker_pool.h" | 12 #include "base/threading/worker_pool.h" |
| 12 #include "base/win/scoped_com_initializer.h" | 13 #include "base/win/scoped_com_initializer.h" |
| 13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 14 #include "content/common/child_process.h" | 15 #include "content/common/child_process.h" |
| 15 #include "content/common/gpu/gpu_messages.h" | 16 #include "content/common/gpu/gpu_messages.h" |
| 16 #include "content/public/common/content_client.h" | 17 #include "content/public/common/content_client.h" |
| 17 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 18 #include "content/gpu/gpu_info_collector.h" | 19 #include "content/gpu/gpu_info_collector.h" |
| 19 #include "content/gpu/gpu_watchdog_thread.h" | 20 #include "content/gpu/gpu_watchdog_thread.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 169 |
| 169 void GpuChildThread::OnCollectGraphicsInfo() { | 170 void GpuChildThread::OnCollectGraphicsInfo() { |
| 170 #if defined(OS_WIN) | 171 #if defined(OS_WIN) |
| 171 if (!gpu_info_.finalized && !collecting_dx_diagnostics_) { | 172 if (!gpu_info_.finalized && !collecting_dx_diagnostics_) { |
| 172 // Prevent concurrent collection of DirectX diagnostics. | 173 // Prevent concurrent collection of DirectX diagnostics. |
| 173 collecting_dx_diagnostics_ = true; | 174 collecting_dx_diagnostics_ = true; |
| 174 | 175 |
| 175 // Asynchronously collect the DirectX diagnostics because this can take a | 176 // Asynchronously collect the DirectX diagnostics because this can take a |
| 176 // couple of seconds. | 177 // couple of seconds. |
| 177 if (!base::WorkerPool::PostTask( | 178 if (!base::WorkerPool::PostTask( |
| 178 FROM_HERE, | 179 FROM_HERE, base::Bind(&GpuChildThread::CollectDxDiagnostics, this), |
| 179 NewRunnableFunction(&GpuChildThread::CollectDxDiagnostics, this), | |
| 180 true)) { | 180 true)) { |
| 181 // Flag GPU info as complete if the DirectX diagnostics cannot be | 181 // Flag GPU info as complete if the DirectX diagnostics cannot be |
| 182 // collected. | 182 // collected. |
| 183 collecting_dx_diagnostics_ = false; | 183 collecting_dx_diagnostics_ = false; |
| 184 gpu_info_.finalized = true; | 184 gpu_info_.finalized = true; |
| 185 } else { | 185 } else { |
| 186 // Do not send response if we are still completing the GPUInfo struct | 186 // Do not send response if we are still completing the GPUInfo struct |
| 187 return; | 187 return; |
| 188 } | 188 } |
| 189 } | 189 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 216 | 216 |
| 217 // Runs on a worker thread. The GPU process never terminates voluntarily so | 217 // Runs on a worker thread. The GPU process never terminates voluntarily so |
| 218 // it is safe to assume that its message loop is valid. | 218 // it is safe to assume that its message loop is valid. |
| 219 void GpuChildThread::CollectDxDiagnostics(GpuChildThread* thread) { | 219 void GpuChildThread::CollectDxDiagnostics(GpuChildThread* thread) { |
| 220 base::win::ScopedCOMInitializer com_initializer; | 220 base::win::ScopedCOMInitializer com_initializer; |
| 221 | 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, | 226 FROM_HERE, base::Bind(&GpuChildThread::SetDxDiagnostics, thread, node)); |
| 227 NewRunnableFunction(&GpuChildThread::SetDxDiagnostics, thread, node)); | |
| 228 } | 227 } |
| 229 | 228 |
| 230 // Runs on the main thread. | 229 // Runs on the main thread. |
| 231 void GpuChildThread::SetDxDiagnostics(GpuChildThread* thread, | 230 void GpuChildThread::SetDxDiagnostics(GpuChildThread* thread, |
| 232 const content::DxDiagNode& node) { | 231 const content::DxDiagNode& node) { |
| 233 thread->gpu_info_.dx_diagnostics = node; | 232 thread->gpu_info_.dx_diagnostics = node; |
| 234 thread->gpu_info_.finalized = true; | 233 thread->gpu_info_.finalized = true; |
| 235 thread->collecting_dx_diagnostics_ = false; | 234 thread->collecting_dx_diagnostics_ = false; |
| 236 thread->Send(new GpuHostMsg_GraphicsInfoCollected(thread->gpu_info_)); | 235 thread->Send(new GpuHostMsg_GraphicsInfoCollected(thread->gpu_info_)); |
| 237 } | 236 } |
| 238 | 237 |
| 239 #endif | 238 #endif |
| OLD | NEW |