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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 return NULL; | 434 return NULL; |
435 } | 435 } |
436 | 436 |
437 GpuProcessHost::GpuProcessHost(int host_id, GpuProcessKind kind) | 437 GpuProcessHost::GpuProcessHost(int host_id, GpuProcessKind kind) |
438 : host_id_(host_id), | 438 : host_id_(host_id), |
439 valid_(true), | 439 valid_(true), |
440 in_process_(false), | 440 in_process_(false), |
441 swiftshader_rendering_(false), | 441 swiftshader_rendering_(false), |
442 kind_(kind), | 442 kind_(kind), |
443 process_launched_(false), | 443 process_launched_(false), |
444 initialized_(false), | 444 initialized_(false) { |
445 uma_memory_stats_received_(false) { | |
446 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 445 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
447 switches::kSingleProcess) || | 446 switches::kSingleProcess) || |
448 base::CommandLine::ForCurrentProcess()->HasSwitch( | 447 base::CommandLine::ForCurrentProcess()->HasSwitch( |
449 switches::kInProcessGPU)) { | 448 switches::kInProcessGPU)) { |
450 in_process_ = true; | 449 in_process_ = true; |
451 } | 450 } |
452 | 451 |
453 // If the 'single GPU process' policy ever changes, we still want to maintain | 452 // If the 'single GPU process' policy ever changes, we still want to maintain |
454 // it for 'gpu thread' mode and only create one instance of host and thread. | 453 // it for 'gpu thread' mode and only create one instance of host and thread. |
455 DCHECK(!in_process_ || g_gpu_process_hosts[kind] == NULL); | 454 DCHECK(!in_process_ || g_gpu_process_hosts[kind] == NULL); |
(...skipping 27 matching lines...) Expand all Loading... |
483 | 482 |
484 // This is only called on the IO thread so no race against the constructor | 483 // This is only called on the IO thread so no race against the constructor |
485 // for another GpuProcessHost. | 484 // for another GpuProcessHost. |
486 if (g_gpu_process_hosts[kind_] == this) | 485 if (g_gpu_process_hosts[kind_] == this) |
487 g_gpu_process_hosts[kind_] = NULL; | 486 g_gpu_process_hosts[kind_] = NULL; |
488 | 487 |
489 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 488 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
490 UMA_HISTOGRAM_COUNTS_100("GPU.AtExitSurfaceCount", | 489 UMA_HISTOGRAM_COUNTS_100("GPU.AtExitSurfaceCount", |
491 GpuSurfaceTracker::Get()->GetSurfaceCount()); | 490 GpuSurfaceTracker::Get()->GetSurfaceCount()); |
492 #endif | 491 #endif |
493 UMA_HISTOGRAM_BOOLEAN("GPU.AtExitReceivedMemoryStats", | |
494 uma_memory_stats_received_); | |
495 | |
496 if (uma_memory_stats_received_) { | |
497 UMA_HISTOGRAM_COUNTS_100("GPU.AtExitContextGroupCount", | |
498 uma_memory_stats_.context_group_count); | |
499 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
500 "GPU.AtExitMBytesAllocated", | |
501 uma_memory_stats_.bytes_allocated_current / 1024 / 1024, 1, 2000, 50); | |
502 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
503 "GPU.AtExitMBytesAllocatedMax", | |
504 uma_memory_stats_.bytes_allocated_max / 1024 / 1024, 1, 2000, 50); | |
505 } | |
506 | 492 |
507 std::string message; | 493 std::string message; |
508 bool block_offscreen_contexts = true; | 494 bool block_offscreen_contexts = true; |
509 if (!in_process_) { | 495 if (!in_process_) { |
510 int exit_code; | 496 int exit_code; |
511 base::TerminationStatus status = process_->GetTerminationStatus( | 497 base::TerminationStatus status = process_->GetTerminationStatus( |
512 false /* known_dead */, &exit_code); | 498 false /* known_dead */, &exit_code); |
513 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessTerminationStatus", | 499 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessTerminationStatus", |
514 status, | 500 status, |
515 base::TERMINATION_STATUS_MAX_ENUM); | 501 base::TERMINATION_STATUS_MAX_ENUM); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 OnGpuMemoryBufferCreated) | 637 OnGpuMemoryBufferCreated) |
652 #if defined(OS_ANDROID) | 638 #if defined(OS_ANDROID) |
653 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyingVideoSurfaceAck, | 639 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyingVideoSurfaceAck, |
654 OnDestroyingVideoSurfaceAck) | 640 OnDestroyingVideoSurfaceAck) |
655 #endif | 641 #endif |
656 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, | 642 IPC_MESSAGE_HANDLER(GpuHostMsg_DidCreateOffscreenContext, |
657 OnDidCreateOffscreenContext) | 643 OnDidCreateOffscreenContext) |
658 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) | 644 IPC_MESSAGE_HANDLER(GpuHostMsg_DidLoseContext, OnDidLoseContext) |
659 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, | 645 IPC_MESSAGE_HANDLER(GpuHostMsg_DidDestroyOffscreenContext, |
660 OnDidDestroyOffscreenContext) | 646 OnDidDestroyOffscreenContext) |
661 IPC_MESSAGE_HANDLER(GpuHostMsg_GpuMemoryUmaStats, | |
662 OnGpuMemoryUmaStatsReceived) | |
663 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, OnDestroyChannel) | 647 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyChannel, OnDestroyChannel) |
664 IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader, OnCacheShader) | 648 IPC_MESSAGE_HANDLER(GpuHostMsg_CacheShader, OnCacheShader) |
665 #if defined(OS_WIN) | 649 #if defined(OS_WIN) |
666 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceCreatedChildWindow, | 650 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceCreatedChildWindow, |
667 OnAcceleratedSurfaceCreatedChildWindow) | 651 OnAcceleratedSurfaceCreatedChildWindow) |
668 #endif | 652 #endif |
669 IPC_MESSAGE_HANDLER(GpuHostMsg_FieldTrialActivated, OnFieldTrialActivated); | 653 IPC_MESSAGE_HANDLER(GpuHostMsg_FieldTrialActivated, OnFieldTrialActivated); |
670 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) | 654 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) |
671 IPC_END_MESSAGE_MAP() | 655 IPC_END_MESSAGE_MAP() |
672 | 656 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 return; | 897 return; |
914 } | 898 } |
915 | 899 |
916 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs(url, guilt); | 900 GpuDataManagerImpl::GetInstance()->BlockDomainFrom3DAPIs(url, guilt); |
917 } | 901 } |
918 | 902 |
919 void GpuProcessHost::OnDidDestroyOffscreenContext(const GURL& url) { | 903 void GpuProcessHost::OnDidDestroyOffscreenContext(const GURL& url) { |
920 urls_with_live_offscreen_contexts_.erase(url); | 904 urls_with_live_offscreen_contexts_.erase(url); |
921 } | 905 } |
922 | 906 |
923 void GpuProcessHost::OnGpuMemoryUmaStatsReceived( | |
924 const gpu::GPUMemoryUmaStats& stats) { | |
925 TRACE_EVENT0("gpu", "GpuProcessHost::OnGpuMemoryUmaStatsReceived"); | |
926 uma_memory_stats_received_ = true; | |
927 uma_memory_stats_ = stats; | |
928 } | |
929 | |
930 void GpuProcessHost::OnFieldTrialActivated(const std::string& trial_name) { | 907 void GpuProcessHost::OnFieldTrialActivated(const std::string& trial_name) { |
931 // Activate the trial in the browser process to match its state in the | 908 // Activate the trial in the browser process to match its state in the |
932 // GPU process. This is done by calling FindFullName which finalizes the group | 909 // GPU process. This is done by calling FindFullName which finalizes the group |
933 // and activates the trial. | 910 // and activates the trial. |
934 base::FieldTrialList::FindFullName(trial_name); | 911 base::FieldTrialList::FindFullName(trial_name); |
935 } | 912 } |
936 | 913 |
937 void GpuProcessHost::OnProcessLaunched() { | 914 void GpuProcessHost::OnProcessLaunched() { |
938 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", | 915 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", |
939 base::TimeTicks::Now() - init_start_time_); | 916 base::TimeTicks::Now() - init_start_time_); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1189 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1166 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
1190 ClientIdToShaderCacheMap::iterator iter = | 1167 ClientIdToShaderCacheMap::iterator iter = |
1191 client_id_to_shader_cache_.find(client_id); | 1168 client_id_to_shader_cache_.find(client_id); |
1192 // If the cache doesn't exist then this is an off the record profile. | 1169 // If the cache doesn't exist then this is an off the record profile. |
1193 if (iter == client_id_to_shader_cache_.end()) | 1170 if (iter == client_id_to_shader_cache_.end()) |
1194 return; | 1171 return; |
1195 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1172 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
1196 } | 1173 } |
1197 | 1174 |
1198 } // namespace content | 1175 } // namespace content |
OLD | NEW |