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 <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
444 while (!queued_messages_.empty()) { | 444 while (!queued_messages_.empty()) { |
445 delete queued_messages_.front(); | 445 delete queued_messages_.front(); |
446 queued_messages_.pop(); | 446 queued_messages_.pop(); |
447 } | 447 } |
448 | 448 |
449 // This is only called on the IO thread so no race against the constructor | 449 // This is only called on the IO thread so no race against the constructor |
450 // for another GpuProcessHost. | 450 // for another GpuProcessHost. |
451 if (g_gpu_process_hosts[kind_] == this) | 451 if (g_gpu_process_hosts[kind_] == this) |
452 g_gpu_process_hosts[kind_] = NULL; | 452 g_gpu_process_hosts[kind_] = NULL; |
453 | 453 |
454 // If there are any remaining offscreen contexts at the point the | |
455 // GPU process exits, assume something went wrong, and block their | |
456 // URLs from accessing client 3D APIs without prompting. | |
457 BlockLiveOffscreenContexts(); | |
458 | |
459 UMA_HISTOGRAM_COUNTS_100("GPU.AtExitSurfaceCount", | 454 UMA_HISTOGRAM_COUNTS_100("GPU.AtExitSurfaceCount", |
460 GpuSurfaceTracker::Get()->GetSurfaceCount()); | 455 GpuSurfaceTracker::Get()->GetSurfaceCount()); |
461 UMA_HISTOGRAM_BOOLEAN("GPU.AtExitReceivedMemoryStats", | 456 UMA_HISTOGRAM_BOOLEAN("GPU.AtExitReceivedMemoryStats", |
462 uma_memory_stats_received_); | 457 uma_memory_stats_received_); |
463 | 458 |
464 if (uma_memory_stats_received_) { | 459 if (uma_memory_stats_received_) { |
465 UMA_HISTOGRAM_COUNTS_100("GPU.AtExitContextGroupCount", | 460 UMA_HISTOGRAM_COUNTS_100("GPU.AtExitContextGroupCount", |
466 uma_memory_stats_.context_group_count); | 461 uma_memory_stats_.context_group_count); |
467 UMA_HISTOGRAM_CUSTOM_COUNTS( | 462 UMA_HISTOGRAM_CUSTOM_COUNTS( |
468 "GPU.AtExitMBytesAllocated", | 463 "GPU.AtExitMBytesAllocated", |
469 uma_memory_stats_.bytes_allocated_current / 1024 / 1024, 1, 2000, 50); | 464 uma_memory_stats_.bytes_allocated_current / 1024 / 1024, 1, 2000, 50); |
470 UMA_HISTOGRAM_CUSTOM_COUNTS( | 465 UMA_HISTOGRAM_CUSTOM_COUNTS( |
471 "GPU.AtExitMBytesAllocatedMax", | 466 "GPU.AtExitMBytesAllocatedMax", |
472 uma_memory_stats_.bytes_allocated_max / 1024 / 1024, 1, 2000, 50); | 467 uma_memory_stats_.bytes_allocated_max / 1024 / 1024, 1, 2000, 50); |
473 } | 468 } |
474 | 469 |
475 std::string message; | 470 std::string message; |
471 bool block_offscreen_contexts = true; | |
476 if (!in_process_) { | 472 if (!in_process_) { |
477 int exit_code; | 473 int exit_code; |
478 base::TerminationStatus status = process_->GetTerminationStatus( | 474 base::TerminationStatus status = process_->GetTerminationStatus( |
479 false /* known_dead */, &exit_code); | 475 false /* known_dead */, &exit_code); |
480 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessTerminationStatus", | 476 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessTerminationStatus", |
481 status, | 477 status, |
482 base::TERMINATION_STATUS_MAX_ENUM); | 478 base::TERMINATION_STATUS_MAX_ENUM); |
483 | 479 |
484 if (status == base::TERMINATION_STATUS_NORMAL_TERMINATION || | 480 if (status == base::TERMINATION_STATUS_NORMAL_TERMINATION || |
485 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { | 481 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { |
486 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessExitCode", | 482 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessExitCode", |
487 exit_code, | 483 exit_code, |
488 RESULT_CODE_LAST_CODE); | 484 RESULT_CODE_LAST_CODE); |
489 } | 485 } |
490 | 486 |
491 switch (status) { | 487 switch (status) { |
492 case base::TERMINATION_STATUS_NORMAL_TERMINATION: | 488 case base::TERMINATION_STATUS_NORMAL_TERMINATION: |
489 #if defined(OS_ANDROID) | |
no sievers
2016/03/01 23:04:34
I'm wondering if this even needs the ifdef Android
Ken Russell (switch to Gerrit)
2016/03/02 00:48:47
You're right, it's probably not needed. The only t
| |
490 // Don't block offscreen contexts (and force page reload for webgl) | |
491 // if we might have gotten killed by the OOM killer. | |
492 // Note that NORMAL_TERMINATION here implies that the browser | |
493 // was backgrounded (or we'd be TERMINATION_STATUS_OOM_PROTECTED). | |
494 block_offscreen_contexts = false; | |
495 #endif | |
493 message = "The GPU process exited normally. Everything is okay."; | 496 message = "The GPU process exited normally. Everything is okay."; |
494 break; | 497 break; |
495 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: | 498 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
496 message = base::StringPrintf( | 499 message = base::StringPrintf( |
497 "The GPU process exited with code %d.", | 500 "The GPU process exited with code %d.", |
498 exit_code); | 501 exit_code); |
499 break; | 502 break; |
500 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: | 503 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: |
501 message = "You killed the GPU process! Why?"; | 504 message = "You killed the GPU process! Why?"; |
502 break; | 505 break; |
503 #if defined(OS_CHROMEOS) | 506 #if defined(OS_CHROMEOS) |
504 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM: | 507 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM: |
505 message = "The GUP process was killed due to out of memory."; | 508 message = "The GUP process was killed due to out of memory."; |
506 break; | 509 break; |
507 #endif | 510 #endif |
508 case base::TERMINATION_STATUS_PROCESS_CRASHED: | 511 case base::TERMINATION_STATUS_PROCESS_CRASHED: |
509 message = "The GPU process crashed!"; | 512 message = "The GPU process crashed!"; |
510 break; | 513 break; |
511 case base::TERMINATION_STATUS_LAUNCH_FAILED: | 514 case base::TERMINATION_STATUS_LAUNCH_FAILED: |
512 message = "The GPU process failed to start!"; | 515 message = "The GPU process failed to start!"; |
513 break; | 516 break; |
514 default: | 517 default: |
515 break; | 518 break; |
516 } | 519 } |
517 } | 520 } |
518 | 521 |
522 // If there are any remaining offscreen contexts at the point the | |
523 // GPU process exits, assume something went wrong, and block their | |
524 // URLs from accessing client 3D APIs without prompting. | |
525 if (block_offscreen_contexts) | |
526 BlockLiveOffscreenContexts(); | |
527 | |
519 BrowserThread::PostTask(BrowserThread::UI, | 528 BrowserThread::PostTask(BrowserThread::UI, |
520 FROM_HERE, | 529 FROM_HERE, |
521 base::Bind(&GpuProcessHostUIShim::Destroy, | 530 base::Bind(&GpuProcessHostUIShim::Destroy, |
522 host_id_, | 531 host_id_, |
523 message)); | 532 message)); |
524 } | 533 } |
525 | 534 |
526 bool GpuProcessHost::Init() { | 535 bool GpuProcessHost::Init() { |
527 init_start_time_ = base::TimeTicks::Now(); | 536 init_start_time_ = base::TimeTicks::Now(); |
528 | 537 |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1143 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1152 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1144 ClientIdToShaderCacheMap::iterator iter = | 1153 ClientIdToShaderCacheMap::iterator iter = |
1145 client_id_to_shader_cache_.find(client_id); | 1154 client_id_to_shader_cache_.find(client_id); |
1146 // If the cache doesn't exist then this is an off the record profile. | 1155 // If the cache doesn't exist then this is an off the record profile. |
1147 if (iter == client_id_to_shader_cache_.end()) | 1156 if (iter == client_id_to_shader_cache_.end()) |
1148 return; | 1157 return; |
1149 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1158 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1150 } | 1159 } |
1151 | 1160 |
1152 } // namespace content | 1161 } // namespace content |
OLD | NEW |