| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_process_host.h" | 5 #include "content/browser/gpu/gpu_process_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 379 |
| 380 // TODO(sievers): Revisit this behavior. It's not really a crash, but we also | 380 // TODO(sievers): Revisit this behavior. It's not really a crash, but we also |
| 381 // want the fallback-to-sw behavior if we cannot initialize the GPU. | 381 // want the fallback-to-sw behavior if we cannot initialize the GPU. |
| 382 host->RecordProcessCrash(); | 382 host->RecordProcessCrash(); |
| 383 | 383 |
| 384 delete host; | 384 delete host; |
| 385 return NULL; | 385 return NULL; |
| 386 } | 386 } |
| 387 | 387 |
| 388 // static | 388 // static |
| 389 void GpuProcessHost::GetProcessHandles( | 389 void GpuProcessHost::GetHasGpuProcess( |
| 390 const GpuDataManager::GetGpuProcessHandlesCallback& callback) { | 390 const base::Callback<void(bool)>& callback) { |
| 391 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 391 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 392 BrowserThread::PostTask( | 392 BrowserThread::PostTask( |
| 393 BrowserThread::IO, | 393 BrowserThread::IO, FROM_HERE, |
| 394 FROM_HERE, | 394 base::Bind(&GpuProcessHost::GetHasGpuProcess, callback)); |
| 395 base::Bind(&GpuProcessHost::GetProcessHandles, callback)); | |
| 396 return; | 395 return; |
| 397 } | 396 } |
| 398 std::list<base::ProcessHandle> handles; | 397 bool has_gpu = false; |
| 399 for (size_t i = 0; i < arraysize(g_gpu_process_hosts); ++i) { | 398 for (size_t i = 0; i < arraysize(g_gpu_process_hosts); ++i) { |
| 400 // TODO(rvargas) crbug/417532: don't store ProcessHandles!. | |
| 401 GpuProcessHost* host = g_gpu_process_hosts[i]; | 399 GpuProcessHost* host = g_gpu_process_hosts[i]; |
| 402 if (host && ValidateHost(host)) | 400 if (host && ValidateHost(host)) { |
| 403 handles.push_back(host->process_->GetProcess().Handle()); | 401 has_gpu = true; |
| 402 break; |
| 403 } |
| 404 } | 404 } |
| 405 BrowserThread::PostTask( | 405 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 406 BrowserThread::UI, | 406 base::Bind(callback, has_gpu)); |
| 407 FROM_HERE, | |
| 408 base::Bind(callback, handles)); | |
| 409 } | 407 } |
| 410 | 408 |
| 411 // static | 409 // static |
| 412 void GpuProcessHost::CallOnIO( | 410 void GpuProcessHost::CallOnIO( |
| 413 GpuProcessKind kind, | 411 GpuProcessKind kind, |
| 414 bool force_create, | 412 bool force_create, |
| 415 const base::Callback<void(GpuProcessHost*)>& callback) { | 413 const base::Callback<void(GpuProcessHost*)>& callback) { |
| 416 #if !defined(OS_WIN) | 414 #if !defined(OS_WIN) |
| 417 DCHECK_NE(kind, GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED); | 415 DCHECK_NE(kind, GpuProcessHost::GPU_PROCESS_KIND_UNSANDBOXED); |
| 418 #endif | 416 #endif |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 if (!cache.get()) | 1177 if (!cache.get()) |
| 1180 return; | 1178 return; |
| 1181 | 1179 |
| 1182 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, | 1180 cache->set_shader_loaded_callback(base::Bind(&GpuProcessHost::LoadedShader, |
| 1183 weak_ptr_factory_.GetWeakPtr())); | 1181 weak_ptr_factory_.GetWeakPtr())); |
| 1184 | 1182 |
| 1185 client_id_to_shader_cache_[client_id] = cache; | 1183 client_id_to_shader_cache_[client_id] = cache; |
| 1186 } | 1184 } |
| 1187 | 1185 |
| 1188 } // namespace content | 1186 } // namespace content |
| OLD | NEW |