OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/gpu/gpu_data_manager_impl_private.h" | 5 #include "content/browser/gpu/gpu_data_manager_impl_private.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats(stats); | 275 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats(stats); |
276 } | 276 } |
277 | 277 |
278 void RequestVideoMemoryUsageStats(GpuProcessHost* host) { | 278 void RequestVideoMemoryUsageStats(GpuProcessHost* host) { |
279 if (!host) | 279 if (!host) |
280 return; | 280 return; |
281 host->gpu_service()->GetVideoMemoryUsageStats( | 281 host->gpu_service()->GetVideoMemoryUsageStats( |
282 base::Bind(&OnVideoMemoryUsageStats)); | 282 base::Bind(&OnVideoMemoryUsageStats)); |
283 } | 283 } |
284 | 284 |
| 285 void UpdateGpuInfoOnIO(const gpu::GPUInfo& gpu_info) { |
| 286 // This function is called on the IO thread, but GPUInfo on GpuDataManagerImpl |
| 287 // should be updated on the UI thread (since it can call into functions that |
| 288 // expect to run in the UI thread, e.g. ContentClient::SetGpuInfo()). |
| 289 BrowserThread::PostTask( |
| 290 BrowserThread::UI, FROM_HERE, |
| 291 base::Bind( |
| 292 [](const gpu::GPUInfo& gpu_info) { |
| 293 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected"); |
| 294 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
| 295 }, |
| 296 gpu_info)); |
| 297 } |
| 298 |
285 } // namespace anonymous | 299 } // namespace anonymous |
286 | 300 |
287 void GpuDataManagerImplPrivate::InitializeForTesting( | 301 void GpuDataManagerImplPrivate::InitializeForTesting( |
288 const std::string& gpu_blacklist_json, | 302 const std::string& gpu_blacklist_json, |
289 const gpu::GPUInfo& gpu_info) { | 303 const gpu::GPUInfo& gpu_info) { |
290 // This function is for testing only, so disable histograms. | 304 // This function is for testing only, so disable histograms. |
291 update_histograms_ = false; | 305 update_histograms_ = false; |
292 | 306 |
293 // Prevent all further initialization. | 307 // Prevent all further initialization. |
294 finalized_ = true; | 308 finalized_ = true; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 425 |
412 void GpuDataManagerImplPrivate::RequestCompleteGpuInfoIfNeeded() { | 426 void GpuDataManagerImplPrivate::RequestCompleteGpuInfoIfNeeded() { |
413 if (complete_gpu_info_already_requested_ || IsCompleteGpuInfoAvailable() || | 427 if (complete_gpu_info_already_requested_ || IsCompleteGpuInfoAvailable() || |
414 base::CommandLine::ForCurrentProcess()->HasSwitch( | 428 base::CommandLine::ForCurrentProcess()->HasSwitch( |
415 switches::kGpuTestingNoCompleteInfoCollection)) { | 429 switches::kGpuTestingNoCompleteInfoCollection)) { |
416 return; | 430 return; |
417 } | 431 } |
418 | 432 |
419 complete_gpu_info_already_requested_ = true; | 433 complete_gpu_info_already_requested_ = true; |
420 | 434 |
421 GpuProcessHost::SendOnIO( | 435 GpuProcessHost::CallOnIO( |
422 #if defined(OS_WIN) | 436 #if defined(OS_WIN) |
423 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, | 437 GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED, |
424 #else | 438 #else |
425 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, | 439 GpuProcessHost::GPU_PROCESS_KIND_SANDBOXED, |
426 #endif | 440 #endif |
427 true /* force_create */, new GpuMsg_CollectGraphicsInfo()); | 441 true /* force_create */, base::Bind([](GpuProcessHost* host) { |
| 442 if (!host) |
| 443 return; |
| 444 host->gpu_service()->RequestCompleteGpuInfo( |
| 445 base::Bind(&UpdateGpuInfoOnIO)); |
| 446 })); |
428 } | 447 } |
429 | 448 |
430 bool GpuDataManagerImplPrivate::IsEssentialGpuInfoAvailable() const { | 449 bool GpuDataManagerImplPrivate::IsEssentialGpuInfoAvailable() const { |
431 if (gpu_info_.basic_info_state == gpu::kCollectInfoNone || | 450 if (gpu_info_.basic_info_state == gpu::kCollectInfoNone || |
432 gpu_info_.context_info_state == gpu::kCollectInfoNone) { | 451 gpu_info_.context_info_state == gpu::kCollectInfoNone) { |
433 return false; | 452 return false; |
434 } | 453 } |
435 return true; | 454 return true; |
436 } | 455 } |
437 | 456 |
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; | 1381 gpu_info_.context_info_state = gpu::kCollectInfoFatalFailure; |
1363 #if defined(OS_WIN) | 1382 #if defined(OS_WIN) |
1364 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; | 1383 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoFatalFailure; |
1365 #endif | 1384 #endif |
1366 complete_gpu_info_already_requested_ = true; | 1385 complete_gpu_info_already_requested_ = true; |
1367 // Some observers might be waiting. | 1386 // Some observers might be waiting. |
1368 NotifyGpuInfoUpdate(); | 1387 NotifyGpuInfoUpdate(); |
1369 } | 1388 } |
1370 | 1389 |
1371 } // namespace content | 1390 } // namespace content |
OLD | NEW |